国展报名

wp
workabee 8 months ago
parent e45f0591ab
commit 4dba7eff58

@ -0,0 +1,33 @@
FROM 172.16.100.99:9006/golang:alpine AS builder
LABEL stage=gobuilder
#ENV DUBBO_GO_CONFIG_PATH ./conf/dubbogo.yaml
#ENV MODE_ENV test
ENV CGO_ENABLED 0
ENV GOPROXY https://goproxy.cn,direct
#RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
#RUN apk update --no-cache && apk add --no-cache tzdata
WORKDIR /build
#ADD go.mod .
#ADD go.sum .
#RUN go mod download
#COPY . .
#RUN go env -w GOOS=linux && go build -ldflags "-s -w" -o /app/meal-main-server ./cmd/app.go
COPY exhibition-main-server /app/exhibition-main-server
#FROM 172.16.100.99:9006/alpine
#RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
#RUN apk update --no-cache
#RUN apk add --no-cache ca-certificates
#RUN apk add --no-cache tzdata
FROM 172.16.100.99:9006/self-alpine
COPY ./conf /app/conf
ENV TZ Asia/Shanghai
ENV MODE_ENV prod
WORKDIR /app
COPY --from=builder /app/exhibition-main-server .
EXPOSE 9025
CMD ["/app/exhibition-main-server"]

@ -0,0 +1,33 @@
FROM 172.16.100.99:9006/golang:alpine AS builder
LABEL stage=gobuilder
#ENV DUBBO_GO_CONFIG_PATH ./conf/dubbogo.yaml
#ENV MODE_ENV test
ENV CGO_ENABLED 0
ENV GOPROXY https://goproxy.cn,direct
#RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
#RUN apk update --no-cache && apk add --no-cache tzdata
WORKDIR /build
#ADD go.mod .
#ADD go.sum .
#RUN go mod download
#COPY . .
#RUN go env -w GOOS=linux && go build -ldflags "-s -w" -o /app/meal-main-server ./cmd/app.go
COPY exhibition-main-server /app/exhibition-main-server
#FROM 172.16.100.99:9006/alpine
#RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
#RUN apk update --no-cache
#RUN apk add --no-cache ca-certificates
#RUN apk add --no-cache tzdata
FROM 172.16.100.99:9006/self-alpine
COPY ./conf /app/conf
ENV TZ Asia/Shanghai
ENV MODE_ENV test
WORKDIR /app
COPY --from=builder /app/exhibition-main-server .
EXPOSE 9025
CMD ["/app/exhibition-main-server"]

@ -0,0 +1,41 @@
FROM golang:1.20-alpine AS builder
MAINTAINER 570956418@qq.com
LABEL stage=gobuilder
ENV DUBBO_GO_CONFIG_PATH ./conf/dubbogo.yaml
ENV CGO_ENABLED 0
ENV GOOS linux
ENV GOPROXY https://goproxy.cn,direct
#RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
#
#RUN apk update --no-cache && apk add --no-cache tzdata
WORKDIR /build
#ADD ./fonchain-main/go.mod .
#ADD ./fonchain-main/go.sum .
#COPY ./utils ../utils
#RUN go env -w GO111MODULE=on
#RUN go env -w GOPROXY=https://goproxy.cn,direct
#RUN go mod download
#COPY ./fonchain-main .
#RUN go build -ldflags "-s -w" -o /app/mainServer ./cmd/app.go
COPY ./build/exhibition-main-server /app/exhibition-main-server
FROM 172.16.100.99:9006/fonchain-base
#FROM alpine
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
RUN apk update --no-cache
RUN apk add --no-cache ca-certificates
RUN apk add --no-cache tzdata
COPY ./conf /app/conf
COPY ./data /app/data
ENV TZ Asia/Shanghai
#ENV DUBBO_GO_CONFIG_PATH ./conf/dubbogo.yaml
ENV MODE_ENV prod
#RUN apk add --no-cache ffmpeg
WORKDIR /app
COPY --from=builder /app/exhibition-main-server .
EXPOSE 9040
CMD ["/app/exhibition-main-server"]

@ -0,0 +1,41 @@
FROM golang:1.20-alpine AS builder
MAINTAINER 570956418@qq.com
LABEL stage=gobuilder
ENV DUBBO_GO_CONFIG_PATH ./conf/dubbogo.yaml
ENV CGO_ENABLED 0
ENV GOOS linux
ENV GOPROXY https://goproxy.cn,direct
#RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
#
#RUN apk update --no-cache && apk add --no-cache tzdata
WORKDIR /build
#ADD ./fonchain-main/go.mod .
#ADD ./fonchain-main/go.sum .
#COPY ./utils ../utils
#RUN go env -w GO111MODULE=on
#RUN go env -w GOPROXY=https://goproxy.cn,direct
#RUN go mod download
#COPY ./fonchain-main .
#RUN go build -ldflags "-s -w" -o /app/mainServer ./cmd/app.go
COPY ./build/exhibition-main-server /app/exhibition-main-server
FROM 172.16.100.99:9006/fonchain-base
#FROM alpine
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
RUN apk update --no-cache
RUN apk add --no-cache ca-certificates
RUN apk add --no-cache tzdata
COPY ./conf /app/conf
COPY ./data /app/data
ENV TZ Asia/Shanghai
#ENV DUBBO_GO_CONFIG_PATH ./conf/dubbogo.yaml
ENV MODE_ENV test
#RUN apk add --no-cache ffmpeg
WORKDIR /app
COPY --from=builder /app/exhibition-main-server .
EXPOSE 9040
CMD ["/app/exhibition-main-server"]

@ -267,6 +267,8 @@ type RecordListReq struct {
Keyword string `protobuf:"bytes,1,opt,name=keyword,proto3" json:"keyword"` Keyword string `protobuf:"bytes,1,opt,name=keyword,proto3" json:"keyword"`
Page int32 `protobuf:"varint,2,opt,name=page,proto3" json:"page"` Page int32 `protobuf:"varint,2,opt,name=page,proto3" json:"page"`
PageSize int32 `protobuf:"varint,3,opt,name=pageSize,proto3" json:"pageSize"` PageSize int32 `protobuf:"varint,3,opt,name=pageSize,proto3" json:"pageSize"`
SortKey int32 `protobuf:"varint,4,opt,name=sortKey,proto3" json:"sortKey"`
Sort string `protobuf:"bytes,5,opt,name=sort,proto3" json:"sort"`
} }
func (x *RecordListReq) Reset() { func (x *RecordListReq) Reset() {
@ -322,6 +324,20 @@ func (x *RecordListReq) GetPageSize() int32 {
return 0 return 0
} }
func (x *RecordListReq) GetSortKey() int32 {
if x != nil {
return x.SortKey
}
return 0
}
func (x *RecordListReq) GetSort() string {
if x != nil {
return x.Sort
}
return ""
}
type RecordListResp struct { type RecordListResp struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
@ -641,68 +657,71 @@ var file_pb_exhibition_proto_rawDesc = []byte{
0x03, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x12, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x12,
0x2c, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x2c, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e,
0x65, 0x78, 0x68, 0x69, 0x62, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x65, 0x78, 0x68, 0x69, 0x62, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73,
0x74, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x59, 0x0a, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x87, 0x01,
0x0d, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a, 0x0d, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x12,
0x0a, 0x07, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x18, 0x0a, 0x07, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
0x07, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x67, 0x65, 0x52, 0x07, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x67,
0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x70, 0x61, 0x67, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x70, 0x61, 0x67, 0x65, 0x12, 0x1a, 0x0a,
0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52,
0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x22, 0x96, 0x01, 0x0a, 0x0e, 0x52, 0x65, 0x63, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x6f, 0x72,
0x6f, 0x72, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x2c, 0x0a, 0x04, 0x64, 0x74, 0x4b, 0x65, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x73, 0x6f, 0x72, 0x74,
0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x65, 0x78, 0x68, 0x69, 0x4b, 0x65, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x6f, 0x72, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28,
0x62, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x49, 0x09, 0x52, 0x04, 0x73, 0x6f, 0x72, 0x74, 0x22, 0x96, 0x01, 0x0a, 0x0e, 0x52, 0x65, 0x63, 0x6f,
0x6e, 0x66, 0x6f, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x72, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x2c, 0x0a, 0x04, 0x64, 0x61,
0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x74, 0x61, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x65, 0x78, 0x68, 0x69, 0x62,
0x12, 0x0a, 0x04, 0x70, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x70,
0x61, 0x67, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x18,
0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12,
0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73,
0x67, 0x22, 0x11, 0x0a, 0x0f, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x63, 0x6f, 0x72,
0x64, 0x52, 0x65, 0x71, 0x22, 0x92, 0x02, 0x0a, 0x0a, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x49,
0x6e, 0x66, 0x6f, 0x12, 0x1e, 0x0a, 0x0a, 0x61, 0x72, 0x74, 0x69, 0x73, 0x74, 0x4e, 0x61, 0x6d,
0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x61, 0x72, 0x74, 0x69, 0x73, 0x74, 0x4e,
0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x67, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x18, 0x04, 0x20,
0x01, 0x28, 0x05, 0x52, 0x06, 0x67, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x12, 0x1a, 0x0a, 0x08, 0x70,
0x68, 0x6f, 0x6e, 0x65, 0x4e, 0x75, 0x6d, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70,
0x68, 0x6f, 0x6e, 0x65, 0x4e, 0x75, 0x6d, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x64, 0x43, 0x61, 0x72,
0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x69, 0x64, 0x43, 0x61, 0x72, 0x64, 0x12,
0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09,
0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x69, 0x64, 0x43,
0x61, 0x72, 0x64, 0x50, 0x68, 0x6f, 0x74, 0x6f, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b,
0x69, 0x64, 0x43, 0x61, 0x72, 0x64, 0x50, 0x68, 0x6f, 0x74, 0x6f, 0x12, 0x20, 0x0a, 0x0b, 0x61,
0x72, 0x74, 0x69, 0x73, 0x74, 0x50, 0x68, 0x6f, 0x74, 0x6f, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09,
0x52, 0x0b, 0x61, 0x72, 0x74, 0x69, 0x73, 0x74, 0x50, 0x68, 0x6f, 0x74, 0x6f, 0x12, 0x1c, 0x0a,
0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09,
0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x75,
0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09,
0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x22, 0x50, 0x0a, 0x10, 0x45, 0x78, 0x70,
0x6f, 0x72, 0x74, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, 0x2a, 0x0a,
0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x65, 0x78,
0x68, 0x69, 0x62, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x49,
0x6e, 0x66, 0x6f, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67,
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x32, 0xc4, 0x02, 0x0a, 0x0a,
0x45, 0x78, 0x68, 0x69, 0x62, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x42, 0x0a, 0x0a, 0x43, 0x68,
0x65, 0x63, 0x6b, 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x12, 0x18, 0x2e, 0x65, 0x78, 0x68, 0x69, 0x62,
0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x49, 0x6e,
0x66, 0x6f, 0x1a, 0x1a, 0x2e, 0x65, 0x78, 0x68, 0x69, 0x62, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x66, 0x6f, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e,
0x43, 0x68, 0x65, 0x63, 0x6b, 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x52, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x12,
0x0a, 0x12, 0x53, 0x61, 0x76, 0x65, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x0a, 0x04, 0x70, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x70, 0x61,
0x63, 0x6f, 0x72, 0x64, 0x12, 0x18, 0x2e, 0x65, 0x78, 0x68, 0x69, 0x62, 0x69, 0x74, 0x69, 0x6f, 0x67, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x04,
0x6e, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x1a, 0x22, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x10,
0x2e, 0x65, 0x78, 0x68, 0x69, 0x62, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x53, 0x61, 0x76, 0x65, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67,
0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x22, 0x11, 0x0a, 0x0f, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64,
0x73, 0x70, 0x12, 0x4b, 0x0a, 0x12, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x52, 0x65, 0x71, 0x22, 0x92, 0x02, 0x0a, 0x0a, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x49, 0x6e,
0x63, 0x6f, 0x72, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x19, 0x2e, 0x65, 0x78, 0x68, 0x69, 0x62, 0x66, 0x6f, 0x12, 0x1e, 0x0a, 0x0a, 0x61, 0x72, 0x74, 0x69, 0x73, 0x74, 0x4e, 0x61, 0x6d, 0x65,
0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x61, 0x72, 0x74, 0x69, 0x73, 0x74, 0x4e, 0x61,
0x52, 0x65, 0x71, 0x1a, 0x1a, 0x2e, 0x65, 0x78, 0x68, 0x69, 0x62, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x67, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01,
0x2e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x28, 0x05, 0x52, 0x06, 0x67, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x68,
0x51, 0x0a, 0x14, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x6f, 0x6e, 0x65, 0x4e, 0x75, 0x6d, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x68,
0x72, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x1b, 0x2e, 0x65, 0x78, 0x68, 0x69, 0x62, 0x69, 0x6f, 0x6e, 0x65, 0x4e, 0x75, 0x6d, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x64, 0x43, 0x61, 0x72, 0x64,
0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x69, 0x64, 0x43, 0x61, 0x72, 0x64, 0x12, 0x18,
0x64, 0x52, 0x65, 0x71, 0x1a, 0x1c, 0x2e, 0x65, 0x78, 0x68, 0x69, 0x62, 0x69, 0x74, 0x69, 0x6f, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52,
0x6e, 0x2e, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x69, 0x64, 0x43, 0x61,
0x73, 0x70, 0x42, 0x11, 0x5a, 0x0f, 0x2e, 0x2f, 0x70, 0x62, 0x2f, 0x65, 0x78, 0x68, 0x69, 0x62, 0x72, 0x64, 0x50, 0x68, 0x6f, 0x74, 0x6f, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x69,
0x69, 0x74, 0x69, 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x64, 0x43, 0x61, 0x72, 0x64, 0x50, 0x68, 0x6f, 0x74, 0x6f, 0x12, 0x20, 0x0a, 0x0b, 0x61, 0x72,
0x74, 0x69, 0x73, 0x74, 0x50, 0x68, 0x6f, 0x74, 0x6f, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52,
0x0b, 0x61, 0x72, 0x74, 0x69, 0x73, 0x74, 0x50, 0x68, 0x6f, 0x74, 0x6f, 0x12, 0x1c, 0x0a, 0x09,
0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52,
0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x75, 0x70,
0x64, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x75,
0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x22, 0x50, 0x0a, 0x10, 0x45, 0x78, 0x70, 0x6f,
0x72, 0x74, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, 0x2a, 0x0a, 0x04,
0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x65, 0x78, 0x68,
0x69, 0x62, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x49, 0x6e,
0x66, 0x6f, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18,
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x32, 0xc4, 0x02, 0x0a, 0x0a, 0x45,
0x78, 0x68, 0x69, 0x62, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x42, 0x0a, 0x0a, 0x43, 0x68, 0x65,
0x63, 0x6b, 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x12, 0x18, 0x2e, 0x65, 0x78, 0x68, 0x69, 0x62, 0x69,
0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x66,
0x6f, 0x1a, 0x1a, 0x2e, 0x65, 0x78, 0x68, 0x69, 0x62, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x43,
0x68, 0x65, 0x63, 0x6b, 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x52, 0x0a,
0x12, 0x53, 0x61, 0x76, 0x65, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x63,
0x6f, 0x72, 0x64, 0x12, 0x18, 0x2e, 0x65, 0x78, 0x68, 0x69, 0x62, 0x69, 0x74, 0x69, 0x6f, 0x6e,
0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x1a, 0x22, 0x2e,
0x65, 0x78, 0x68, 0x69, 0x62, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x53, 0x61, 0x76, 0x65, 0x52,
0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x73,
0x70, 0x12, 0x4b, 0x0a, 0x12, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x63,
0x6f, 0x72, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x19, 0x2e, 0x65, 0x78, 0x68, 0x69, 0x62, 0x69,
0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x52,
0x65, 0x71, 0x1a, 0x1a, 0x2e, 0x65, 0x78, 0x68, 0x69, 0x62, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2e,
0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x51,
0x0a, 0x14, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72,
0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x1b, 0x2e, 0x65, 0x78, 0x68, 0x69, 0x62, 0x69, 0x74,
0x69, 0x6f, 0x6e, 0x2e, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64,
0x52, 0x65, 0x71, 0x1a, 0x1c, 0x2e, 0x65, 0x78, 0x68, 0x69, 0x62, 0x69, 0x74, 0x69, 0x6f, 0x6e,
0x2e, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x73,
0x70, 0x42, 0x11, 0x5a, 0x0f, 0x2e, 0x2f, 0x70, 0x62, 0x2f, 0x65, 0x78, 0x68, 0x69, 0x62, 0x69,
0x74, 0x69, 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (

@ -7,8 +7,8 @@ system:
cert: cert:
is_https: false is_https: false
cron: false cron: false
key_path: "" key_path: "/cert/erptest.fontree.cn/erptest.fontree.cn.key"
cert_path: "" cert_path: "/cert/erptest.fontree.cn/erptest.fontree.cn.pem"
redis: redis:
db: 1 db: 1
addr: 127.0.0.1:6379 addr: 127.0.0.1:6379
@ -25,3 +25,11 @@ zapLog:
jwt: jwt:
key: "3Ei*^!a6^6$w^wgK" key: "3Ei*^!a6^6$w^wgK"
expire: 24 expire: 24
bos:
Ak: "ALTAKxrqOQHnAN525Tb2GX4Bhe"
Sk: "d2ecaa9d75114d3b9f42b99014198306"
BucketName: "dci-file-new"
BosUrl: ".bj.bcebos.com"
BosBaseDir: "fonchain-main"
BosHttp: "https://"
BosDomain: "cdns.fontree.cn"

@ -1,6 +1,6 @@
dubbo: dubbo:
registries: registries:
meal_zk: demoZK:
protocol: zookeeper protocol: zookeeper
timeout: 30s timeout: 30s
address: 127.0.0.1:2181 address: 127.0.0.1:2181

@ -25,3 +25,11 @@ zapLog:
jwt: jwt:
key: "tP0xXGErz4~" key: "tP0xXGErz4~"
expire: 24 expire: 24
bos:
Ak: "ALTAKxrqOQHnAN525Tb2GX4Bhe"
Sk: "d2ecaa9d75114d3b9f42b99014198306"
BucketName: "dci-file-new"
BosUrl: ".bj.bcebos.com"
BosBaseDir: "fonchain-main"
BosHttp: "https://"
BosDomain: "cdns.fontree.cn"

@ -1,6 +1,6 @@
dubbo: dubbo:
registries: registries:
meal_zk: demoZK:
protocol: zookeeper protocol: zookeeper
timeout: 3s timeout: 3s
address: zookeeper:2181 address: zookeeper:2181

@ -25,3 +25,11 @@ zapLog:
jwt: jwt:
key: "SxjwBuEcHg42t73" key: "SxjwBuEcHg42t73"
expire: 24 expire: 24
bos:
Ak: "ALTAKxrqOQHnAN525Tb2GX4Bhe"
Sk: "d2ecaa9d75114d3b9f42b99014198306"
BucketName: "dci-file-new"
BosUrl: ".bj.bcebos.com"
BosBaseDir: "fonchain-main"
BosHttp: "https://"
BosDomain: "cdns.fontree.cn"

@ -1,6 +1,6 @@
dubbo: dubbo:
registries: registries:
meal_zk: demoZK:
protocol: zookeeper protocol: zookeeper
timeout: 3s timeout: 3s
address: zookeeper:2181 address: zookeeper:2181

@ -16,7 +16,9 @@ replace (
require ( require (
dubbo.apache.org/dubbo-go/v3 v3.0.5 dubbo.apache.org/dubbo-go/v3 v3.0.5
github.com/360EntSecGroup-Skylar/excelize v1.4.1
github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/disintegration/imaging v1.6.2
github.com/dubbogo/gost v1.13.2 github.com/dubbogo/gost v1.13.2
github.com/dubbogo/grpc-go v1.42.10 github.com/dubbogo/grpc-go v1.42.10
github.com/dubbogo/triple v1.2.2-rc2 github.com/dubbogo/triple v1.2.2-rc2
@ -39,6 +41,7 @@ require (
github.com/satori/go.uuid v1.2.0 github.com/satori/go.uuid v1.2.0
github.com/spf13/viper v1.7.0 github.com/spf13/viper v1.7.0
github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271 github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271
github.com/tealeg/xlsx v1.0.5
github.com/u2takey/ffmpeg-go v0.5.0 github.com/u2takey/ffmpeg-go v0.5.0
github.com/uber/jaeger-client-go v2.30.0+incompatible github.com/uber/jaeger-client-go v2.30.0+incompatible
go.uber.org/zap v1.21.0 go.uber.org/zap v1.21.0
@ -118,6 +121,7 @@ require (
github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
github.com/mschoch/smat v0.2.0 // indirect github.com/mschoch/smat v0.2.0 // indirect
github.com/nacos-group/nacos-sdk-go v1.1.4 // indirect github.com/nacos-group/nacos-sdk-go v1.1.4 // indirect
github.com/oliveagle/jsonpath v0.0.0-20180606110733-2e52cf6e6852 // indirect github.com/oliveagle/jsonpath v0.0.0-20180606110733-2e52cf6e6852 // indirect

@ -31,5 +31,6 @@ const (
ERROR_BAIDU_IMAGE = "图片审核不通过" ERROR_BAIDU_IMAGE = "图片审核不通过"
ERROR_BAIDU_FAIL = "图片审核失败" ERROR_BAIDU_FAIL = "图片审核失败"
ErrorUploadBos ErrorUploadBos = "上传到服务器失败"
ErrorDownloadFile = "下载文件错误"
) )

@ -0,0 +1,97 @@
package logic
import (
"fmt"
"github.com/360EntSecGroup-Skylar/excelize"
"github.com/exhibition-main/internal/model"
"github.com/exhibition-main/pkg/utils"
"image"
"math"
"os"
"path/filepath"
"strings"
)
// DealListExcelImg 处理Excel图片
func DealListExcelImg(filePath string) (err error) {
f, err := excelize.OpenFile(filePath)
filename := filepath.Base(filePath)
var cellHeight, cellWidth float64 = 150, 40
//minColumn := int([]byte("A")[0])
// string(rune(i))
rows := f.GetRows("Sheet1")
var columnFullName string
var lineNo, columnNo int32
var cellNo string
for k, row := range rows {
lineNo = int32(k + 1)
if lineNo != 1 {
f.SetRowHeight("Sheet1", int(lineNo), cellHeight)
}
var firstCell int32
var suffix string
var columnName, firstCellName string
columnFullName = ""
for kk, colCell := range row {
cellNo = ""
columnNo = int32(int([]byte("A")[0]) + kk%26)
columnName = string(columnNo)
if kk >= 26 {
firstCell = int32(int([]byte("A")[0]) + (int(math.Floor(float64(kk)/float64(26))) - 1))
firstCellName = string(firstCell)
}
columnFullName = fmt.Sprintf("%s%s", firstCellName, columnName)
if strings.Contains(colCell, "cdns.fontree.cn") {
suffix = colCell[strings.LastIndex(colCell, "."):]
if strings.Contains(".jpg,.png,.gif,.bmp,.jpeg,", suffix) {
cellNo = fmt.Sprintf("%s%v", columnFullName, lineNo)
// 需要转化图片 ,先下载图片
fullPath, _ := utils.SaveUrlFileDisk(colCell, model.TmpArtworkDir, "")
reader, _ := os.Open(fullPath)
defer reader.Close()
im, _, _ := image.DecodeConfig(reader)
rateX := cellWidth * 2.0 / float64(im.Width)
rateY := cellHeight * 1.33 / float64(im.Height)
f.SetCellValue("Sheet1", cellNo, "")
err = f.AddPicture("Sheet1", cellNo, fullPath, fmt.Sprintf(`{"x_scale": %v, "y_scale": %v, "hyperlink": "%s", "hyperlink_type": "External"}`, rateX, rateY, colCell))
_ = os.Remove(fullPath)
if err != nil {
return
}
}
}
}
}
f.SetColWidth("Sheet1", "A", columnFullName, cellWidth)
//err = f.AddPicture("Sheet1", "A2", "./runtime/small.png", `{"x_scale": 1, "y_scale": 1, "hyperlink": "#Sheet2!D8", "hyperlink_type": "Location"}`)
//err = f.AddPicture("Sheet1", "A2", "./runtime/small.png", `{"x_with": 30, "y_hright": 50, "hyperlink": "#Sheet2!D8", "hyperlink_type": "Location"}`)
//err = f.AddPicture("Sheet1", "H2", "./runtime/field_3.jpg", `{"x_offset": 15, "y_offset": 10, "hyperlink": "https://www.baidu.com", "hyperlink_type": "External", "print_obj": true, "lock_aspect_ratio": false, "locked": false, "positioning": "oneCell"}`)
//if err := f.AddPicture("Sheet1", "D2", "./runtime/field_3.jpg",
// `{"x_scale": 0.5, "y_scale": 0.5}`); err != nil {
// fmt.Println(err)
//}
if err != nil {
fmt.Println(err)
}
err = f.SaveAs(fmt.Sprintf("%s%s", model.MediaPath, filename))
if err != nil {
fmt.Println(err)
}
// Insert a picture offset in the cell with printing support.
//err = xlsx.AddPicture("Sheet1", "C2", "./runtime/field_3.jpg", `{"x_offset": 15, "y_offset": 10, "print_obj": true, "lock_aspect_ratio": false, "locked": false}`)
//if err != nil {
// fmt.Println(err)
//}
// Save the xlsx file with the origin path.
//err = xlsx.Save()
//if err != nil {
// fmt.Println(err)
//}
//ResponseQuickMsg(c, e.Ok, "成功", nil)
return
}

@ -28,9 +28,10 @@ func NewRouter() *gin.Engine {
registerAuth := auth.Group("register") registerAuth := auth.Group("register")
{ {
registerAuth.POST("register_record_list", service.RegisterRecordList) registerAuth.POST("register_record_list", service.RegisterList)
registerAuth.POST("check_by_phone", service.CheckPhone) registerAuth.POST("check_by_phone", service.CheckByPhone)
registerAuth.POST("save_register_info", service.SaveRegisterRecord) registerAuth.POST("save_register_info", service.SaveRegister)
registerAuth.POST("export_register", service.ExportRegister)
} }
//静态文件 //静态文件

@ -2,14 +2,19 @@ package service
import ( import (
"context" "context"
"fmt"
"github.com/dubbogo/gost/log/logger" "github.com/dubbogo/gost/log/logger"
"github.com/exhibition-main/api/exhibition" "github.com/exhibition-main/api/exhibition"
"github.com/exhibition-main/internal/config"
"github.com/exhibition-main/internal/model"
"github.com/exhibition-main/internal/msg" "github.com/exhibition-main/internal/msg"
"github.com/exhibition-main/internal/response" "github.com/exhibition-main/internal/response"
"github.com/exhibition-main/pkg/logic"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"time"
) )
func RegisterRecordList(c *gin.Context) { func RegisterList(c *gin.Context) {
var recordListReq exhibition.RecordListReq var recordListReq exhibition.RecordListReq
if err := c.ShouldBind(&recordListReq); err != nil { if err := c.ShouldBind(&recordListReq); err != nil {
logger.Errorf("RegisterRecordList ShouldBind err", err) logger.Errorf("RegisterRecordList ShouldBind err", err)
@ -26,7 +31,7 @@ func RegisterRecordList(c *gin.Context) {
} }
func CheckPhone(c *gin.Context) { func CheckByPhone(c *gin.Context) {
var registerInfo exhibition.RegisterInfo var registerInfo exhibition.RegisterInfo
if err := c.ShouldBind(&registerInfo); err != nil { if err := c.ShouldBind(&registerInfo); err != nil {
logger.Errorf("CheckPhone ShouldBind err", err) logger.Errorf("CheckPhone ShouldBind err", err)
@ -43,7 +48,7 @@ func CheckPhone(c *gin.Context) {
} }
func SaveRegisterRecord(c *gin.Context) { func SaveRegister(c *gin.Context) {
var registerInfo exhibition.RegisterInfo var registerInfo exhibition.RegisterInfo
if err := c.ShouldBind(&registerInfo); err != nil { if err := c.ShouldBind(&registerInfo); err != nil {
logger.Errorf("SaveRegisterRecord ShouldBind err", err) logger.Errorf("SaveRegisterRecord ShouldBind err", err)
@ -59,3 +64,48 @@ func SaveRegisterRecord(c *gin.Context) {
return return
} }
// ExportRegister 导出报名信息列表
func ExportRegister(c *gin.Context) {
var exportRecordReq exhibition.ExportRecordReq
//if err := c.ShouldBind(&exportRecordReq); err != nil {
// logger.Errorf("SaveRegisterRecord ShouldBind err", err)
// response.ResponseQuickMsg(c, msg.Fail, msg.INVALID_PARAMS, nil)
// return
//}
resp, err := GrpcExhibitionClientImpl.ExportRegisterRecord(context.Background(), &exportRecordReq)
if err != nil {
response.ResponseQuickMsg(c, msg.Fail, err.Error(), nil)
return
}
//组装数据
if len(resp.Data) == 0 {
resp.Data = []*exhibition.ExportInfo{}
}
columns := make([]string, 0)
columns = append(columns, "画家姓名", "性别", "手机号", "身份证号", "通讯地址", "身份证照片", "本人近照", "报名时间", "更新时间")
exportFileName := fmt.Sprintf("国展报名%v.xlsx", time.Now().String())
filePath := fmt.Sprintf("./runtime/%s", exportFileName)
// 下载图片 自适应插入到Excel
err = logic.DealListExcelImg(filePath)
if err != nil {
response.ResponseQuickMsg(c, msg.Fail, err.Error(), nil)
return
}
var httpType string
if config.IsHttps {
httpType = model.HttpsType
} else {
httpType = model.HttpType
}
var exportUrl string = fmt.Sprintf("%s%s/static/%s", httpType, c.Request.Host, exportFileName)
response.ResponseQuickMsg(c, msg.Ok, resp.Msg, map[string]string{
"ExportUrl": exportUrl,
})
return
}

@ -2,10 +2,18 @@ package utils
import ( import (
"bytes" "bytes"
"errors"
"fmt"
"github.com/dubbogo/gost/log/logger"
"github.com/exhibition-main/internal/msg"
"github.com/tealeg/xlsx"
"go.uber.org/zap"
"io" "io"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"net/url" "net/url"
"os"
"strings"
"time" "time"
) )
@ -45,3 +53,78 @@ func Get(url string) string {
return result.String() return result.String()
} }
// ToExcelByType 转成Excel类型
func ToExcelByType(titleList []string, dataList []interface{}, dataType string, filePath string) (content io.ReadSeeker, err error) {
// 生成一个新的文件
file := xlsx.NewFile()
// 添加sheet页
sheet, _ := file.AddSheet("Sheet1")
// 插入表头
titleRow := sheet.AddRow()
for _, v := range titleList {
cell := titleRow.AddCell()
cell.Value = v
}
// 插入内容
for _, v := range dataList {
row := sheet.AddRow()
if dataType == "struct" {
row.WriteStruct(v, -1)
} else if dataType == "slice" {
row.WriteSlice(v, -1)
}
}
var buffer bytes.Buffer
_ = file.Write(&buffer)
if filePath != "" {
if err = file.Save(filePath); err != nil {
return
}
} else {
content = bytes.NewReader(buffer.Bytes())
}
return
}
// SaveUrlFileDisk 保存图片到本地
func SaveUrlFileDisk(url string, path string, filename string) (fullPath string, err error) {
if err = CreateDirPath(path); err != nil {
zap.L().Error("SaveUrlFileDisk err ", zap.Error(err))
return
}
if filename == "" {
stepName := strings.Split(url, "/")
if len(stepName) > 1 {
filename = stepName[len(stepName)-1]
}
}
resp, err := http.Get(url)
if err != nil {
logger.Errorf("SaveUrlFileDisk get err", err)
err = errors.New(msg.ErrorDownloadFile)
return
}
defer func() {
if err := recover(); err != nil {
logger.Errorf("SaveUrlFileDisk close err", err)
}
resp.Body.Close()
}()
bytes, err := ioutil.ReadAll(resp.Body)
fullPath = fmt.Sprintf("%s/%s", path, filename)
// 写入数据
err = ioutil.WriteFile(fullPath, bytes, 0777)
return
}
// CreateDirPath 递归创建文件夹
func CreateDirPath(path string) (err error) {
if _, err = os.Stat(path); os.IsNotExist(err) {
if err = os.MkdirAll(path, os.ModePerm); err != nil {
return
}
}
return
}

Loading…
Cancel
Save