修改从Excel导入到数据库信息方法

This commit is contained in:
孙肖扬 2025-03-12 14:24:05 +08:00
parent 3c5232823e
commit dd42e1f3cb
5 changed files with 136 additions and 75 deletions

View File

@ -926,7 +926,7 @@ var file_pb_exhibition_proto_rawDesc = []byte{
0x61, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x65, 0x78, 0x68, 0x69, 0x62, 0x69, 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, 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, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01,
0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x32, 0x8a, 0x03, 0x0a, 0x0a, 0x45, 0x78, 0x68, 0x69, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x32, 0xdd, 0x03, 0x0a, 0x0a, 0x45, 0x78, 0x68, 0x69,
0x62, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x42, 0x0a, 0x0a, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x50, 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, 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, 0x6e, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x1a, 0x1a,
@ -951,8 +951,14 @@ var file_pb_exhibition_proto_rawDesc = []byte{
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, 0x1a, 0x1b, 0x2e, 0x65, 0x78, 0x68, 0x69, 0x62, 0x69, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x1a, 0x1b, 0x2e, 0x65, 0x78, 0x68, 0x69, 0x62, 0x69,
0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x49, 0x64, 0x43, 0x61, 0x72, 0x64, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x49, 0x64, 0x43, 0x61, 0x72, 0x64,
0x52, 0x65, 0x73, 0x70, 0x42, 0x11, 0x5a, 0x0f, 0x2e, 0x2f, 0x70, 0x62, 0x2f, 0x65, 0x78, 0x68, 0x52, 0x65, 0x73, 0x70, 0x12, 0x51, 0x0a, 0x11, 0x49, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x49, 0x6e,
0x69, 0x62, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x66, 0x6f, 0x42, 0x79, 0x45, 0x78, 0x63, 0x65, 0x6c, 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, 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 (
@ -980,25 +986,27 @@ var file_pb_exhibition_proto_goTypes = []any{
(*ExportRecordResp)(nil), // 8: exhibition.ExportRecordResp (*ExportRecordResp)(nil), // 8: exhibition.ExportRecordResp
} }
var file_pb_exhibition_proto_depIdxs = []int32{ var file_pb_exhibition_proto_depIdxs = []int32{
0, // 0: exhibition.SaveRegisterRecordResp.data:type_name -> exhibition.RegisterInfo 0, // 0: exhibition.SaveRegisterRecordResp.data:type_name -> exhibition.RegisterInfo
0, // 1: exhibition.CheckPhoneResp.data:type_name -> exhibition.RegisterInfo 0, // 1: exhibition.CheckPhoneResp.data:type_name -> exhibition.RegisterInfo
0, // 2: exhibition.RecordListResp.data:type_name -> exhibition.RegisterInfo 0, // 2: exhibition.RecordListResp.data:type_name -> exhibition.RegisterInfo
7, // 3: exhibition.ExportRecordResp.data:type_name -> exhibition.ExportInfo 7, // 3: exhibition.ExportRecordResp.data:type_name -> exhibition.ExportInfo
0, // 4: exhibition.Exhibition.CheckPhone:input_type -> exhibition.RegisterInfo 0, // 4: exhibition.Exhibition.CheckPhone:input_type -> exhibition.RegisterInfo
0, // 5: exhibition.Exhibition.SaveRegisterRecord:input_type -> exhibition.RegisterInfo 0, // 5: exhibition.Exhibition.SaveRegisterRecord:input_type -> exhibition.RegisterInfo
4, // 6: exhibition.Exhibition.RegisterRecordList:input_type -> exhibition.RecordListReq 4, // 6: exhibition.Exhibition.RegisterRecordList:input_type -> exhibition.RecordListReq
6, // 7: exhibition.Exhibition.ExportRegisterRecord:input_type -> exhibition.ExportRecordReq 6, // 7: exhibition.Exhibition.ExportRegisterRecord:input_type -> exhibition.ExportRecordReq
0, // 8: exhibition.Exhibition.CheckIdCard:input_type -> exhibition.RegisterInfo 0, // 8: exhibition.Exhibition.CheckIdCard:input_type -> exhibition.RegisterInfo
2, // 9: exhibition.Exhibition.CheckPhone:output_type -> exhibition.CheckPhoneResp 0, // 9: exhibition.Exhibition.ImportInfoByExcel:input_type -> exhibition.RegisterInfo
1, // 10: exhibition.Exhibition.SaveRegisterRecord:output_type -> exhibition.SaveRegisterRecordResp 2, // 10: exhibition.Exhibition.CheckPhone:output_type -> exhibition.CheckPhoneResp
5, // 11: exhibition.Exhibition.RegisterRecordList:output_type -> exhibition.RecordListResp 1, // 11: exhibition.Exhibition.SaveRegisterRecord:output_type -> exhibition.SaveRegisterRecordResp
8, // 12: exhibition.Exhibition.ExportRegisterRecord:output_type -> exhibition.ExportRecordResp 5, // 12: exhibition.Exhibition.RegisterRecordList:output_type -> exhibition.RecordListResp
3, // 13: exhibition.Exhibition.CheckIdCard:output_type -> exhibition.CheckIdCardResp 8, // 13: exhibition.Exhibition.ExportRegisterRecord:output_type -> exhibition.ExportRecordResp
9, // [9:14] is the sub-list for method output_type 3, // 14: exhibition.Exhibition.CheckIdCard:output_type -> exhibition.CheckIdCardResp
4, // [4:9] is the sub-list for method input_type 1, // 15: exhibition.Exhibition.ImportInfoByExcel:output_type -> exhibition.SaveRegisterRecordResp
4, // [4:4] is the sub-list for extension type_name 10, // [10:16] is the sub-list for method output_type
4, // [4:4] is the sub-list for extension extendee 4, // [4:10] is the sub-list for method input_type
0, // [0:4] is the sub-list for field type_name 4, // [4:4] is the sub-list for extension type_name
4, // [4:4] is the sub-list for extension extendee
0, // [0:4] is the sub-list for field type_name
} }
func init() { file_pb_exhibition_proto_init() } func init() { file_pb_exhibition_proto_init() }

View File

@ -33,6 +33,7 @@ type ExhibitionClient interface {
RegisterRecordList(ctx context.Context, in *RecordListReq, opts ...grpc_go.CallOption) (*RecordListResp, common.ErrorWithAttachment) RegisterRecordList(ctx context.Context, in *RecordListReq, opts ...grpc_go.CallOption) (*RecordListResp, common.ErrorWithAttachment)
ExportRegisterRecord(ctx context.Context, in *ExportRecordReq, opts ...grpc_go.CallOption) (*ExportRecordResp, common.ErrorWithAttachment) ExportRegisterRecord(ctx context.Context, in *ExportRecordReq, opts ...grpc_go.CallOption) (*ExportRecordResp, common.ErrorWithAttachment)
CheckIdCard(ctx context.Context, in *RegisterInfo, opts ...grpc_go.CallOption) (*CheckIdCardResp, common.ErrorWithAttachment) CheckIdCard(ctx context.Context, in *RegisterInfo, opts ...grpc_go.CallOption) (*CheckIdCardResp, common.ErrorWithAttachment)
ImportInfoByExcel(ctx context.Context, in *RegisterInfo, opts ...grpc_go.CallOption) (*SaveRegisterRecordResp, common.ErrorWithAttachment)
} }
type exhibitionClient struct { type exhibitionClient struct {
@ -45,6 +46,7 @@ type ExhibitionClientImpl struct {
RegisterRecordList func(ctx context.Context, in *RecordListReq) (*RecordListResp, error) RegisterRecordList func(ctx context.Context, in *RecordListReq) (*RecordListResp, error)
ExportRegisterRecord func(ctx context.Context, in *ExportRecordReq) (*ExportRecordResp, error) ExportRegisterRecord func(ctx context.Context, in *ExportRecordReq) (*ExportRecordResp, error)
CheckIdCard func(ctx context.Context, in *RegisterInfo) (*CheckIdCardResp, error) CheckIdCard func(ctx context.Context, in *RegisterInfo) (*CheckIdCardResp, error)
ImportInfoByExcel func(ctx context.Context, in *RegisterInfo) (*SaveRegisterRecordResp, error)
} }
func (c *ExhibitionClientImpl) GetDubboStub(cc *triple.TripleConn) ExhibitionClient { func (c *ExhibitionClientImpl) GetDubboStub(cc *triple.TripleConn) ExhibitionClient {
@ -89,6 +91,12 @@ func (c *exhibitionClient) CheckIdCard(ctx context.Context, in *RegisterInfo, op
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/CheckIdCard", in, out) return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/CheckIdCard", in, out)
} }
func (c *exhibitionClient) ImportInfoByExcel(ctx context.Context, in *RegisterInfo, opts ...grpc_go.CallOption) (*SaveRegisterRecordResp, common.ErrorWithAttachment) {
out := new(SaveRegisterRecordResp)
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/ImportInfoByExcel", in, out)
}
// ExhibitionServer is the server API for Exhibition service. // ExhibitionServer is the server API for Exhibition service.
// All implementations must embed UnimplementedExhibitionServer // All implementations must embed UnimplementedExhibitionServer
// for forward compatibility // for forward compatibility
@ -98,6 +106,7 @@ type ExhibitionServer interface {
RegisterRecordList(context.Context, *RecordListReq) (*RecordListResp, error) RegisterRecordList(context.Context, *RecordListReq) (*RecordListResp, error)
ExportRegisterRecord(context.Context, *ExportRecordReq) (*ExportRecordResp, error) ExportRegisterRecord(context.Context, *ExportRecordReq) (*ExportRecordResp, error)
CheckIdCard(context.Context, *RegisterInfo) (*CheckIdCardResp, error) CheckIdCard(context.Context, *RegisterInfo) (*CheckIdCardResp, error)
ImportInfoByExcel(context.Context, *RegisterInfo) (*SaveRegisterRecordResp, error)
mustEmbedUnimplementedExhibitionServer() mustEmbedUnimplementedExhibitionServer()
} }
@ -121,6 +130,9 @@ func (UnimplementedExhibitionServer) ExportRegisterRecord(context.Context, *Expo
func (UnimplementedExhibitionServer) CheckIdCard(context.Context, *RegisterInfo) (*CheckIdCardResp, error) { func (UnimplementedExhibitionServer) CheckIdCard(context.Context, *RegisterInfo) (*CheckIdCardResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method CheckIdCard not implemented") return nil, status.Errorf(codes.Unimplemented, "method CheckIdCard not implemented")
} }
func (UnimplementedExhibitionServer) ImportInfoByExcel(context.Context, *RegisterInfo) (*SaveRegisterRecordResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method ImportInfoByExcel not implemented")
}
func (s *UnimplementedExhibitionServer) XXX_SetProxyImpl(impl protocol.Invoker) { func (s *UnimplementedExhibitionServer) XXX_SetProxyImpl(impl protocol.Invoker) {
s.proxyImpl = impl s.proxyImpl = impl
} }
@ -294,6 +306,35 @@ func _Exhibition_CheckIdCard_Handler(srv interface{}, ctx context.Context, dec f
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }
func _Exhibition_ImportInfoByExcel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
in := new(RegisterInfo)
if err := dec(in); err != nil {
return nil, err
}
base := srv.(dubbo3.Dubbo3GrpcService)
args := []interface{}{}
args = append(args, in)
md, _ := metadata.FromIncomingContext(ctx)
invAttachment := make(map[string]interface{}, len(md))
for k, v := range md {
invAttachment[k] = v
}
invo := invocation.NewRPCInvocation("ImportInfoByExcel", args, invAttachment)
if interceptor == nil {
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
return result, result.Error()
}
info := &grpc_go.UnaryServerInfo{
Server: srv,
FullMethod: ctx.Value("XXX_TRIPLE_GO_INTERFACE_NAME").(string),
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
return result, result.Error()
}
return interceptor(ctx, in, info, handler)
}
// Exhibition_ServiceDesc is the grpc_go.ServiceDesc for Exhibition service. // Exhibition_ServiceDesc is the grpc_go.ServiceDesc for Exhibition service.
// It's only intended for direct use with grpc_go.RegisterService, // It's only intended for direct use with grpc_go.RegisterService,
// and not to be introspected or modified (even as a copy) // and not to be introspected or modified (even as a copy)
@ -321,6 +362,10 @@ var Exhibition_ServiceDesc = grpc_go.ServiceDesc{
MethodName: "CheckIdCard", MethodName: "CheckIdCard",
Handler: _Exhibition_CheckIdCard_Handler, Handler: _Exhibition_CheckIdCard_Handler,
}, },
{
MethodName: "ImportInfoByExcel",
Handler: _Exhibition_ImportInfoByExcel_Handler,
},
}, },
Streams: []grpc_go.StreamDesc{}, Streams: []grpc_go.StreamDesc{},
Metadata: "pb/exhibition.proto", Metadata: "pb/exhibition.proto",

View File

@ -27,10 +27,10 @@ jwt:
key: "3Ei*^!a6^6$w^wgK" key: "3Ei*^!a6^6$w^wgK"
expire: 24 expire: 24
bos: bos:
AccessKeyId: "LTAI5tHfjSmWXHqfWgaL7Uo5" AccessKeyId: "LTAI5tLz1fSK53FQAEC9uNSb"
AccessKeySecret: "kOPctFZ3DHsbdSSym1fLyDK39hkzPI" AccessKeySecret: "oGB9chrQzQzITXR2IGv37Ji5WxZh4j"
BucketName: "erp-k8s-store" BucketName: "fontree-test"
Endpoint: "oss-cn-hangzhou-internal.aliyuncs.com" Endpoint: "oss-cn-hangzhou.aliyuncs.com"
BosBaseDir: "exhibition" BosBaseDir: "exhibition"
Host: "https://oss-cn-hangzhou.aliyuncs.com" Host: "https://oss-cn-hangzhou.aliyuncs.com"
CdnHost: "https://e-cdn.fontree.cn" CdnHost: "https://cdn-test.szjixun.cn"

View File

@ -6,6 +6,16 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io/ioutil"
"mime/multipart"
"net/url"
"os"
"path"
"path/filepath"
"strconv"
"strings"
"sync"
"github.com/disintegration/imaging" "github.com/disintegration/imaging"
"github.com/dubbogo/gost/log/logger" "github.com/dubbogo/gost/log/logger"
"github.com/exhibition-main/internal/config" "github.com/exhibition-main/internal/config"
@ -19,15 +29,6 @@ import (
uuid "github.com/satori/go.uuid" uuid "github.com/satori/go.uuid"
ffmpeg "github.com/u2takey/ffmpeg-go" ffmpeg "github.com/u2takey/ffmpeg-go"
"go.uber.org/zap" "go.uber.org/zap"
"io/ioutil"
"mime/multipart"
"net/url"
"os"
"path"
"path/filepath"
"strconv"
"strings"
"sync"
) )
var ( var (
@ -305,3 +306,21 @@ func BaiduCheckImage(imageByte []byte) (err error) {
} }
return nil return nil
} }
// 图片转url
func UploadFile(fileBytes []byte) (url string, err error) {
mask := "default"
source := "国展报名"
uuids := uuid.NewV4()
filePath := fmt.Sprintf("%s/%s/%s.png", mask, source, uuids)
var objectName string = fmt.Sprintf("%s/%s/%s", config.Data.Bos.BosBaseDir, config.Data.System.Mode, filePath)
BOSClient, _ := objstorage.NewOSS(config.Data.Bos.AccessKeyId, config.Data.Bos.AccessKeySecret, config.Data.Bos.Endpoint)
_, err = BOSClient.PutObjectFromBytes(config.Data.Bos.BucketName, objectName, fileBytes)
if err != nil {
logger.Errorf("UploadImg PutObjectFromBytes err", err)
return "", err
}
url = fmt.Sprintf("%s/%s", config.Data.Bos.CdnHost, objectName)
return
}

View File

@ -15,6 +15,7 @@ import (
"github.com/exhibition-main/internal/model" "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/service/common"
"github.com/exhibition-main/pkg/utils" "github.com/exhibition-main/pkg/utils"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding" "github.com/gin-gonic/gin/binding"
@ -285,6 +286,8 @@ func OcrBase64(c *gin.Context) {
response.ResponseQuickMsg(c, msg.Ok, "操作成功", res) response.ResponseQuickMsg(c, msg.Ok, "操作成功", res)
return return
} }
// 导入数据到数据库(一次性)
func ImportRecordByExcel(c *gin.Context) { func ImportRecordByExcel(c *gin.Context) {
file, err := c.FormFile("file") file, err := c.FormFile("file")
if err != nil { if err != nil {
@ -326,30 +329,19 @@ func ImportRecordByExcel(c *gin.Context) {
continue continue
} }
if len(row) < 12 { // 确保列数足够 if len(row) < 3 { // 确保列数足够
continue continue
} }
// artworkUrl := "" artworkUrl := ""
// if pics, err := excelFile.GetPictures(sheetName, fmt.Sprintf("K%d", i+1)); err == nil && len(pics) > 0 { if pics, err := excelFile.GetPictures(sheetName, fmt.Sprintf("K%d", i+1)); err == nil && len(pics) > 0 {
// tmpFile, err := ioutil.TempFile("", fmt.Sprintf("oss_upload_%d*.jpg", i)) if url, err := common.UploadFile(pics[0].File); err != nil {
// if err != nil { logger.Errorf("上传到服务器失败:%v", err)
// logger.Errorf("创建临时文件失败: %v", err) response.ResponseQuickMsg(c, msg.Fail, "上传到服务器失败:"+err.Error(), nil)
// response.ResponseQuickMsg(c, msg.Fail, "创建临时文件失败", nil) return
// return } else {
// } artworkUrl = url
// defer os.Remove(tmpFile.Name()) }
// if _, err := tmpFile.Write(pics[0].File); err != nil { }
// logger.Errorf("写入临时文件失败: %v", err)
// response.ResponseQuickMsg(c, msg.Fail, "写入临时文件失败", nil)
// return
// }
// //objectKey := fmt.Sprintf("artwork/%s/%d.jpg", time.Now().Format("20060102"), time.Now().UnixNano())
// if url, err := common.PutBos(tmpFile.Name(), "image", false); err == nil {
// artworkUrl = url
// } else {
// logger.Errorf("上传图片失败: %v", err)
// }
// }
record := &exhibition.RegisterInfo{ record := &exhibition.RegisterInfo{
PreliminaryRatingNo: row[0], PreliminaryRatingNo: row[0],
ReRatingNo: row[1], ReRatingNo: row[1],
@ -360,32 +352,27 @@ func ImportRecordByExcel(c *gin.Context) {
ArtistName: row[6], ArtistName: row[6],
PhoneNum: string(row[7]), PhoneNum: string(row[7]),
Province: string(row[8]), Province: string(row[8]),
IdCard: string(row[9]), IdCard: row[9],
//ArtworkFile: artworkUrl, ArtworkFile: artworkUrl,
Gender: GetGenderByIdCard(row[9]),
} }
record.Gender = GetGenderByIdCard(record.IdCard)
records = append(records, record) records = append(records, record)
} }
for k, v := range records {
for i, r := range records { fmt.Println(k, v)
recordListReq := exhibition.RecordListReq{
Keyword: r.ArtistName,
}
resp, err := GrpcExhibitionClientImpl.RegisterRecordList(context.Background(), &recordListReq)
if err != nil {
response.ResponseQuickMsg(c, msg.Fail, err.Error(), nil)
return
}
records[i].Uuid = resp.Data[i].Uuid
} }
for _, r := range records { for _, r := range records {
_, err := GrpcExhibitionClientImpl.SaveRegisterRecord(context.Background(), r) // registerInfo := &exhibition.RegisterInfo{
// ArtistName: r.ArtistName,
// ArtworkName: r.ArtworkName,
// }
_, err := GrpcExhibitionClientImpl.ImportInfoByExcel(context.Background(), r)
if err != nil { if err != nil {
response.ResponseQuickMsg(c, msg.Fail, err.Error(), nil) response.ResponseQuickMsg(c, msg.Fail, err.Error(), nil)
return return
} }
}
}
response.ResponseQuickMsg(c, msg.Ok, "ok", "") response.ResponseQuickMsg(c, msg.Ok, "ok", "")
return return
@ -395,6 +382,9 @@ func ImportRecordByExcel(c *gin.Context) {
// 参数idCard - 身份证号码字符串 // 参数idCard - 身份证号码字符串
// 返回值1-男2-女0-未知 // 返回值1-男2-女0-未知
func GetGenderByIdCard(idCard string) int32 { func GetGenderByIdCard(idCard string) int32 {
if idCard == "" {
return 0
}
if len(idCard) != 18 && len(idCard) != 15 { if len(idCard) != 18 && len(idCard) != 15 {
return 0 return 0
} }
@ -409,7 +399,6 @@ func GetGenderByIdCard(idCard string) int32 {
if err != nil { if err != nil {
return 0 return 0
} }
if genderNum%2 == 0 { if genderNum%2 == 0 {
return 2 // 女 return 2 // 女
} }