From dc5640ce7fcfc51ba83c6e40e7e35dcecd20488e Mon Sep 17 00:00:00 2001 From: sxy <3187870250@qq.com> Date: Wed, 12 Mar 2025 14:22:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=8EExcel=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E5=88=B0=E6=95=B0=E6=8D=AE=E5=BA=93=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/controller/register.go | 12 +++++ internal/dao/register.go | 9 ++++ internal/logic/register_logic.go | 65 +++++++++++++++++++++++++++ pb/exhibition.proto | 1 + pb/exhibition/exhibition.pb.go | 52 ++++++++++++--------- pb/exhibition/exhibition_triple.pb.go | 45 +++++++++++++++++++ 6 files changed, 162 insertions(+), 22 deletions(-) diff --git a/internal/controller/register.go b/internal/controller/register.go index 22af7e6..113e234 100644 --- a/internal/controller/register.go +++ b/internal/controller/register.go @@ -47,3 +47,15 @@ func (e *ExhibitionProvider) ExportRegisterRecord(_ context.Context, req *exhibi rep.Msg = msg.Success return rep, nil } +func (e *ExhibitionProvider) ImportInfoByExcel(_ context.Context, req *exhibition.RegisterInfo) (rep *exhibition.SaveRegisterRecordResp, err error) { + if info, err := e.registerLogic.GetRecordByName(req); err != nil { + return nil, err + } else { + req.Uuid = info.Uuid + } + if rep, err = e.registerLogic.UpdateRegisterRecord(req); err != nil { + return nil, err + } + rep.Msg = msg.Success + return rep, nil +} diff --git a/internal/dao/register.go b/internal/dao/register.go index aad4f05..b3f1f04 100644 --- a/internal/dao/register.go +++ b/internal/dao/register.go @@ -111,3 +111,12 @@ func AllRecord() (data []*model.RegisterRecord, err error) { } return } + +func GetRecordByName(in *exhibition.RegisterInfo) (record *model.RegisterRecord, err error) { + if err = app.ModuleClients.ExhibitionRegister.Model(&model.RegisterRecord{}).Where("artist_name=? AND artwork_name=?", in.ArtistName, in.ArtworkName).First(&record).Error; err != nil { + zap.L().Error("GetRecordByName err", zap.Error(err)) + err = errors.New(msg.ErrorSelect) + return + } + return +} diff --git a/internal/logic/register_logic.go b/internal/logic/register_logic.go index 77e0506..7bf05cc 100644 --- a/internal/logic/register_logic.go +++ b/internal/logic/register_logic.go @@ -214,3 +214,68 @@ func (r *Register) CheckByPhone(in *exhibition.RegisterInfo) (out *exhibition.Ch return out, nil } +func (r *Register) GetRecordByName(in *exhibition.RegisterInfo) (out *exhibition.RegisterInfo, err error) { + record, err := dao.GetRecordByName(in) + if err != nil { + return nil, err + } + if record == nil { + return nil, errors.New("未找到该记录") + } + data := &exhibition.RegisterInfo{ + Id: int32(record.ID), + Uuid: record.UUID, + } + return data, nil +} +func (r *Register) UpdateRegisterRecord(in *exhibition.RegisterInfo) (out *exhibition.SaveRegisterRecordResp, err error) { + out = &exhibition.SaveRegisterRecordResp{} + record := &model.RegisterRecord{ + ArtistName: in.ArtistName, + Gender: in.Gender, + PhoneNum: in.PhoneNum, + IdCard: in.IdCard, + Address: in.Address, + Address1: in.Address1, + IdCardPhoto: in.IdCardPhoto, + IdCardBackPhoto: in.IdCardBackPhoto, + ArtistPhoto: in.ArtistPhoto, + ArtworkFile: in.ArtworkFile, + ArtworkName: in.ArtworkName, + Province: in.Province, + ArtworkType: in.ArtworkType, + ArtworkSize: in.ArtworkSize, + PreliminaryRatingNo: in.PreliminaryRatingNo, + ReRatingNo: in.ReRatingNo, + UUID: in.Uuid, + } + registerRecord, err1 := dao.UpdateRegisterRecord(record) + if err1 != nil { + return nil, err1 + } + + data := &exhibition.RegisterInfo{ + Id: int32(registerRecord.ID), + Uuid: registerRecord.UUID, + ArtistName: registerRecord.ArtistName, + Gender: registerRecord.Gender, + PhoneNum: registerRecord.PhoneNum, + IdCard: registerRecord.IdCard, + Address: registerRecord.Address, + Address1: registerRecord.Address1, + IdCardPhoto: registerRecord.IdCardPhoto, + IdCardBackPhoto: registerRecord.IdCardBackPhoto, + ArtistPhoto: registerRecord.ArtistPhoto, + ArtworkFile: registerRecord.ArtworkFile, + ArtworkName: registerRecord.ArtworkName, + Province: registerRecord.Province, + ArtworkType: registerRecord.ArtworkType, + ArtworkSize: registerRecord.ArtworkSize, + PreliminaryRatingNo: registerRecord.PreliminaryRatingNo, + ReRatingNo: registerRecord.ReRatingNo, + CreatedAt: registerRecord.CreatedAt.Format("2006-01-02 15:04:05"), + UpdatedAt: registerRecord.UpdatedAt.Format("2006-01-02 15:04:05"), + } + out.Data = data + return out, nil +} diff --git a/pb/exhibition.proto b/pb/exhibition.proto index 5eb7a6f..5534eff 100644 --- a/pb/exhibition.proto +++ b/pb/exhibition.proto @@ -12,6 +12,7 @@ service Exhibition { rpc RegisterRecordList(RecordListReq) returns (RecordListResp); rpc ExportRegisterRecord(ExportRecordReq) returns (ExportRecordResp); rpc CheckIdCard(RegisterInfo) returns (CheckIdCardResp); + rpc ImportInfoByExcel(RegisterInfo) returns(SaveRegisterRecordResp); } message RegisterInfo{ diff --git a/pb/exhibition/exhibition.pb.go b/pb/exhibition/exhibition.pb.go index 8c8bd49..5ed738d 100644 --- a/pb/exhibition/exhibition.pb.go +++ b/pb/exhibition/exhibition.pb.go @@ -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, 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, 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, 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, @@ -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, 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, - 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, + 0x52, 0x65, 0x73, 0x70, 0x12, 0x51, 0x0a, 0x11, 0x49, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x49, 0x6e, + 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 ( @@ -980,25 +986,27 @@ var file_pb_exhibition_proto_goTypes = []any{ (*ExportRecordResp)(nil), // 8: exhibition.ExportRecordResp } var file_pb_exhibition_proto_depIdxs = []int32{ - 0, // 0: exhibition.SaveRegisterRecordResp.data:type_name -> exhibition.RegisterInfo - 0, // 1: exhibition.CheckPhoneResp.data:type_name -> exhibition.RegisterInfo - 0, // 2: exhibition.RecordListResp.data:type_name -> exhibition.RegisterInfo - 7, // 3: exhibition.ExportRecordResp.data:type_name -> exhibition.ExportInfo - 0, // 4: exhibition.Exhibition.CheckPhone:input_type -> exhibition.RegisterInfo - 0, // 5: exhibition.Exhibition.SaveRegisterRecord:input_type -> exhibition.RegisterInfo - 4, // 6: exhibition.Exhibition.RegisterRecordList:input_type -> exhibition.RecordListReq - 6, // 7: exhibition.Exhibition.ExportRegisterRecord:input_type -> exhibition.ExportRecordReq - 0, // 8: exhibition.Exhibition.CheckIdCard:input_type -> exhibition.RegisterInfo - 2, // 9: exhibition.Exhibition.CheckPhone:output_type -> exhibition.CheckPhoneResp - 1, // 10: exhibition.Exhibition.SaveRegisterRecord:output_type -> exhibition.SaveRegisterRecordResp - 5, // 11: exhibition.Exhibition.RegisterRecordList:output_type -> exhibition.RecordListResp - 8, // 12: exhibition.Exhibition.ExportRegisterRecord:output_type -> exhibition.ExportRecordResp - 3, // 13: exhibition.Exhibition.CheckIdCard:output_type -> exhibition.CheckIdCardResp - 9, // [9:14] is the sub-list for method output_type - 4, // [4:9] is the sub-list for method input_type - 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 + 0, // 0: exhibition.SaveRegisterRecordResp.data:type_name -> exhibition.RegisterInfo + 0, // 1: exhibition.CheckPhoneResp.data:type_name -> exhibition.RegisterInfo + 0, // 2: exhibition.RecordListResp.data:type_name -> exhibition.RegisterInfo + 7, // 3: exhibition.ExportRecordResp.data:type_name -> exhibition.ExportInfo + 0, // 4: exhibition.Exhibition.CheckPhone:input_type -> exhibition.RegisterInfo + 0, // 5: exhibition.Exhibition.SaveRegisterRecord:input_type -> exhibition.RegisterInfo + 4, // 6: exhibition.Exhibition.RegisterRecordList:input_type -> exhibition.RecordListReq + 6, // 7: exhibition.Exhibition.ExportRegisterRecord:input_type -> exhibition.ExportRecordReq + 0, // 8: exhibition.Exhibition.CheckIdCard:input_type -> exhibition.RegisterInfo + 0, // 9: exhibition.Exhibition.ImportInfoByExcel:input_type -> exhibition.RegisterInfo + 2, // 10: exhibition.Exhibition.CheckPhone:output_type -> exhibition.CheckPhoneResp + 1, // 11: exhibition.Exhibition.SaveRegisterRecord:output_type -> exhibition.SaveRegisterRecordResp + 5, // 12: exhibition.Exhibition.RegisterRecordList:output_type -> exhibition.RecordListResp + 8, // 13: exhibition.Exhibition.ExportRegisterRecord:output_type -> exhibition.ExportRecordResp + 3, // 14: exhibition.Exhibition.CheckIdCard:output_type -> exhibition.CheckIdCardResp + 1, // 15: exhibition.Exhibition.ImportInfoByExcel:output_type -> exhibition.SaveRegisterRecordResp + 10, // [10:16] is the sub-list for method output_type + 4, // [4:10] is the sub-list for method input_type + 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() } diff --git a/pb/exhibition/exhibition_triple.pb.go b/pb/exhibition/exhibition_triple.pb.go index 77eb822..c937be8 100644 --- a/pb/exhibition/exhibition_triple.pb.go +++ b/pb/exhibition/exhibition_triple.pb.go @@ -33,6 +33,7 @@ type ExhibitionClient interface { 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) 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 { @@ -45,6 +46,7 @@ type ExhibitionClientImpl struct { RegisterRecordList func(ctx context.Context, in *RecordListReq) (*RecordListResp, error) ExportRegisterRecord func(ctx context.Context, in *ExportRecordReq) (*ExportRecordResp, 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 { @@ -89,6 +91,12 @@ func (c *exhibitionClient) CheckIdCard(ctx context.Context, in *RegisterInfo, op 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. // All implementations must embed UnimplementedExhibitionServer // for forward compatibility @@ -98,6 +106,7 @@ type ExhibitionServer interface { RegisterRecordList(context.Context, *RecordListReq) (*RecordListResp, error) ExportRegisterRecord(context.Context, *ExportRecordReq) (*ExportRecordResp, error) CheckIdCard(context.Context, *RegisterInfo) (*CheckIdCardResp, error) + ImportInfoByExcel(context.Context, *RegisterInfo) (*SaveRegisterRecordResp, error) mustEmbedUnimplementedExhibitionServer() } @@ -121,6 +130,9 @@ func (UnimplementedExhibitionServer) ExportRegisterRecord(context.Context, *Expo func (UnimplementedExhibitionServer) CheckIdCard(context.Context, *RegisterInfo) (*CheckIdCardResp, error) { 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) { s.proxyImpl = impl } @@ -294,6 +306,35 @@ func _Exhibition_CheckIdCard_Handler(srv interface{}, ctx context.Context, dec f 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. // It's only intended for direct use with grpc_go.RegisterService, // and not to be introspected or modified (even as a copy) @@ -321,6 +362,10 @@ var Exhibition_ServiceDesc = grpc_go.ServiceDesc{ MethodName: "CheckIdCard", Handler: _Exhibition_CheckIdCard_Handler, }, + { + MethodName: "ImportInfoByExcel", + Handler: _Exhibition_ImportInfoByExcel_Handler, + }, }, Streams: []grpc_go.StreamDesc{}, Metadata: "pb/exhibition.proto",