From 8d7b543dc27c8faa8b95fba35730d88d8d0c0d7c Mon Sep 17 00:00:00 2001 From: zzw <1464003642@qq.com> Date: Mon, 19 Oct 2026 17:30:45 +0800 Subject: [PATCH] feat: user info --- deploy/apisix/lua/auth.lua | 10 +- rpc/analysis/analysis.pb | Bin 16311 -> 17322 bytes rpc/analysis/analysis.proto | 57 ++ rpc/analysis/pb/analysis.pb.go | 448 +++++++++++++-- rpc/analysis/pb/analysis_grpc.pb.go | 190 +++++++ rpc/chore/chore.proto | 4 +- rpc/equipment/equipment.proto | 2 +- rpc/sale/sale.proto | 3 - rpc/store/pb/store.pb.go | 23 +- rpc/store/store.pb | Bin 21772 -> 21829 bytes rpc/store/store.proto | 2 + rpc/user/pb/user.pb.go | 513 +++++++++++++++--- rpc/user/pb/user_grpc.pb.go | 76 +++ rpc/user/user.pb | Bin 18341 -> 19142 bytes rpc/user/user.proto | 188 ++++--- .../client/analysisstore/analysisStore.go | 35 ++ services/analysis/internal/dao/remark.go | 31 ++ services/analysis/internal/dao/store.go | 43 ++ .../logic/analysisstore/storeDetailLogic.go | 38 ++ .../logic/analysisstore/storeInfoLogic.go | 41 ++ .../logic/analysisstore/storeUserInfoLogic.go | 84 +++ .../logic/analysisstore/storeUserListLogic.go | 343 ++++++++++++ .../analysisstore/storeUserUpdateLogic.go | 155 ++++++ .../internal/logic/analysisstore/storeView.go | 102 ++++ services/analysis/internal/model/remark.go | 23 + .../analysis/internal/model/user_image_log.go | 16 + .../analysis/internal/model/user_image_tag.go | 23 + .../analysisstore/analysisStoreServer.go | 25 + services/analysis/validator/user.go | 54 ++ .../internal/logic/apiLowerSaleItemsLogic.go | 2 +- .../sale/internal/logic/apiSaleAddLogic.go | 4 +- services/store/internal/dao/store.go | 1 + .../store/internal/logic/getInfoByIdLogic.go | 14 + .../store/internal/logic/getInfoByIdsLogic.go | 14 + .../logic/webCheckPayPasswordLogic.go | 4 +- .../internal/logic/webDepositCreateLogic.go | 4 +- .../internal/logic/webDepositItemsLogic.go | 4 +- services/store/internal/logic/webInfoLogic.go | 4 +- .../internal/logic/webLowerStoreItemsLogic.go | 4 +- .../store/internal/logic/webPayMoneyLogic.go | 4 +- .../internal/logic/webSetPayPasswordLogic.go | 4 +- .../store/internal/logic/webStoreAddLogic.go | 6 +- services/store/internal/server/storeServer.go | 2 +- services/store/storeclient/store.go | 2 +- services/user/internal/dao/session.go | 11 +- services/user/internal/dao/user_detail.go | 23 + services/user/internal/logic/authHelper.go | 6 + services/user/internal/logic/bizUser.go | 5 +- services/user/internal/logic/infoLogic.go | 13 +- .../internal/logic/internalCreateLogic.go | 4 + .../internal/logic/internalUsersByBizLogic.go | 139 +++++ services/user/internal/logic/updateLogic.go | 144 +++++ services/user/internal/logic/userDetail.go | 54 ++ services/user/internal/model/user_detail.go | 23 + services/user/internal/server/userServer.go | 10 + services/user/userClient/user.go | 16 + services/user/validator/user.go | 37 ++ 57 files changed, 2836 insertions(+), 251 deletions(-) create mode 100644 services/analysis/internal/dao/remark.go create mode 100644 services/analysis/internal/dao/store.go create mode 100644 services/analysis/internal/logic/analysisstore/storeDetailLogic.go create mode 100644 services/analysis/internal/logic/analysisstore/storeInfoLogic.go create mode 100644 services/analysis/internal/logic/analysisstore/storeUserInfoLogic.go create mode 100644 services/analysis/internal/logic/analysisstore/storeUserListLogic.go create mode 100644 services/analysis/internal/logic/analysisstore/storeUserUpdateLogic.go create mode 100644 services/analysis/internal/logic/analysisstore/storeView.go create mode 100644 services/analysis/internal/model/remark.go create mode 100644 services/analysis/internal/model/user_image_log.go create mode 100644 services/analysis/internal/model/user_image_tag.go create mode 100644 services/user/internal/dao/user_detail.go create mode 100644 services/user/internal/logic/internalUsersByBizLogic.go create mode 100644 services/user/internal/logic/updateLogic.go create mode 100644 services/user/internal/logic/userDetail.go create mode 100644 services/user/internal/model/user_detail.go diff --git a/deploy/apisix/lua/auth.lua b/deploy/apisix/lua/auth.lua index 307b0f8..f188adc 100644 --- a/deploy/apisix/lua/auth.lua +++ b/deploy/apisix/lua/auth.lua @@ -11,9 +11,9 @@ function _M.access(conf, ctx) core.log.info("REQUEST_DEBUG: uri = "..request_uri) local white_list = { - ["/api/v3/sms/send"] = true, - ["/api/v3/login"] = true, - ["/api/v3/version"] = true, + ["/api/v3/chore/sms/send"] = true, + ["/api/v3/user/login"] = true, + ["/api/v3/equipment/version"] = true, ["/admin/v3/login"] = true, ["/admin/v3/refresh"] = true, @@ -30,6 +30,7 @@ function _M.access(conf, ctx) ["/api/v2/analysis/agreement/info"] = true, ["/api/v2/analysis/switch"] = true, ["/api/v2/analysis/user/delete"] = true, + ["/api/v2/analysis/store/info"] = true, } local user_key = core.request.header(ctx, "authorization") @@ -76,7 +77,8 @@ function _M.access(conf, ctx) end local res, err = red:get(redis_key) - core.log.info("AUTH_DEBUG host=", redis_host, + + core.log.error("AUTH_DEBUG host=", redis_host, " port=", redis_port, " password=", redis_password, " db=", redis_db, diff --git a/rpc/analysis/analysis.pb b/rpc/analysis/analysis.pb index d86410dd3c1a5ae02149cf156f7738b7c562d870..799563b956de89c623217b2c35726f10548acb0d 100644 GIT binary patch delta 847 zcmZ`%L2DCH5cX}dyWNS_@DA-$i-rZESgg=mC@$6sZsP6+8xdB# z*!w&B4?GDy^bhzC{0qUG;LV%(=52P3rQT-dn{Q^mnK{ote0< z9%Q3L^y8PKK)j~QV9AJ)7Fn+a+VY#QZ18=NaXHi({#OD`6FN*q@IL7%=itaekfv{SG zgKj_4Kt1Niq7c)&5*Y845PGYUW7PCWsRzM3u=GME*-^x&g|40zRFTtMXUs+0W_2jK z>w+C(tF8xbSZu1>052>H`5Ox-C@=TFxqS`|RQPz39nDXbO~-gDz4^0eyM4#{Wvfq} znNLITs%M}pn>^;jX)4prDyZJKnVNN4_oaT9N8}zA&{%j6$}Vth!z eX?Fy$ySMS-+e}$^{g(RCS@ldQl&{|Hwf_J`@%#h; delta 32 ocmZ40&bYmPgOe%KXOYb=rXQF#i&&+yF+E|NT analysis.InternalCreateUserReq @@ -962,31 +1295,41 @@ var file_analysis_analysis_proto_depIdxs = []int32{ 5, // 4: analysis.AnalysisUser.FaceBind:input_type -> analysis.FaceBindReq 3, // 5: analysis.AnalysisUser.UserImprove:input_type -> analysis.UserImproveReq 7, // 6: analysis.AnalysisUser.UserDelete:input_type -> analysis.UserDeleteReq - 11, // 7: analysis.AnalysisUser.UserAuth:input_type -> analysis.UserAuthReq - 12, // 8: analysis.AnalysisUser.UserAuthList:input_type -> analysis.UserAuthListReq - 13, // 9: analysis.AnalysisUser.UserAuthDelete:input_type -> analysis.UserAuthDeleteReq - 14, // 10: analysis.AnalysisUser.UserAuthUpdate:input_type -> analysis.UserAuthUpdateReq - 15, // 11: analysis.AnalysisUser.DeviceBind:input_type -> analysis.DeviceBindReq - 16, // 12: analysis.AnalysisUser.DeviceInfo:input_type -> analysis.DeviceInfoReq + 16, // 7: analysis.AnalysisUser.UserAuth:input_type -> analysis.UserAuthReq + 17, // 8: analysis.AnalysisUser.UserAuthList:input_type -> analysis.UserAuthListReq + 18, // 9: analysis.AnalysisUser.UserAuthDelete:input_type -> analysis.UserAuthDeleteReq + 19, // 10: analysis.AnalysisUser.UserAuthUpdate:input_type -> analysis.UserAuthUpdateReq + 20, // 11: analysis.AnalysisUser.DeviceBind:input_type -> analysis.DeviceBindReq + 21, // 12: analysis.AnalysisUser.DeviceInfo:input_type -> analysis.DeviceInfoReq 9, // 13: analysis.AnalysisStore.StoreAuth:input_type -> analysis.StoreAuthReq 10, // 14: analysis.AnalysisStore.StoreAuthQrcode:input_type -> analysis.StoreAuthQrcodeReq - 2, // 15: analysis.Analysis.InternalCreateUser:output_type -> analysis.InternalCreateUserData - 0, // 16: analysis.Analysis.AgreementInfo:output_type -> analysis.Response - 0, // 17: analysis.Analysis.Switch:output_type -> analysis.Response - 0, // 18: analysis.AnalysisUser.UserRegister:output_type -> analysis.Response - 0, // 19: analysis.AnalysisUser.FaceBind:output_type -> analysis.Response - 0, // 20: analysis.AnalysisUser.UserImprove:output_type -> analysis.Response - 0, // 21: analysis.AnalysisUser.UserDelete:output_type -> analysis.Response - 0, // 22: analysis.AnalysisUser.UserAuth:output_type -> analysis.Response - 0, // 23: analysis.AnalysisUser.UserAuthList:output_type -> analysis.Response - 0, // 24: analysis.AnalysisUser.UserAuthDelete:output_type -> analysis.Response - 0, // 25: analysis.AnalysisUser.UserAuthUpdate:output_type -> analysis.Response - 0, // 26: analysis.AnalysisUser.DeviceBind:output_type -> analysis.Response - 0, // 27: analysis.AnalysisUser.DeviceInfo:output_type -> analysis.Response - 0, // 28: analysis.AnalysisStore.StoreAuth:output_type -> analysis.Response - 0, // 29: analysis.AnalysisStore.StoreAuthQrcode:output_type -> analysis.Response - 15, // [15:30] is the sub-list for method output_type - 0, // [0:15] is the sub-list for method input_type + 11, // 15: analysis.AnalysisStore.StoreInfo:input_type -> analysis.StoreInfoReq + 12, // 16: analysis.AnalysisStore.StoreDetail:input_type -> analysis.StoreDetailReq + 13, // 17: analysis.AnalysisStore.StoreUserList:input_type -> analysis.StoreUserListReq + 14, // 18: analysis.AnalysisStore.StoreUserUpdate:input_type -> analysis.StoreUserUpdateReq + 15, // 19: analysis.AnalysisStore.StoreUserInfo:input_type -> analysis.StoreUserInfoReq + 2, // 20: analysis.Analysis.InternalCreateUser:output_type -> analysis.InternalCreateUserData + 0, // 21: analysis.Analysis.AgreementInfo:output_type -> analysis.Response + 0, // 22: analysis.Analysis.Switch:output_type -> analysis.Response + 0, // 23: analysis.AnalysisUser.UserRegister:output_type -> analysis.Response + 0, // 24: analysis.AnalysisUser.FaceBind:output_type -> analysis.Response + 0, // 25: analysis.AnalysisUser.UserImprove:output_type -> analysis.Response + 0, // 26: analysis.AnalysisUser.UserDelete:output_type -> analysis.Response + 0, // 27: analysis.AnalysisUser.UserAuth:output_type -> analysis.Response + 0, // 28: analysis.AnalysisUser.UserAuthList:output_type -> analysis.Response + 0, // 29: analysis.AnalysisUser.UserAuthDelete:output_type -> analysis.Response + 0, // 30: analysis.AnalysisUser.UserAuthUpdate:output_type -> analysis.Response + 0, // 31: analysis.AnalysisUser.DeviceBind:output_type -> analysis.Response + 0, // 32: analysis.AnalysisUser.DeviceInfo:output_type -> analysis.Response + 0, // 33: analysis.AnalysisStore.StoreAuth:output_type -> analysis.Response + 0, // 34: analysis.AnalysisStore.StoreAuthQrcode:output_type -> analysis.Response + 0, // 35: analysis.AnalysisStore.StoreInfo:output_type -> analysis.Response + 0, // 36: analysis.AnalysisStore.StoreDetail:output_type -> analysis.Response + 0, // 37: analysis.AnalysisStore.StoreUserList:output_type -> analysis.Response + 0, // 38: analysis.AnalysisStore.StoreUserUpdate:output_type -> analysis.Response + 0, // 39: analysis.AnalysisStore.StoreUserInfo:output_type -> analysis.Response + 20, // [20:40] is the sub-list for method output_type + 0, // [0:20] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name 0, // [0:0] is the sub-list for extension extendee 0, // [0:0] is the sub-list for field type_name @@ -997,13 +1340,14 @@ func file_analysis_analysis_proto_init() { if File_analysis_analysis_proto != nil { return } + file_analysis_analysis_proto_msgTypes[14].OneofWrappers = []any{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_analysis_analysis_proto_rawDesc), len(file_analysis_analysis_proto_rawDesc)), NumEnums: 0, - NumMessages: 17, + NumMessages: 22, NumExtensions: 0, NumServices: 4, }, diff --git a/rpc/analysis/pb/analysis_grpc.pb.go b/rpc/analysis/pb/analysis_grpc.pb.go index 7fdea95..7b5f809 100644 --- a/rpc/analysis/pb/analysis_grpc.pb.go +++ b/rpc/analysis/pb/analysis_grpc.pb.go @@ -643,6 +643,11 @@ var AnalysisUser_ServiceDesc = grpc.ServiceDesc{ const ( AnalysisStore_StoreAuth_FullMethodName = "/analysis.AnalysisStore/StoreAuth" AnalysisStore_StoreAuthQrcode_FullMethodName = "/analysis.AnalysisStore/StoreAuthQrcode" + AnalysisStore_StoreInfo_FullMethodName = "/analysis.AnalysisStore/StoreInfo" + AnalysisStore_StoreDetail_FullMethodName = "/analysis.AnalysisStore/StoreDetail" + AnalysisStore_StoreUserList_FullMethodName = "/analysis.AnalysisStore/StoreUserList" + AnalysisStore_StoreUserUpdate_FullMethodName = "/analysis.AnalysisStore/StoreUserUpdate" + AnalysisStore_StoreUserInfo_FullMethodName = "/analysis.AnalysisStore/StoreUserInfo" ) // AnalysisStoreClient is the client API for AnalysisStore service. @@ -651,6 +656,11 @@ const ( type AnalysisStoreClient interface { StoreAuth(ctx context.Context, in *StoreAuthReq, opts ...grpc.CallOption) (*Response, error) StoreAuthQrcode(ctx context.Context, in *StoreAuthQrcodeReq, opts ...grpc.CallOption) (*Response, error) + StoreInfo(ctx context.Context, in *StoreInfoReq, opts ...grpc.CallOption) (*Response, error) + StoreDetail(ctx context.Context, in *StoreDetailReq, opts ...grpc.CallOption) (*Response, error) + StoreUserList(ctx context.Context, in *StoreUserListReq, opts ...grpc.CallOption) (*Response, error) + StoreUserUpdate(ctx context.Context, in *StoreUserUpdateReq, opts ...grpc.CallOption) (*Response, error) + StoreUserInfo(ctx context.Context, in *StoreUserInfoReq, opts ...grpc.CallOption) (*Response, error) } type analysisStoreClient struct { @@ -681,12 +691,67 @@ func (c *analysisStoreClient) StoreAuthQrcode(ctx context.Context, in *StoreAuth return out, nil } +func (c *analysisStoreClient) StoreInfo(ctx context.Context, in *StoreInfoReq, opts ...grpc.CallOption) (*Response, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Response) + err := c.cc.Invoke(ctx, AnalysisStore_StoreInfo_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *analysisStoreClient) StoreDetail(ctx context.Context, in *StoreDetailReq, opts ...grpc.CallOption) (*Response, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Response) + err := c.cc.Invoke(ctx, AnalysisStore_StoreDetail_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *analysisStoreClient) StoreUserList(ctx context.Context, in *StoreUserListReq, opts ...grpc.CallOption) (*Response, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Response) + err := c.cc.Invoke(ctx, AnalysisStore_StoreUserList_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *analysisStoreClient) StoreUserUpdate(ctx context.Context, in *StoreUserUpdateReq, opts ...grpc.CallOption) (*Response, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Response) + err := c.cc.Invoke(ctx, AnalysisStore_StoreUserUpdate_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *analysisStoreClient) StoreUserInfo(ctx context.Context, in *StoreUserInfoReq, opts ...grpc.CallOption) (*Response, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Response) + err := c.cc.Invoke(ctx, AnalysisStore_StoreUserInfo_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + // AnalysisStoreServer is the server API for AnalysisStore service. // All implementations must embed UnimplementedAnalysisStoreServer // for forward compatibility. type AnalysisStoreServer interface { StoreAuth(context.Context, *StoreAuthReq) (*Response, error) StoreAuthQrcode(context.Context, *StoreAuthQrcodeReq) (*Response, error) + StoreInfo(context.Context, *StoreInfoReq) (*Response, error) + StoreDetail(context.Context, *StoreDetailReq) (*Response, error) + StoreUserList(context.Context, *StoreUserListReq) (*Response, error) + StoreUserUpdate(context.Context, *StoreUserUpdateReq) (*Response, error) + StoreUserInfo(context.Context, *StoreUserInfoReq) (*Response, error) mustEmbedUnimplementedAnalysisStoreServer() } @@ -703,6 +768,21 @@ func (UnimplementedAnalysisStoreServer) StoreAuth(context.Context, *StoreAuthReq func (UnimplementedAnalysisStoreServer) StoreAuthQrcode(context.Context, *StoreAuthQrcodeReq) (*Response, error) { return nil, status.Error(codes.Unimplemented, "method StoreAuthQrcode not implemented") } +func (UnimplementedAnalysisStoreServer) StoreInfo(context.Context, *StoreInfoReq) (*Response, error) { + return nil, status.Error(codes.Unimplemented, "method StoreInfo not implemented") +} +func (UnimplementedAnalysisStoreServer) StoreDetail(context.Context, *StoreDetailReq) (*Response, error) { + return nil, status.Error(codes.Unimplemented, "method StoreDetail not implemented") +} +func (UnimplementedAnalysisStoreServer) StoreUserList(context.Context, *StoreUserListReq) (*Response, error) { + return nil, status.Error(codes.Unimplemented, "method StoreUserList not implemented") +} +func (UnimplementedAnalysisStoreServer) StoreUserUpdate(context.Context, *StoreUserUpdateReq) (*Response, error) { + return nil, status.Error(codes.Unimplemented, "method StoreUserUpdate not implemented") +} +func (UnimplementedAnalysisStoreServer) StoreUserInfo(context.Context, *StoreUserInfoReq) (*Response, error) { + return nil, status.Error(codes.Unimplemented, "method StoreUserInfo not implemented") +} func (UnimplementedAnalysisStoreServer) mustEmbedUnimplementedAnalysisStoreServer() {} func (UnimplementedAnalysisStoreServer) testEmbeddedByValue() {} @@ -760,6 +840,96 @@ func _AnalysisStore_StoreAuthQrcode_Handler(srv interface{}, ctx context.Context return interceptor(ctx, in, info, handler) } +func _AnalysisStore_StoreInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(StoreInfoReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AnalysisStoreServer).StoreInfo(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: AnalysisStore_StoreInfo_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AnalysisStoreServer).StoreInfo(ctx, req.(*StoreInfoReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _AnalysisStore_StoreDetail_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(StoreDetailReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AnalysisStoreServer).StoreDetail(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: AnalysisStore_StoreDetail_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AnalysisStoreServer).StoreDetail(ctx, req.(*StoreDetailReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _AnalysisStore_StoreUserList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(StoreUserListReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AnalysisStoreServer).StoreUserList(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: AnalysisStore_StoreUserList_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AnalysisStoreServer).StoreUserList(ctx, req.(*StoreUserListReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _AnalysisStore_StoreUserUpdate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(StoreUserUpdateReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AnalysisStoreServer).StoreUserUpdate(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: AnalysisStore_StoreUserUpdate_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AnalysisStoreServer).StoreUserUpdate(ctx, req.(*StoreUserUpdateReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _AnalysisStore_StoreUserInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(StoreUserInfoReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AnalysisStoreServer).StoreUserInfo(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: AnalysisStore_StoreUserInfo_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AnalysisStoreServer).StoreUserInfo(ctx, req.(*StoreUserInfoReq)) + } + return interceptor(ctx, in, info, handler) +} + // AnalysisStore_ServiceDesc is the grpc.ServiceDesc for AnalysisStore service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -775,6 +945,26 @@ var AnalysisStore_ServiceDesc = grpc.ServiceDesc{ MethodName: "StoreAuthQrcode", Handler: _AnalysisStore_StoreAuthQrcode_Handler, }, + { + MethodName: "StoreInfo", + Handler: _AnalysisStore_StoreInfo_Handler, + }, + { + MethodName: "StoreDetail", + Handler: _AnalysisStore_StoreDetail_Handler, + }, + { + MethodName: "StoreUserList", + Handler: _AnalysisStore_StoreUserList_Handler, + }, + { + MethodName: "StoreUserUpdate", + Handler: _AnalysisStore_StoreUserUpdate_Handler, + }, + { + MethodName: "StoreUserInfo", + Handler: _AnalysisStore_StoreUserInfo_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "analysis/analysis.proto", diff --git a/rpc/chore/chore.proto b/rpc/chore/chore.proto index 99152ca..80b8e34 100644 --- a/rpc/chore/chore.proto +++ b/rpc/chore/chore.proto @@ -37,7 +37,7 @@ service Chore { } rpc SendSms(SendSmsReq) returns (Response) { option (google.api.http) = { - post: "/api/v3/sms/send" + post: "/api/v3/chore/sms/send" body: "*" }; } @@ -89,7 +89,7 @@ service Chore { } rpc Document(DocumentReq) returns (Response) { option (google.api.http) = { - get: "/api/v3/document" + get: "/api/v3/chore/document" body: "*" }; } diff --git a/rpc/equipment/equipment.proto b/rpc/equipment/equipment.proto index d32beac..426a85a 100644 --- a/rpc/equipment/equipment.proto +++ b/rpc/equipment/equipment.proto @@ -331,7 +331,7 @@ service Equipment { }; rpc ApiVersion(ApiVersionRequest) returns(Response){ option (google.api.http) = { - get: "/api/v3/version" + get: "/api/v3/equipment/version" body: "*" }; }; diff --git a/rpc/sale/sale.proto b/rpc/sale/sale.proto index a26f588..02725fb 100644 --- a/rpc/sale/sale.proto +++ b/rpc/sale/sale.proto @@ -83,11 +83,8 @@ service Sale { }; } - // 销售详情 rpc InfoInternal(InfoReq) returns (InfoData); - // 按 user_id 查销售详情(内部) rpc InfoByUserId(InfoByUserIdReq) returns (InfoData); - // ids 批量查销售 rpc NamesByIds(NamesByIdsReq) returns (NamesByIdsData); } diff --git a/rpc/store/pb/store.pb.go b/rpc/store/pb/store.pb.go index 05282b2..6ed1cd0 100644 --- a/rpc/store/pb/store.pb.go +++ b/rpc/store/pb/store.pb.go @@ -859,6 +859,8 @@ type InfoResponse struct { CountyName string `protobuf:"bytes,29,opt,name=county_name,json=countyName,proto3" json:"county_name,omitempty"` BuyAmount float64 `protobuf:"fixed64,30,opt,name=buy_amount,json=buyAmount,proto3" json:"buy_amount,omitempty"` ResidualNumber int32 `protobuf:"varint,31,opt,name=residual_number,json=residualNumber,proto3" json:"residual_number,omitempty"` + Status int32 `protobuf:"varint,32,opt,name=status,proto3" json:"status,omitempty"` + CreateTime string `protobuf:"bytes,33,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -1110,6 +1112,20 @@ func (x *InfoResponse) GetResidualNumber() int32 { return 0 } +func (x *InfoResponse) GetStatus() int32 { + if x != nil { + return x.Status + } + return 0 +} + +func (x *InfoResponse) GetCreateTime() string { + if x != nil { + return x.CreateTime + } + return "" +} + type ItemsResponse struct { state protoimpl.MessageState `protogen:"open.v1"` Items []*InfoResponse `protobuf:"bytes,1,rep,name=items,proto3" json:"items,omitempty"` @@ -2331,7 +2347,7 @@ const file_store_store_proto_rawDesc = "" + "\tcity_name\x18\x1e \x01(\tR\bcityName\x12\x16\n" + "\x06county\x18\x1f \x01(\x03R\x06county\x12\x1f\n" + "\vcounty_name\x18 \x01(\tR\n" + - "countyName\"\xa7\a\n" + + "countyName\"\xe0\a\n" + "\fInfoResponse\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x1f\n" + "\vuser_mobile\x18\x02 \x01(\tR\n" + @@ -2368,7 +2384,10 @@ const file_store_store_proto_rawDesc = "" + "countyName\x12\x1d\n" + "\n" + "buy_amount\x18\x1e \x01(\x01R\tbuyAmount\x12'\n" + - "\x0fresidual_number\x18\x1f \x01(\x05R\x0eresidualNumber\":\n" + + "\x0fresidual_number\x18\x1f \x01(\x05R\x0eresidualNumber\x12\x16\n" + + "\x06status\x18 \x01(\x05R\x06status\x12\x1f\n" + + "\vcreate_time\x18! \x01(\tR\n" + + "createTime\":\n" + "\rItemsResponse\x12)\n" + "\x05items\x18\x01 \x03(\v2\x13.store.InfoResponseR\x05items\"8\n" + "\rToSaleRequest\x12\x0e\n" + diff --git a/rpc/store/store.pb b/rpc/store/store.pb index 9bc27378b270177d2d3ec5872858901cedf2bf78..58c728a66eb2a7319699e0fd08304b71501fe833 100644 GIT binary patch delta 87 zcmeBK#dvfT;|3>FrbdU&E~e2Oj1M+1uwB7yDI~_lR$P);Qd%sbpuniX8U*DD$#Zch f7o{eaq{f$I=B7$00wpFrW5v?T}-1n7?*EeV7r2ObED%CVF0i=3zh%? diff --git a/rpc/store/store.proto b/rpc/store/store.proto index 62187fd..f573eea 100644 --- a/rpc/store/store.proto +++ b/rpc/store/store.proto @@ -125,6 +125,8 @@ message InfoResponse { string county_name = 29; double buy_amount = 30; int32 residual_number = 31; + int32 status = 32; + string create_time = 33; } message ItemsResponse { diff --git a/rpc/user/pb/user.pb.go b/rpc/user/pb/user.pb.go index 0a36259..b7e0f97 100644 --- a/rpc/user/pb/user.pb.go +++ b/rpc/user/pb/user.pb.go @@ -1498,6 +1498,234 @@ func (x *InternalVerifyPasswordData) GetBizId() int64 { return 0 } +type InternalUsersByBizReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + ClientCode string `protobuf:"bytes,1,opt,name=client_code,json=clientCode,proto3" json:"client_code,omitempty"` + BizIds []int64 `protobuf:"varint,2,rep,packed,name=biz_ids,json=bizIds,proto3" json:"biz_ids,omitempty"` + Keyword string `protobuf:"bytes,3,opt,name=keyword,proto3" json:"keyword,omitempty"` + Gender uint32 `protobuf:"varint,4,opt,name=gender,proto3" json:"gender,omitempty"` + BirthdayGte string `protobuf:"bytes,5,opt,name=birthday_gte,json=birthdayGte,proto3" json:"birthday_gte,omitempty"` + BirthdayLte string `protobuf:"bytes,6,opt,name=birthday_lte,json=birthdayLte,proto3" json:"birthday_lte,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *InternalUsersByBizReq) Reset() { + *x = InternalUsersByBizReq{} + mi := &file_user_user_proto_msgTypes[23] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *InternalUsersByBizReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*InternalUsersByBizReq) ProtoMessage() {} + +func (x *InternalUsersByBizReq) ProtoReflect() protoreflect.Message { + mi := &file_user_user_proto_msgTypes[23] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use InternalUsersByBizReq.ProtoReflect.Descriptor instead. +func (*InternalUsersByBizReq) Descriptor() ([]byte, []int) { + return file_user_user_proto_rawDescGZIP(), []int{23} +} + +func (x *InternalUsersByBizReq) GetClientCode() string { + if x != nil { + return x.ClientCode + } + return "" +} + +func (x *InternalUsersByBizReq) GetBizIds() []int64 { + if x != nil { + return x.BizIds + } + return nil +} + +func (x *InternalUsersByBizReq) GetKeyword() string { + if x != nil { + return x.Keyword + } + return "" +} + +func (x *InternalUsersByBizReq) GetGender() uint32 { + if x != nil { + return x.Gender + } + return 0 +} + +func (x *InternalUsersByBizReq) GetBirthdayGte() string { + if x != nil { + return x.BirthdayGte + } + return "" +} + +func (x *InternalUsersByBizReq) GetBirthdayLte() string { + if x != nil { + return x.BirthdayLte + } + return "" +} + +type BizUserItem struct { + state protoimpl.MessageState `protogen:"open.v1"` + BizId int64 `protobuf:"varint,1,opt,name=biz_id,json=bizId,proto3" json:"biz_id,omitempty"` + UserId int64 `protobuf:"varint,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + Mobile string `protobuf:"bytes,3,opt,name=mobile,proto3" json:"mobile,omitempty"` + Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` + Avatar string `protobuf:"bytes,5,opt,name=avatar,proto3" json:"avatar,omitempty"` + Gender uint32 `protobuf:"varint,6,opt,name=gender,proto3" json:"gender,omitempty"` + Birthday string `protobuf:"bytes,7,opt,name=birthday,proto3" json:"birthday,omitempty"` + Status uint32 `protobuf:"varint,8,opt,name=status,proto3" json:"status,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *BizUserItem) Reset() { + *x = BizUserItem{} + mi := &file_user_user_proto_msgTypes[24] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *BizUserItem) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BizUserItem) ProtoMessage() {} + +func (x *BizUserItem) ProtoReflect() protoreflect.Message { + mi := &file_user_user_proto_msgTypes[24] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BizUserItem.ProtoReflect.Descriptor instead. +func (*BizUserItem) Descriptor() ([]byte, []int) { + return file_user_user_proto_rawDescGZIP(), []int{24} +} + +func (x *BizUserItem) GetBizId() int64 { + if x != nil { + return x.BizId + } + return 0 +} + +func (x *BizUserItem) GetUserId() int64 { + if x != nil { + return x.UserId + } + return 0 +} + +func (x *BizUserItem) GetMobile() string { + if x != nil { + return x.Mobile + } + return "" +} + +func (x *BizUserItem) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *BizUserItem) GetAvatar() string { + if x != nil { + return x.Avatar + } + return "" +} + +func (x *BizUserItem) GetGender() uint32 { + if x != nil { + return x.Gender + } + return 0 +} + +func (x *BizUserItem) GetBirthday() string { + if x != nil { + return x.Birthday + } + return "" +} + +func (x *BizUserItem) GetStatus() uint32 { + if x != nil { + return x.Status + } + return 0 +} + +type InternalUsersByBizData struct { + state protoimpl.MessageState `protogen:"open.v1"` + Items []*BizUserItem `protobuf:"bytes,1,rep,name=items,proto3" json:"items,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *InternalUsersByBizData) Reset() { + *x = InternalUsersByBizData{} + mi := &file_user_user_proto_msgTypes[25] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *InternalUsersByBizData) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*InternalUsersByBizData) ProtoMessage() {} + +func (x *InternalUsersByBizData) ProtoReflect() protoreflect.Message { + mi := &file_user_user_proto_msgTypes[25] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use InternalUsersByBizData.ProtoReflect.Descriptor instead. +func (*InternalUsersByBizData) Descriptor() ([]byte, []int) { + return file_user_user_proto_rawDescGZIP(), []int{25} +} + +func (x *InternalUsersByBizData) GetItems() []*BizUserItem { + if x != nil { + return x.Items + } + return nil +} + type GetOpenidReq struct { state protoimpl.MessageState `protogen:"open.v1"` Code string `protobuf:"bytes,1,opt,name=code,proto3" json:"code,omitempty"` @@ -1507,7 +1735,7 @@ type GetOpenidReq struct { func (x *GetOpenidReq) Reset() { *x = GetOpenidReq{} - mi := &file_user_user_proto_msgTypes[23] + mi := &file_user_user_proto_msgTypes[26] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1519,7 +1747,7 @@ func (x *GetOpenidReq) String() string { func (*GetOpenidReq) ProtoMessage() {} func (x *GetOpenidReq) ProtoReflect() protoreflect.Message { - mi := &file_user_user_proto_msgTypes[23] + mi := &file_user_user_proto_msgTypes[26] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1532,7 +1760,7 @@ func (x *GetOpenidReq) ProtoReflect() protoreflect.Message { // Deprecated: Use GetOpenidReq.ProtoReflect.Descriptor instead. func (*GetOpenidReq) Descriptor() ([]byte, []int) { - return file_user_user_proto_rawDescGZIP(), []int{23} + return file_user_user_proto_rawDescGZIP(), []int{26} } func (x *GetOpenidReq) GetCode() string { @@ -1550,7 +1778,7 @@ type InfoReq struct { func (x *InfoReq) Reset() { *x = InfoReq{} - mi := &file_user_user_proto_msgTypes[24] + mi := &file_user_user_proto_msgTypes[27] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1562,7 +1790,7 @@ func (x *InfoReq) String() string { func (*InfoReq) ProtoMessage() {} func (x *InfoReq) ProtoReflect() protoreflect.Message { - mi := &file_user_user_proto_msgTypes[24] + mi := &file_user_user_proto_msgTypes[27] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1575,7 +1803,91 @@ func (x *InfoReq) ProtoReflect() protoreflect.Message { // Deprecated: Use InfoReq.ProtoReflect.Descriptor instead. func (*InfoReq) Descriptor() ([]byte, []int) { - return file_user_user_proto_rawDescGZIP(), []int{24} + return file_user_user_proto_rawDescGZIP(), []int{27} +} + +type UpdateReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Avatar string `protobuf:"bytes,2,opt,name=avatar,proto3" json:"avatar,omitempty"` + Gender uint32 `protobuf:"varint,3,opt,name=gender,proto3" json:"gender,omitempty"` + Birthday string `protobuf:"bytes,4,opt,name=birthday,proto3" json:"birthday,omitempty"` + Mobile string `protobuf:"bytes,5,opt,name=mobile,proto3" json:"mobile,omitempty"` + RealName string `protobuf:"bytes,6,opt,name=real_name,json=realName,proto3" json:"real_name,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdateReq) Reset() { + *x = UpdateReq{} + mi := &file_user_user_proto_msgTypes[28] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdateReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateReq) ProtoMessage() {} + +func (x *UpdateReq) ProtoReflect() protoreflect.Message { + mi := &file_user_user_proto_msgTypes[28] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateReq.ProtoReflect.Descriptor instead. +func (*UpdateReq) Descriptor() ([]byte, []int) { + return file_user_user_proto_rawDescGZIP(), []int{28} +} + +func (x *UpdateReq) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *UpdateReq) GetAvatar() string { + if x != nil { + return x.Avatar + } + return "" +} + +func (x *UpdateReq) GetGender() uint32 { + if x != nil { + return x.Gender + } + return 0 +} + +func (x *UpdateReq) GetBirthday() string { + if x != nil { + return x.Birthday + } + return "" +} + +func (x *UpdateReq) GetMobile() string { + if x != nil { + return x.Mobile + } + return "" +} + +func (x *UpdateReq) GetRealName() string { + if x != nil { + return x.RealName + } + return "" } type PasswordReq struct { @@ -1588,7 +1900,7 @@ type PasswordReq struct { func (x *PasswordReq) Reset() { *x = PasswordReq{} - mi := &file_user_user_proto_msgTypes[25] + mi := &file_user_user_proto_msgTypes[29] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1600,7 +1912,7 @@ func (x *PasswordReq) String() string { func (*PasswordReq) ProtoMessage() {} func (x *PasswordReq) ProtoReflect() protoreflect.Message { - mi := &file_user_user_proto_msgTypes[25] + mi := &file_user_user_proto_msgTypes[29] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1613,7 +1925,7 @@ func (x *PasswordReq) ProtoReflect() protoreflect.Message { // Deprecated: Use PasswordReq.ProtoReflect.Descriptor instead. func (*PasswordReq) Descriptor() ([]byte, []int) { - return file_user_user_proto_rawDescGZIP(), []int{25} + return file_user_user_proto_rawDescGZIP(), []int{29} } func (x *PasswordReq) GetOldPassword() string { @@ -1641,7 +1953,7 @@ type ClientReq struct { func (x *ClientReq) Reset() { *x = ClientReq{} - mi := &file_user_user_proto_msgTypes[26] + mi := &file_user_user_proto_msgTypes[30] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1653,7 +1965,7 @@ func (x *ClientReq) String() string { func (*ClientReq) ProtoMessage() {} func (x *ClientReq) ProtoReflect() protoreflect.Message { - mi := &file_user_user_proto_msgTypes[26] + mi := &file_user_user_proto_msgTypes[30] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1666,7 +1978,7 @@ func (x *ClientReq) ProtoReflect() protoreflect.Message { // Deprecated: Use ClientReq.ProtoReflect.Descriptor instead. func (*ClientReq) Descriptor() ([]byte, []int) { - return file_user_user_proto_rawDescGZIP(), []int{26} + return file_user_user_proto_rawDescGZIP(), []int{30} } func (x *ClientReq) GetName() string { @@ -1699,7 +2011,7 @@ type GenerateQrcodeReq struct { func (x *GenerateQrcodeReq) Reset() { *x = GenerateQrcodeReq{} - mi := &file_user_user_proto_msgTypes[27] + mi := &file_user_user_proto_msgTypes[31] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1711,7 +2023,7 @@ func (x *GenerateQrcodeReq) String() string { func (*GenerateQrcodeReq) ProtoMessage() {} func (x *GenerateQrcodeReq) ProtoReflect() protoreflect.Message { - mi := &file_user_user_proto_msgTypes[27] + mi := &file_user_user_proto_msgTypes[31] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1724,7 +2036,7 @@ func (x *GenerateQrcodeReq) ProtoReflect() protoreflect.Message { // Deprecated: Use GenerateQrcodeReq.ProtoReflect.Descriptor instead. func (*GenerateQrcodeReq) Descriptor() ([]byte, []int) { - return file_user_user_proto_rawDescGZIP(), []int{27} + return file_user_user_proto_rawDescGZIP(), []int{31} } func (x *GenerateQrcodeReq) GetClientCode() string { @@ -1743,7 +2055,7 @@ type QrcodeScanReq struct { func (x *QrcodeScanReq) Reset() { *x = QrcodeScanReq{} - mi := &file_user_user_proto_msgTypes[28] + mi := &file_user_user_proto_msgTypes[32] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1755,7 +2067,7 @@ func (x *QrcodeScanReq) String() string { func (*QrcodeScanReq) ProtoMessage() {} func (x *QrcodeScanReq) ProtoReflect() protoreflect.Message { - mi := &file_user_user_proto_msgTypes[28] + mi := &file_user_user_proto_msgTypes[32] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1768,7 +2080,7 @@ func (x *QrcodeScanReq) ProtoReflect() protoreflect.Message { // Deprecated: Use QrcodeScanReq.ProtoReflect.Descriptor instead. func (*QrcodeScanReq) Descriptor() ([]byte, []int) { - return file_user_user_proto_rawDescGZIP(), []int{28} + return file_user_user_proto_rawDescGZIP(), []int{32} } func (x *QrcodeScanReq) GetSessionId() string { @@ -1788,7 +2100,7 @@ type QrcodeLoginReq struct { func (x *QrcodeLoginReq) Reset() { *x = QrcodeLoginReq{} - mi := &file_user_user_proto_msgTypes[29] + mi := &file_user_user_proto_msgTypes[33] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1800,7 +2112,7 @@ func (x *QrcodeLoginReq) String() string { func (*QrcodeLoginReq) ProtoMessage() {} func (x *QrcodeLoginReq) ProtoReflect() protoreflect.Message { - mi := &file_user_user_proto_msgTypes[29] + mi := &file_user_user_proto_msgTypes[33] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1813,7 +2125,7 @@ func (x *QrcodeLoginReq) ProtoReflect() protoreflect.Message { // Deprecated: Use QrcodeLoginReq.ProtoReflect.Descriptor instead. func (*QrcodeLoginReq) Descriptor() ([]byte, []int) { - return file_user_user_proto_rawDescGZIP(), []int{29} + return file_user_user_proto_rawDescGZIP(), []int{33} } func (x *QrcodeLoginReq) GetSessionId() string { @@ -1952,10 +2264,36 @@ const file_user_user_proto_rawDesc = "" + "clientCode\"L\n" + "\x1aInternalVerifyPasswordData\x12\x17\n" + "\auser_id\x18\x01 \x01(\x03R\x06userId\x12\x15\n" + - "\x06biz_id\x18\x02 \x01(\x03R\x05bizId\"\"\n" + + "\x06biz_id\x18\x02 \x01(\x03R\x05bizId\"\xc9\x01\n" + + "\x15InternalUsersByBizReq\x12\x1f\n" + + "\vclient_code\x18\x01 \x01(\tR\n" + + "clientCode\x12\x17\n" + + "\abiz_ids\x18\x02 \x03(\x03R\x06bizIds\x12\x18\n" + + "\akeyword\x18\x03 \x01(\tR\akeyword\x12\x16\n" + + "\x06gender\x18\x04 \x01(\rR\x06gender\x12!\n" + + "\fbirthday_gte\x18\x05 \x01(\tR\vbirthdayGte\x12!\n" + + "\fbirthday_lte\x18\x06 \x01(\tR\vbirthdayLte\"\xcd\x01\n" + + "\vBizUserItem\x12\x15\n" + + "\x06biz_id\x18\x01 \x01(\x03R\x05bizId\x12\x17\n" + + "\auser_id\x18\x02 \x01(\x03R\x06userId\x12\x16\n" + + "\x06mobile\x18\x03 \x01(\tR\x06mobile\x12\x12\n" + + "\x04name\x18\x04 \x01(\tR\x04name\x12\x16\n" + + "\x06avatar\x18\x05 \x01(\tR\x06avatar\x12\x16\n" + + "\x06gender\x18\x06 \x01(\rR\x06gender\x12\x1a\n" + + "\bbirthday\x18\a \x01(\tR\bbirthday\x12\x16\n" + + "\x06status\x18\b \x01(\rR\x06status\"A\n" + + "\x16InternalUsersByBizData\x12'\n" + + "\x05items\x18\x01 \x03(\v2\x11.user.BizUserItemR\x05items\"\"\n" + "\fGetOpenidReq\x12\x12\n" + "\x04code\x18\x01 \x01(\tR\x04code\"\t\n" + - "\aInfoReq\"L\n" + + "\aInfoReq\"\xa0\x01\n" + + "\tUpdateReq\x12\x12\n" + + "\x04name\x18\x01 \x01(\tR\x04name\x12\x16\n" + + "\x06avatar\x18\x02 \x01(\tR\x06avatar\x12\x16\n" + + "\x06gender\x18\x03 \x01(\rR\x06gender\x12\x1a\n" + + "\bbirthday\x18\x04 \x01(\tR\bbirthday\x12\x16\n" + + "\x06mobile\x18\x05 \x01(\tR\x06mobile\x12\x1b\n" + + "\treal_name\x18\x06 \x01(\tR\brealName\"L\n" + "\vPasswordReq\x12!\n" + "\fold_password\x18\x01 \x01(\tR\voldPassword\x12\x1a\n" + "\bpassword\x18\x02 \x01(\tR\bpassword\"V\n" + @@ -1972,16 +2310,17 @@ const file_user_user_proto_rawDesc = "" + "\x0eQrcodeLoginReq\x12\x1d\n" + "\n" + "session_id\x18\x01 \x01(\tR\tsessionId\x12\x12\n" + - "\x04type\x18\x02 \x01(\x05R\x04type2\xa5\f\n" + - "\x04User\x12A\n" + - "\x05Login\x12\x0e.user.LoginReq\x1a\x0e.user.Response\"\x18\x82\xd3\xe4\x93\x02\x12:\x01*\"\r/api/v3/login\x12b\n" + + "\x04type\x18\x02 \x01(\x05R\x04type2\xc4\r\n" + + "\x04User\x12F\n" + + "\x05Login\x12\x0e.user.LoginReq\x1a\x0e.user.Response\"\x1d\x82\xd3\xe4\x93\x02\x17:\x01*\"\x12/api/v3/user/login\x12b\n" + "\x0eGenerateQrcode\x12\x17.user.GenerateQrcodeReq\x1a\x0e.user.Response\"'\x82\xd3\xe4\x93\x02!:\x01*\"\x1c/api/v3/user/qrcode/generate\x12V\n" + "\n" + "QrcodeScan\x12\x13.user.QrcodeScanReq\x1a\x0e.user.Response\"#\x82\xd3\xe4\x93\x02\x1d:\x01*\"\x18/api/v3/user/qrcode/scan\x12Y\n" + "\vQrcodeLogin\x12\x14.user.QrcodeLoginReq\x1a\x0e.user.Response\"$\x82\xd3\xe4\x93\x02\x1e:\x01*\"\x19/api/v3/user/qrcode/login\x12C\n" + - "\x04Info\x12\r.user.InfoReq\x1a\x0e.user.Response\"\x1c\x82\xd3\xe4\x93\x02\x16:\x01*\x12\x11/api/v3/user/info\x12O\n" + - "\bPassword\x12\x11.user.PasswordReq\x1a\x0e.user.Response\" \x82\xd3\xe4\x93\x02\x1a:\x01*\x1a\x15/api/v3/user/password\x12N\n" + - "\tGetOpenid\x12\x12.user.GetOpenidReq\x1a\x0e.user.Response\"\x1d\x82\xd3\xe4\x93\x02\x17:\x01*\"\x12/api/v3/getuseroid\x12K\n" + + "\x04Info\x12\r.user.InfoReq\x1a\x0e.user.Response\"\x1c\x82\xd3\xe4\x93\x02\x16:\x01*\x12\x11/api/v3/user/info\x12B\n" + + "\x06Update\x12\x0f.user.UpdateReq\x1a\x0e.user.Response\"\x17\x82\xd3\xe4\x93\x02\x11:\x01*\x1a\f/api/v3/user\x12O\n" + + "\bPassword\x12\x11.user.PasswordReq\x1a\x0e.user.Response\" \x82\xd3\xe4\x93\x02\x1a:\x01*\x1a\x15/api/v3/user/password\x12S\n" + + "\tGetOpenid\x12\x12.user.GetOpenidReq\x1a\x0e.user.Response\"\"\x82\xd3\xe4\x93\x02\x1c:\x01*\"\x17/api/v3/user/getuseroid\x12K\n" + "\x06Client\x12\x0f.user.ClientReq\x1a\x0e.user.Response\" \x82\xd3\xe4\x93\x02\x1a:\x01*\x12\x15/admin/v3/user/client\x12P\n" + "\tUserItems\x12\x12.user.UserItemsReq\x1a\x0e.user.Response\"\x1f\x82\xd3\xe4\x93\x02\x19:\x01*\x12\x14/admin/v3/user/items\x12S\n" + "\n" + @@ -1994,7 +2333,8 @@ const file_user_user_proto_rawDesc = "" + "\x14InternalUpdateMobile\x12\x1d.user.InternalUpdateMobileReq\x1a\x1e.user.InternalUpdateMobileData\x12^\n" + "\x17InternalRevokeBizClient\x12 .user.InternalRevokeBizClientReq\x1a!.user.InternalRevokeBizClientData\x12R\n" + "\x13InternalGetUserInfo\x12\x1c.user.InternalGetUserInfoReq\x1a\x1d.user.InternalGetUserInfoData\x12[\n" + - "\x16InternalVerifyPassword\x12\x1f.user.InternalVerifyPasswordReq\x1a .user.InternalVerifyPasswordDataB\x18Z\x16lone-services/rpc/userb\x06proto3" + "\x16InternalVerifyPassword\x12\x1f.user.InternalVerifyPasswordReq\x1a .user.InternalVerifyPasswordData\x12O\n" + + "\x12InternalUsersByBiz\x12\x1b.user.InternalUsersByBizReq\x1a\x1c.user.InternalUsersByBizDataB\x18Z\x16lone-services/rpc/userb\x06proto3" var ( file_user_user_proto_rawDescOnce sync.Once @@ -2008,7 +2348,7 @@ func file_user_user_proto_rawDescGZIP() []byte { return file_user_user_proto_rawDescData } -var file_user_user_proto_msgTypes = make([]protoimpl.MessageInfo, 30) +var file_user_user_proto_msgTypes = make([]protoimpl.MessageInfo, 34) var file_user_user_proto_goTypes = []any{ (*Response)(nil), // 0: user.Response (*LoginReq)(nil), // 1: user.LoginReq @@ -2033,59 +2373,68 @@ var file_user_user_proto_goTypes = []any{ (*InternalGetUserInfoData)(nil), // 20: user.InternalGetUserInfoData (*InternalVerifyPasswordReq)(nil), // 21: user.InternalVerifyPasswordReq (*InternalVerifyPasswordData)(nil), // 22: user.InternalVerifyPasswordData - (*GetOpenidReq)(nil), // 23: user.GetOpenidReq - (*InfoReq)(nil), // 24: user.InfoReq - (*PasswordReq)(nil), // 25: user.PasswordReq - (*ClientReq)(nil), // 26: user.ClientReq - (*GenerateQrcodeReq)(nil), // 27: user.GenerateQrcodeReq - (*QrcodeScanReq)(nil), // 28: user.QrcodeScanReq - (*QrcodeLoginReq)(nil), // 29: user.QrcodeLoginReq + (*InternalUsersByBizReq)(nil), // 23: user.InternalUsersByBizReq + (*BizUserItem)(nil), // 24: user.BizUserItem + (*InternalUsersByBizData)(nil), // 25: user.InternalUsersByBizData + (*GetOpenidReq)(nil), // 26: user.GetOpenidReq + (*InfoReq)(nil), // 27: user.InfoReq + (*UpdateReq)(nil), // 28: user.UpdateReq + (*PasswordReq)(nil), // 29: user.PasswordReq + (*ClientReq)(nil), // 30: user.ClientReq + (*GenerateQrcodeReq)(nil), // 31: user.GenerateQrcodeReq + (*QrcodeScanReq)(nil), // 32: user.QrcodeScanReq + (*QrcodeLoginReq)(nil), // 33: user.QrcodeLoginReq } var file_user_user_proto_depIdxs = []int32{ 7, // 0: user.InternalUsersByIdsData.items:type_name -> user.UserBriefItem - 1, // 1: user.User.Login:input_type -> user.LoginReq - 27, // 2: user.User.GenerateQrcode:input_type -> user.GenerateQrcodeReq - 28, // 3: user.User.QrcodeScan:input_type -> user.QrcodeScanReq - 29, // 4: user.User.QrcodeLogin:input_type -> user.QrcodeLoginReq - 24, // 5: user.User.Info:input_type -> user.InfoReq - 25, // 6: user.User.Password:input_type -> user.PasswordReq - 23, // 7: user.User.GetOpenid:input_type -> user.GetOpenidReq - 26, // 8: user.User.Client:input_type -> user.ClientReq - 2, // 9: user.User.UserItems:input_type -> user.UserItemsReq - 3, // 10: user.User.UserStatus:input_type -> user.UserStatusReq - 4, // 11: user.User.InternalCreate:input_type -> user.InternalCreateReq - 13, // 12: user.User.InternalCheckCreate:input_type -> user.InternalCheckCreateReq - 15, // 13: user.User.InternalCheckUpdate:input_type -> user.InternalCheckUpdateReq - 17, // 14: user.User.InternalUpdate:input_type -> user.InternalUpdateReq - 6, // 15: user.User.InternalUsersByIds:input_type -> user.InternalUsersByIdsReq - 9, // 16: user.User.InternalUpdateMobile:input_type -> user.InternalUpdateMobileReq - 11, // 17: user.User.InternalRevokeBizClient:input_type -> user.InternalRevokeBizClientReq - 19, // 18: user.User.InternalGetUserInfo:input_type -> user.InternalGetUserInfoReq - 21, // 19: user.User.InternalVerifyPassword:input_type -> user.InternalVerifyPasswordReq - 0, // 20: user.User.Login:output_type -> user.Response - 0, // 21: user.User.GenerateQrcode:output_type -> user.Response - 0, // 22: user.User.QrcodeScan:output_type -> user.Response - 0, // 23: user.User.QrcodeLogin:output_type -> user.Response - 0, // 24: user.User.Info:output_type -> user.Response - 0, // 25: user.User.Password:output_type -> user.Response - 0, // 26: user.User.GetOpenid:output_type -> user.Response - 0, // 27: user.User.Client:output_type -> user.Response - 0, // 28: user.User.UserItems:output_type -> user.Response - 0, // 29: user.User.UserStatus:output_type -> user.Response - 5, // 30: user.User.InternalCreate:output_type -> user.InternalCreateData - 14, // 31: user.User.InternalCheckCreate:output_type -> user.InternalCheckCreateData - 16, // 32: user.User.InternalCheckUpdate:output_type -> user.InternalCheckUpdateData - 18, // 33: user.User.InternalUpdate:output_type -> user.InternalUpdateData - 8, // 34: user.User.InternalUsersByIds:output_type -> user.InternalUsersByIdsData - 10, // 35: user.User.InternalUpdateMobile:output_type -> user.InternalUpdateMobileData - 12, // 36: user.User.InternalRevokeBizClient:output_type -> user.InternalRevokeBizClientData - 20, // 37: user.User.InternalGetUserInfo:output_type -> user.InternalGetUserInfoData - 22, // 38: user.User.InternalVerifyPassword:output_type -> user.InternalVerifyPasswordData - 20, // [20:39] is the sub-list for method output_type - 1, // [1:20] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name + 24, // 1: user.InternalUsersByBizData.items:type_name -> user.BizUserItem + 1, // 2: user.User.Login:input_type -> user.LoginReq + 31, // 3: user.User.GenerateQrcode:input_type -> user.GenerateQrcodeReq + 32, // 4: user.User.QrcodeScan:input_type -> user.QrcodeScanReq + 33, // 5: user.User.QrcodeLogin:input_type -> user.QrcodeLoginReq + 27, // 6: user.User.Info:input_type -> user.InfoReq + 28, // 7: user.User.Update:input_type -> user.UpdateReq + 29, // 8: user.User.Password:input_type -> user.PasswordReq + 26, // 9: user.User.GetOpenid:input_type -> user.GetOpenidReq + 30, // 10: user.User.Client:input_type -> user.ClientReq + 2, // 11: user.User.UserItems:input_type -> user.UserItemsReq + 3, // 12: user.User.UserStatus:input_type -> user.UserStatusReq + 4, // 13: user.User.InternalCreate:input_type -> user.InternalCreateReq + 13, // 14: user.User.InternalCheckCreate:input_type -> user.InternalCheckCreateReq + 15, // 15: user.User.InternalCheckUpdate:input_type -> user.InternalCheckUpdateReq + 17, // 16: user.User.InternalUpdate:input_type -> user.InternalUpdateReq + 6, // 17: user.User.InternalUsersByIds:input_type -> user.InternalUsersByIdsReq + 9, // 18: user.User.InternalUpdateMobile:input_type -> user.InternalUpdateMobileReq + 11, // 19: user.User.InternalRevokeBizClient:input_type -> user.InternalRevokeBizClientReq + 19, // 20: user.User.InternalGetUserInfo:input_type -> user.InternalGetUserInfoReq + 21, // 21: user.User.InternalVerifyPassword:input_type -> user.InternalVerifyPasswordReq + 23, // 22: user.User.InternalUsersByBiz:input_type -> user.InternalUsersByBizReq + 0, // 23: user.User.Login:output_type -> user.Response + 0, // 24: user.User.GenerateQrcode:output_type -> user.Response + 0, // 25: user.User.QrcodeScan:output_type -> user.Response + 0, // 26: user.User.QrcodeLogin:output_type -> user.Response + 0, // 27: user.User.Info:output_type -> user.Response + 0, // 28: user.User.Update:output_type -> user.Response + 0, // 29: user.User.Password:output_type -> user.Response + 0, // 30: user.User.GetOpenid:output_type -> user.Response + 0, // 31: user.User.Client:output_type -> user.Response + 0, // 32: user.User.UserItems:output_type -> user.Response + 0, // 33: user.User.UserStatus:output_type -> user.Response + 5, // 34: user.User.InternalCreate:output_type -> user.InternalCreateData + 14, // 35: user.User.InternalCheckCreate:output_type -> user.InternalCheckCreateData + 16, // 36: user.User.InternalCheckUpdate:output_type -> user.InternalCheckUpdateData + 18, // 37: user.User.InternalUpdate:output_type -> user.InternalUpdateData + 8, // 38: user.User.InternalUsersByIds:output_type -> user.InternalUsersByIdsData + 10, // 39: user.User.InternalUpdateMobile:output_type -> user.InternalUpdateMobileData + 12, // 40: user.User.InternalRevokeBizClient:output_type -> user.InternalRevokeBizClientData + 20, // 41: user.User.InternalGetUserInfo:output_type -> user.InternalGetUserInfoData + 22, // 42: user.User.InternalVerifyPassword:output_type -> user.InternalVerifyPasswordData + 25, // 43: user.User.InternalUsersByBiz:output_type -> user.InternalUsersByBizData + 23, // [23:44] is the sub-list for method output_type + 2, // [2:23] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name } func init() { file_user_user_proto_init() } @@ -2099,7 +2448,7 @@ func file_user_user_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_user_user_proto_rawDesc), len(file_user_user_proto_rawDesc)), NumEnums: 0, - NumMessages: 30, + NumMessages: 34, NumExtensions: 0, NumServices: 1, }, diff --git a/rpc/user/pb/user_grpc.pb.go b/rpc/user/pb/user_grpc.pb.go index 5a5da2c..e27fc37 100644 --- a/rpc/user/pb/user_grpc.pb.go +++ b/rpc/user/pb/user_grpc.pb.go @@ -24,6 +24,7 @@ const ( User_QrcodeScan_FullMethodName = "/user.User/QrcodeScan" User_QrcodeLogin_FullMethodName = "/user.User/QrcodeLogin" User_Info_FullMethodName = "/user.User/Info" + User_Update_FullMethodName = "/user.User/Update" User_Password_FullMethodName = "/user.User/Password" User_GetOpenid_FullMethodName = "/user.User/GetOpenid" User_Client_FullMethodName = "/user.User/Client" @@ -38,6 +39,7 @@ const ( User_InternalRevokeBizClient_FullMethodName = "/user.User/InternalRevokeBizClient" User_InternalGetUserInfo_FullMethodName = "/user.User/InternalGetUserInfo" User_InternalVerifyPassword_FullMethodName = "/user.User/InternalVerifyPassword" + User_InternalUsersByBiz_FullMethodName = "/user.User/InternalUsersByBiz" ) // UserClient is the client API for User service. @@ -49,6 +51,7 @@ type UserClient interface { QrcodeScan(ctx context.Context, in *QrcodeScanReq, opts ...grpc.CallOption) (*Response, error) QrcodeLogin(ctx context.Context, in *QrcodeLoginReq, opts ...grpc.CallOption) (*Response, error) Info(ctx context.Context, in *InfoReq, opts ...grpc.CallOption) (*Response, error) + Update(ctx context.Context, in *UpdateReq, opts ...grpc.CallOption) (*Response, error) Password(ctx context.Context, in *PasswordReq, opts ...grpc.CallOption) (*Response, error) GetOpenid(ctx context.Context, in *GetOpenidReq, opts ...grpc.CallOption) (*Response, error) Client(ctx context.Context, in *ClientReq, opts ...grpc.CallOption) (*Response, error) @@ -63,6 +66,7 @@ type UserClient interface { InternalRevokeBizClient(ctx context.Context, in *InternalRevokeBizClientReq, opts ...grpc.CallOption) (*InternalRevokeBizClientData, error) InternalGetUserInfo(ctx context.Context, in *InternalGetUserInfoReq, opts ...grpc.CallOption) (*InternalGetUserInfoData, error) InternalVerifyPassword(ctx context.Context, in *InternalVerifyPasswordReq, opts ...grpc.CallOption) (*InternalVerifyPasswordData, error) + InternalUsersByBiz(ctx context.Context, in *InternalUsersByBizReq, opts ...grpc.CallOption) (*InternalUsersByBizData, error) } type userClient struct { @@ -123,6 +127,16 @@ func (c *userClient) Info(ctx context.Context, in *InfoReq, opts ...grpc.CallOpt return out, nil } +func (c *userClient) Update(ctx context.Context, in *UpdateReq, opts ...grpc.CallOption) (*Response, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Response) + err := c.cc.Invoke(ctx, User_Update_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *userClient) Password(ctx context.Context, in *PasswordReq, opts ...grpc.CallOption) (*Response, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(Response) @@ -263,6 +277,16 @@ func (c *userClient) InternalVerifyPassword(ctx context.Context, in *InternalVer return out, nil } +func (c *userClient) InternalUsersByBiz(ctx context.Context, in *InternalUsersByBizReq, opts ...grpc.CallOption) (*InternalUsersByBizData, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(InternalUsersByBizData) + err := c.cc.Invoke(ctx, User_InternalUsersByBiz_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + // UserServer is the server API for User service. // All implementations must embed UnimplementedUserServer // for forward compatibility. @@ -272,6 +296,7 @@ type UserServer interface { QrcodeScan(context.Context, *QrcodeScanReq) (*Response, error) QrcodeLogin(context.Context, *QrcodeLoginReq) (*Response, error) Info(context.Context, *InfoReq) (*Response, error) + Update(context.Context, *UpdateReq) (*Response, error) Password(context.Context, *PasswordReq) (*Response, error) GetOpenid(context.Context, *GetOpenidReq) (*Response, error) Client(context.Context, *ClientReq) (*Response, error) @@ -286,6 +311,7 @@ type UserServer interface { InternalRevokeBizClient(context.Context, *InternalRevokeBizClientReq) (*InternalRevokeBizClientData, error) InternalGetUserInfo(context.Context, *InternalGetUserInfoReq) (*InternalGetUserInfoData, error) InternalVerifyPassword(context.Context, *InternalVerifyPasswordReq) (*InternalVerifyPasswordData, error) + InternalUsersByBiz(context.Context, *InternalUsersByBizReq) (*InternalUsersByBizData, error) mustEmbedUnimplementedUserServer() } @@ -311,6 +337,9 @@ func (UnimplementedUserServer) QrcodeLogin(context.Context, *QrcodeLoginReq) (*R func (UnimplementedUserServer) Info(context.Context, *InfoReq) (*Response, error) { return nil, status.Error(codes.Unimplemented, "method Info not implemented") } +func (UnimplementedUserServer) Update(context.Context, *UpdateReq) (*Response, error) { + return nil, status.Error(codes.Unimplemented, "method Update not implemented") +} func (UnimplementedUserServer) Password(context.Context, *PasswordReq) (*Response, error) { return nil, status.Error(codes.Unimplemented, "method Password not implemented") } @@ -353,6 +382,9 @@ func (UnimplementedUserServer) InternalGetUserInfo(context.Context, *InternalGet func (UnimplementedUserServer) InternalVerifyPassword(context.Context, *InternalVerifyPasswordReq) (*InternalVerifyPasswordData, error) { return nil, status.Error(codes.Unimplemented, "method InternalVerifyPassword not implemented") } +func (UnimplementedUserServer) InternalUsersByBiz(context.Context, *InternalUsersByBizReq) (*InternalUsersByBizData, error) { + return nil, status.Error(codes.Unimplemented, "method InternalUsersByBiz not implemented") +} func (UnimplementedUserServer) mustEmbedUnimplementedUserServer() {} func (UnimplementedUserServer) testEmbeddedByValue() {} @@ -464,6 +496,24 @@ func _User_Info_Handler(srv interface{}, ctx context.Context, dec func(interface return interceptor(ctx, in, info, handler) } +func _User_Update_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdateReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UserServer).Update(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: User_Update_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UserServer).Update(ctx, req.(*UpdateReq)) + } + return interceptor(ctx, in, info, handler) +} + func _User_Password_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(PasswordReq) if err := dec(in); err != nil { @@ -716,6 +766,24 @@ func _User_InternalVerifyPassword_Handler(srv interface{}, ctx context.Context, return interceptor(ctx, in, info, handler) } +func _User_InternalUsersByBiz_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(InternalUsersByBizReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UserServer).InternalUsersByBiz(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: User_InternalUsersByBiz_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UserServer).InternalUsersByBiz(ctx, req.(*InternalUsersByBizReq)) + } + return interceptor(ctx, in, info, handler) +} + // User_ServiceDesc is the grpc.ServiceDesc for User service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -743,6 +811,10 @@ var User_ServiceDesc = grpc.ServiceDesc{ MethodName: "Info", Handler: _User_Info_Handler, }, + { + MethodName: "Update", + Handler: _User_Update_Handler, + }, { MethodName: "Password", Handler: _User_Password_Handler, @@ -799,6 +871,10 @@ var User_ServiceDesc = grpc.ServiceDesc{ MethodName: "InternalVerifyPassword", Handler: _User_InternalVerifyPassword_Handler, }, + { + MethodName: "InternalUsersByBiz", + Handler: _User_InternalUsersByBiz_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "user/user.proto", diff --git a/rpc/user/user.pb b/rpc/user/user.pb index cb83558dfdc13032c4b9389d8d04b56237ed3bda..6400af5597d8716ca25a1337d5d6622092f77763 100644 GIT binary patch delta 638 zcmZXQPiqrF7{;01WYfH9lpRQR8$GlOYM{`hN@y)bn}3#osEkDL6ejGnU7Bp-&QwV+ zg&ukp928ID#k-KNAVLqGJbLlq)i2;hXLcKD>1lZ0_nCQq^L%=ZzP?4D8#Uv2dD^PI zhvF%MLMId~3hAKBS;QNYMsO%kYd4M@$n=B5Uf^@rSTxHfv6Sri9J`R&XOmZ>$al>} zRL+u_#6_@nS?IIKO{qnmoGH8n^Zg(adp@1?b_H|O@wMD+wk_BN%RpJI_C?P_!Mtw> za*9rKb_5&Z0%#;f=ptn{Nje6^3j9D>^xTm4h9jS^FUgIy97@Z->khJHb#nn_|)SZhpLg}k{&!#dJ0pEaumFJ52wob&7HyXJ4Rh#v#K+?xE^c1+ce{L?PQ=h61fe;7Ex>i_@% delta 86 zcmV-c0IC1Rl>w!X0kA?f0^uaHL^YTSle= ?": utils.Now().String(), + }, + Order: "created_at desc", + Page: int(req.Page), + Size: int(req.Size), + } + if hasFilter { + params.In = map[string][]string{"user_id": idStrings(userIds)} + } + + var records []storeUserRecord + authModel := model.UserStoreAuthModel{}.Init() + if _, err = authModel.Page(params, &records); err != nil { + l.Errorf("store user list page: %v", err) + return common.FailResponse(utils.Fail), nil + } + if len(records) == utils.NumberZero { + return common.OkResponse([]dao.StoreUserListItem{}), nil + } + + pageIds := make([]int64, 0, len(records)) + for _, row := range records { + pageIds = append(pageIds, row.UserId) + } + + profiles, err := l.loadProfiles(pageIds) + if err != nil { + l.Errorf("store user list profiles: %v", err) + return common.FailResponse(utils.Fail), nil + } + logs, err := loadImageLogs(pageIds) + if err != nil { + l.Errorf("store user list logs: %v", err) + return common.FailResponse(utils.Fail), nil + } + remarks, err := loadRemarks(storeId, pageIds) + if err != nil { + l.Errorf("store user list remarks: %v", err) + return common.FailResponse(utils.Fail), nil + } + + list := make([]dao.StoreUserListItem, 0, len(records)) + for _, row := range records { + profile, ok := profiles[row.UserId] + if !ok { + continue + } + item := dao.StoreUserListItem{ + Id: row.Id, + UserId: row.UserId, + StoreId: row.StoreId, + Name: profile.Name, + Nickname: profile.Name, + Avatar: imageURL(profile.Avatar), + Mobile: decryptMobile(profile.Mobile), + Gender: int(profile.Gender), + Birthday: profile.Birthday, + Age: utils.CalcAgeStr(profile.Birthday), + } + if logRow, ok := logs[row.UserId]; ok { + item.Cover = imageURL(logRow.Cover) + item.DetectionNumber = logRow.DetectionNumber + item.DetectionTime = logRow.DetectionTime.Format(detectionTimeLayout) + } + if remark, ok := remarks[row.UserId]; ok { + if remark.Name != utils.StringEmpty { + item.Nickname = remark.Name + } + if remark.Gender != utils.NumberZero { + item.Gender = int(remark.Gender) + } + if remark.Birthday != utils.StringEmpty { + item.Birthday = dateOnly(remark.Birthday) + item.Age = utils.CalcAgeStr(item.Birthday) + } + } + list = append(list, item) + } + return common.OkResponse(list), nil +} + +func (l *StoreUserListLogic) filterUserIds(storeId int64, in *analysis.StoreUserListReq) ([]int64, bool, error) { + var ids []int64 + hasFilter := false + + birthStart, birthEnd := ageBirthdayRange(in.AgeMin, in.AgeMax) + profileFilter := in.Keyword != utils.StringEmpty || in.Gender != utils.NumberZero || birthStart != utils.StringEmpty || birthEnd != utils.StringEmpty + if profileFilter { + matched, err := l.filterBizIds(in.Keyword, in.Gender, birthStart, birthEnd) + if err != nil { + return nil, false, err + } + ids = matched + hasFilter = true + if len(ids) == utils.NumberZero { + return ids, true, nil + } + } + + if len(in.Date) == 2 { + logWhere := modelbase.Params{ + Between: map[string][2]string{ + "detection_time": utils.DateRangeWithTime(in.Date), + }, + } + if hasFilter { + logWhere.In = map[string][]string{"user_id": idStrings(ids)} + } + raw, err := model.UserImageLogModel{}.Init().GetIDsByKeyword(logWhere, "user_id") + if err != nil { + return nil, false, err + } + ids = parseIDs(raw) + return ids, true, nil + } + + if in.Tag != utils.StringEmpty { + tagWhere := modelbase.Params{ + Eq: map[string]string{ + "status": strconv.Itoa(int(dao.StatusEnabled)), + "store_id": strconv.FormatInt(storeId, utils.NumberTen), + }, + Like: map[string]string{"tag LIKE ?": "%" + in.Tag + "%"}, + } + raw, err := model.UserImageTagModel{}.Init().GetIDsByKeyword(tagWhere, "user_id") + if err != nil { + return nil, false, err + } + tagIDs := parseIDs(raw) + if !hasFilter { + return tagIDs, true, nil + } + return intersectIDs(ids, tagIDs), true, nil + } + + return ids, hasFilter, nil +} + +func (l *StoreUserListLogic) filterBizIds(keyword string, gender int32, birthStart, birthEnd string) ([]int64, error) { + if l.svcCtx.UserSvcName == utils.StringEmpty { + return nil, status.Error(codes.FailedPrecondition, "user service empty") + } + cli, err := svc.GetRpcClient(l.svcCtx.UserSvcName) + if err != nil { + return nil, err + } + res, err := userpb.NewUserClient(cli.Conn()).InternalUsersByBiz(l.ctx, &userpb.InternalUsersByBizReq{ + ClientCode: dao.ClientCodeUserSkin, + Keyword: keyword, + Gender: uint32(gender), + BirthdayGte: birthStart, + BirthdayLte: birthEnd, + }) + if err != nil { + return nil, err + } + ids := make([]int64, 0, len(res.GetItems())) + for _, item := range res.GetItems() { + if item.BizId > utils.NumberZero { + ids = append(ids, item.BizId) + } + } + return ids, nil +} + +func (l *StoreUserListLogic) loadProfiles(bizIds []int64) (map[int64]*userpb.BizUserItem, error) { + if l.svcCtx.UserSvcName == utils.StringEmpty { + return nil, status.Error(codes.FailedPrecondition, "user service empty") + } + cli, err := svc.GetRpcClient(l.svcCtx.UserSvcName) + if err != nil { + return nil, err + } + res, err := userpb.NewUserClient(cli.Conn()).InternalUsersByBiz(l.ctx, &userpb.InternalUsersByBizReq{ + ClientCode: dao.ClientCodeUserSkin, + BizIds: bizIds, + }) + if err != nil { + return nil, err + } + out := make(map[int64]*userpb.BizUserItem, len(res.GetItems())) + for _, item := range res.GetItems() { + out[item.BizId] = item + } + return out, nil +} + +func loadImageLogs(userIds []int64) (map[int64]dao.UserImageLog, error) { + var rows []dao.UserImageLog + err := model.UserImageLogModel{}.Init().Items(modelbase.Params{ + In: map[string][]string{"user_id": idStrings(userIds)}, + Order: "detection_time desc", + }, &rows) + if err != nil { + return nil, err + } + out := make(map[int64]dao.UserImageLog, len(rows)) + for _, row := range rows { + if _, ok := out[row.UserId]; ok { + continue + } + out[row.UserId] = row + } + return out, nil +} + +func loadRemarks(storeId int64, userIds []int64) (map[int64]dao.UserRemark, error) { + var rows []dao.UserRemark + err := model.UserRemarkModel{}.Init().Items(modelbase.Params{ + Eq: map[string]string{"store_id": strconv.FormatInt(storeId, utils.NumberTen)}, + In: map[string][]string{"user_id": idStrings(userIds)}, + }, &rows) + if err != nil { + return nil, err + } + out := make(map[int64]dao.UserRemark, len(rows)) + for _, row := range rows { + out[row.UserId] = row + } + return out, nil +} + +func ageBirthdayRange(ageMin, ageMax int32) (string, string) { + year := time.Now().Year() + var start, end string + if ageMax > utils.NumberZero { + start = strconv.Itoa(year-int(ageMax)) + "-01-01" + } + if ageMin > utils.NumberZero { + end = strconv.Itoa(year-int(ageMin)) + "-12-31" + } + return start, end +} + +func parseIDs(raw []string) []int64 { + out := make([]int64, 0, len(raw)) + seen := make(map[int64]struct{}, len(raw)) + for _, item := range raw { + id, err := strconv.ParseInt(item, utils.NumberTen, 64) + if err != nil || id < utils.NumberOne { + continue + } + if _, ok := seen[id]; ok { + continue + } + seen[id] = struct{}{} + out = append(out, id) + } + return out +} + +func intersectIDs(left, right []int64) []int64 { + set := make(map[int64]struct{}, len(left)) + for _, id := range left { + set[id] = struct{}{} + } + out := make([]int64, 0) + for _, id := range right { + if _, ok := set[id]; ok { + out = append(out, id) + } + } + return out +} + +func decryptMobile(mobile string) string { + plain, err := utils.DecryptPhone(mobile) + if err != nil { + return utils.StringEmpty + } + return plain +} diff --git a/services/analysis/internal/logic/analysisstore/storeUserUpdateLogic.go b/services/analysis/internal/logic/analysisstore/storeUserUpdateLogic.go new file mode 100644 index 0000000..beb7c5d --- /dev/null +++ b/services/analysis/internal/logic/analysisstore/storeUserUpdateLogic.go @@ -0,0 +1,155 @@ +package analysisstorelogic + +import ( + "context" + "strconv" + "strings" + "time" + + "lone-services/pkg/modelbase" + "lone-services/pkg/utils" + "lone-services/pkg/validate" + analysis "lone-services/rpc/analysis/pb" + "lone-services/services/analysis/internal/dao" + "lone-services/services/analysis/internal/logic/common" + "lone-services/services/analysis/internal/model" + "lone-services/services/analysis/internal/svc" + "lone-services/services/analysis/validator" + + "github.com/zeromicro/go-zero/core/logx" +) + +type StoreUserUpdateLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewStoreUserUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *StoreUserUpdateLogic { + return &StoreUserUpdateLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *StoreUserUpdateLogic) StoreUserUpdate(in *analysis.StoreUserUpdateReq) (*analysis.Response, error) { + var req validator.StoreUserUpdateValidator + if msg := validate.ValidateFromProto(in, &req); msg != utils.StringEmpty { + return common.OutResponse(utils.ErrorParams, msg), nil + } + if req.Birthday != nil && *req.Birthday != utils.StringEmpty { + if _, err := time.ParseInLocation("2006-01-02", dateOnly(*req.Birthday), time.Local); err != nil { + return common.OutResponse(utils.ErrorParams, "生日格式不正确"), nil + } + } + + storeId, _, fail := common.RequireStoreId(l.ctx) + if fail != nil { + return fail, nil + } + + if err := replaceUserTags(storeId, req.UserId, in.Tag); err != nil { + l.Errorf("store user update tags: %v", err) + return common.FailResponse(utils.Fail), nil + } + + data := map[string]interface{}{} + if req.Name != nil { + data["name"] = *req.Name + } + if req.Gender != nil { + if *req.Gender == utils.NumberZero { + data["gender"] = nil + } else { + data["gender"] = *req.Gender + } + } + if req.Birthday != nil { + if *req.Birthday == utils.StringEmpty { + data["birthday"] = nil + } else { + data["birthday"] = dateOnly(*req.Birthday) + } + } + + where := modelbase.Params{ + Eq: map[string]string{ + "user_id": strconv.FormatInt(req.UserId, utils.NumberTen), + "store_id": strconv.FormatInt(storeId, utils.NumberTen), + }, + } + remarkModel := model.UserRemarkModel{}.Init() + count, err := remarkModel.CountNumber(where) + if err != nil { + l.Errorf("store user update count: %v", err) + return common.FailResponse(utils.Fail), nil + } + if count > utils.NumberZero { + if len(data) == utils.NumberZero { + return common.OkResponse(nil), nil + } + if _, err = remarkModel.Edit(where, data); err != nil { + l.Errorf("store user update edit: %v", err) + return common.FailResponse(utils.Fail), nil + } + return common.OkResponse(nil), nil + } + + row := dao.UserRemark{ + StoreId: storeId, + UserId: req.UserId, + CreatedAt: utils.Now(), + } + if req.Name != nil { + row.Name = *req.Name + } + if req.Gender != nil && *req.Gender != utils.NumberZero { + row.Gender = int8(*req.Gender) + } + if req.Birthday != nil && *req.Birthday != utils.StringEmpty { + row.Birthday = dateOnly(*req.Birthday) + } + if err = remarkModel.Create(&row); err != nil { + l.Errorf("store user update create: %v", err) + return common.FailResponse(utils.Fail), nil + } + return common.OkResponse(nil), nil +} + +func replaceUserTags(storeId, userId int64, tags []string) error { + where := modelbase.Params{ + Eq: map[string]string{ + "user_id": strconv.FormatInt(userId, utils.NumberTen), + "store_id": strconv.FormatInt(storeId, utils.NumberTen), + }, + } + tagModel := model.UserImageTagModel{}.Init() + if _, err := tagModel.Edit(where, map[string]interface{}{ + "status": dao.StatusDisabled, + }); err != nil { + return err + } + + seen := make(map[string]struct{}, len(tags)) + for _, tag := range tags { + tag = strings.TrimSpace(tag) + if tag == utils.StringEmpty { + continue + } + if _, ok := seen[tag]; ok { + continue + } + seen[tag] = struct{}{} + if err := tagModel.Create(&dao.UserImageTag{ + StoreId: storeId, + UserId: userId, + Tag: tag, + Status: dao.StatusEnabled, + CreatedAt: utils.Now(), + }); err != nil { + return err + } + } + return nil +} diff --git a/services/analysis/internal/logic/analysisstore/storeView.go b/services/analysis/internal/logic/analysisstore/storeView.go new file mode 100644 index 0000000..a43be06 --- /dev/null +++ b/services/analysis/internal/logic/analysisstore/storeView.go @@ -0,0 +1,102 @@ +package analysisstorelogic + +import ( + "context" + "strconv" + "strings" + + "lone-services/pkg/utils" + analysis "lone-services/rpc/analysis/pb" + storepb "lone-services/rpc/store/pb" + "lone-services/services/analysis/internal/dao" + "lone-services/services/analysis/internal/logic/common" + "lone-services/services/analysis/internal/svc" + + "github.com/zeromicro/go-zero/core/logx" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func loadPassedStore(ctx context.Context, storeId int64) (*storepb.InfoResponse, *analysis.Response) { + if storeId < utils.NumberOne { + return nil, common.OutResponse(utils.ErrorParams, "门店信息不存在") + } + svcName := utils.GetConfigString("services.store") + if svcName == utils.StringEmpty { + return nil, common.FailResponse(utils.Fail) + } + cli, err := svc.GetRpcClient(svcName) + if err != nil { + logx.WithContext(ctx).Errorf("store info rpc: %v", err) + return nil, common.FailResponse(utils.Fail) + } + info, err := storepb.NewStoreClient(cli.Conn()).GetInfoById(ctx, &storepb.IdRequest{Id: storeId}) + if err != nil { + logx.WithContext(ctx).Errorf("store info get: %v", err) + if st, ok := status.FromError(err); ok && (st.Code() == codes.NotFound || st.Message() == utils.ErrorNotFund.Msg) { + return nil, common.FailResponse(utils.ErrorNotFund) + } + return nil, common.FailResponse(utils.Fail) + } + if info == nil || info.Id < utils.NumberOne || info.Status != int32(utils.StatusOk) { + return nil, common.FailResponse(utils.ErrorNotFund) + } + return info, nil +} + +func skinStore(info *storepb.InfoResponse) dao.StoreSkinInfo { + img, _ := utils.BuildImageURL(info.Images).(string) + return dao.StoreSkinInfo{ + Id: info.Id, + StoreName: info.Name, + StoreUserName: info.UserName, + StoreUserMobile: utils.DecryptPhoneReplace(info.UserMobile), + District: info.DistrictIds, + Address: regionAddress(info), + StoreImg: img, + StoreContact: info.Contact, + StoreContent: info.Content, + OpenTime: info.OpenTime, + LongitudeWgs84: info.LongitudeWgs84, + LatitudeWgs84: info.LatitudeWgs84, + LongitudeGcj02: info.LongitudeGcj02, + LatitudeGcj02: info.LatitudeGcj02, + CreateTime: info.CreateTime, + } +} + +func regionAddress(info *storepb.InfoResponse) string { + parts := make([]string, 0, 3) + for _, name := range []string{info.ProvinceName, info.CityName, info.CountyName} { + if name != utils.StringEmpty { + parts = append(parts, name) + } + } + return strings.Join(parts, "") + info.Address +} + +func imageURL(path string) string { + if path == utils.StringEmpty { + return utils.StringEmpty + } + url, _ := utils.BuildImageURL(path).(string) + return url +} + +func dateOnly(value string) string { + if len(value) >= len("2006-01-02") { + return value[:len("2006-01-02")] + } + return value +} + +func idStrings(ids []int64) []string { + out := make([]string, 0, len(ids)) + for _, id := range ids { + if id < utils.NumberOne { + continue + } + out = append(out, strconv.FormatInt(id, utils.NumberTen)) + } + return out +} diff --git a/services/analysis/internal/model/remark.go b/services/analysis/internal/model/remark.go new file mode 100644 index 0000000..0688e86 --- /dev/null +++ b/services/analysis/internal/model/remark.go @@ -0,0 +1,23 @@ +package model + +import ( + "lone-services/pkg/modelbase" + "lone-services/services/analysis/internal/dao" +) + +type UserRemarkModel struct { + modelbase.Base +} + +func (m UserRemarkModel) TableName() string { + return modelbase.Prefix() + "user_remarks" +} + +func (m UserRemarkModel) Init() UserRemarkModel { + m.Table = m.TableName() + return m +} + +func (m UserRemarkModel) Create(data *dao.UserRemark) error { + return m.Base.Create(data) +} diff --git a/services/analysis/internal/model/user_image_log.go b/services/analysis/internal/model/user_image_log.go new file mode 100644 index 0000000..c0192b6 --- /dev/null +++ b/services/analysis/internal/model/user_image_log.go @@ -0,0 +1,16 @@ +package model + +import "lone-services/pkg/modelbase" + +type UserImageLogModel struct { + modelbase.Base +} + +func (m UserImageLogModel) TableName() string { + return modelbase.Prefix() + "user_images_log" +} + +func (m UserImageLogModel) Init() UserImageLogModel { + m.Table = m.TableName() + return m +} diff --git a/services/analysis/internal/model/user_image_tag.go b/services/analysis/internal/model/user_image_tag.go new file mode 100644 index 0000000..f97ec96 --- /dev/null +++ b/services/analysis/internal/model/user_image_tag.go @@ -0,0 +1,23 @@ +package model + +import ( + "lone-services/pkg/modelbase" + "lone-services/services/analysis/internal/dao" +) + +type UserImageTagModel struct { + modelbase.Base +} + +func (m UserImageTagModel) TableName() string { + return modelbase.Prefix() + "user_images_tag" +} + +func (m UserImageTagModel) Init() UserImageTagModel { + m.Table = m.TableName() + return m +} + +func (m UserImageTagModel) Create(data *dao.UserImageTag) error { + return m.Base.Create(data) +} diff --git a/services/analysis/internal/server/analysisstore/analysisStoreServer.go b/services/analysis/internal/server/analysisstore/analysisStoreServer.go index 098d75b..5697fc4 100644 --- a/services/analysis/internal/server/analysisstore/analysisStoreServer.go +++ b/services/analysis/internal/server/analysisstore/analysisStoreServer.go @@ -32,3 +32,28 @@ func (s *AnalysisStoreServer) StoreAuthQrcode(ctx context.Context, in *analysis. l := analysisstorelogic.NewStoreAuthQrcodeLogic(ctx, s.svcCtx) return l.StoreAuthQrcode(in) } + +func (s *AnalysisStoreServer) StoreInfo(ctx context.Context, in *analysis.StoreInfoReq) (*analysis.Response, error) { + l := analysisstorelogic.NewStoreInfoLogic(ctx, s.svcCtx) + return l.StoreInfo(in) +} + +func (s *AnalysisStoreServer) StoreDetail(ctx context.Context, in *analysis.StoreDetailReq) (*analysis.Response, error) { + l := analysisstorelogic.NewStoreDetailLogic(ctx, s.svcCtx) + return l.StoreDetail(in) +} + +func (s *AnalysisStoreServer) StoreUserList(ctx context.Context, in *analysis.StoreUserListReq) (*analysis.Response, error) { + l := analysisstorelogic.NewStoreUserListLogic(ctx, s.svcCtx) + return l.StoreUserList(in) +} + +func (s *AnalysisStoreServer) StoreUserUpdate(ctx context.Context, in *analysis.StoreUserUpdateReq) (*analysis.Response, error) { + l := analysisstorelogic.NewStoreUserUpdateLogic(ctx, s.svcCtx) + return l.StoreUserUpdate(in) +} + +func (s *AnalysisStoreServer) StoreUserInfo(ctx context.Context, in *analysis.StoreUserInfoReq) (*analysis.Response, error) { + l := analysisstorelogic.NewStoreUserInfoLogic(ctx, s.svcCtx) + return l.StoreUserInfo(in) +} diff --git a/services/analysis/validator/user.go b/services/analysis/validator/user.go index 94a5f4f..1e4229e 100644 --- a/services/analysis/validator/user.go +++ b/services/analysis/validator/user.go @@ -127,6 +127,60 @@ func (p DeviceBindValidator) GetMessage() validate.ValidatorMessages { } } +type StoreInfoValidator struct { + Id int64 `validate:"required,gt=0"` +} + +func (p StoreInfoValidator) GetMessage() validate.ValidatorMessages { + return validate.ValidatorMessages{ + "Id.required": "id 必传", + "Id.gt": "id 必传", + } +} + +type StoreUserListValidator struct { + Gender int32 `validate:"omitempty,oneof=0 1 2 3"` + AgeMin int32 `validate:"omitempty,gte=0"` + AgeMax int32 `validate:"omitempty,gte=0"` + Page int32 `validate:"omitempty,gte=0"` + Size int32 `validate:"omitempty,gte=0,lte=100"` +} + +func (p StoreUserListValidator) GetMessage() validate.ValidatorMessages { + return validate.ValidatorMessages{ + "Gender.oneof": "性别不正确", + "Size.lte": "每页数量过大", + } +} + +type StoreUserUpdateValidator struct { + UserId int64 `validate:"required,gt=0"` + Gender *int32 `validate:"omitempty,oneof=0 1 2 3"` + Name *string `validate:"omitempty,max=64"` + Birthday *string `validate:"omitempty,max=32"` +} + +func (p StoreUserUpdateValidator) GetMessage() validate.ValidatorMessages { + return validate.ValidatorMessages{ + "UserId.required": "user_id 必传", + "UserId.gt": "user_id 必传", + "Gender.oneof": "性别不正确", + "Name.max": "名称过长", + "Birthday.max": "生日过长", + } +} + +type StoreUserInfoValidator struct { + UserId int64 `validate:"required,gt=0"` +} + +func (p StoreUserInfoValidator) GetMessage() validate.ValidatorMessages { + return validate.ValidatorMessages{ + "UserId.required": "user_id 必传", + "UserId.gt": "user_id 必传", + } +} + type UserAuthUpdateValidator struct { Id int64 `validate:"required,gt=0"` ValidityTime string `validate:"required,max=32"` diff --git a/services/sale/internal/logic/apiLowerSaleItemsLogic.go b/services/sale/internal/logic/apiLowerSaleItemsLogic.go index fb5d6d5..c135e7d 100644 --- a/services/sale/internal/logic/apiLowerSaleItemsLogic.go +++ b/services/sale/internal/logic/apiLowerSaleItemsLogic.go @@ -45,7 +45,7 @@ func (l *ApiLowerSaleItemsLogic) ApiLowerSaleItems(in *sale.ApiLowerSaleItemsReq Page: int(in.Page), Size: int(in.Size), Order: "id desc", - Eq: map[string]string{"sale_id": strconv.FormatInt(adminInfo.ID, utils.NumberTen)}, + Eq: map[string]string{"sale_id": strconv.FormatInt(adminInfo.BizId, utils.NumberTen)}, In: map[string][]string{ "status": { utils.StringStatusOk, diff --git a/services/sale/internal/logic/apiSaleAddLogic.go b/services/sale/internal/logic/apiSaleAddLogic.go index 758723d..0ea4e8a 100644 --- a/services/sale/internal/logic/apiSaleAddLogic.go +++ b/services/sale/internal/logic/apiSaleAddLogic.go @@ -11,7 +11,7 @@ import ( "lone-services/services/sale/validator" "strconv" - "lone-services/rpc/sale/pb" + sale "lone-services/rpc/sale/pb" "lone-services/services/sale/internal/svc" "github.com/zeromicro/go-zero/core/logx" @@ -105,7 +105,7 @@ func (l *ApiSaleAddLogic) ApiSaleAdd(in *sale.ApiSaleAddReq) (*sale.Response, er } data := dao.SaleCreate{ - SaleId: adminInfo.ID, + SaleId: adminInfo.BizId, Mobile: encryptMobile, Name: in.Name, IdCardFront: in.IdCardFront, diff --git a/services/store/internal/dao/store.go b/services/store/internal/dao/store.go index bd7a519..266bec2 100644 --- a/services/store/internal/dao/store.go +++ b/services/store/internal/dao/store.go @@ -86,6 +86,7 @@ type StoreInfo struct { City int64 `json:"city" gorm:"city"` CityName string `json:"city_name" gorm:"city_name"` County int64 `json:"county" gorm:"county"` + CountyName string `json:"county_name" gorm:"county_name"` Contact string `gorm:"column:contact;type:varchar(255);comment:联系方式,多个,号分割" json:"contact"` Content string `gorm:"column:content;type:text" json:"content"` OpenTime string `gorm:"column:open_time;type:varchar(100);comment:营业时间" json:"open_time"` diff --git a/services/store/internal/logic/getInfoByIdLogic.go b/services/store/internal/logic/getInfoByIdLogic.go index 349d915..75b177e 100644 --- a/services/store/internal/logic/getInfoByIdLogic.go +++ b/services/store/internal/logic/getInfoByIdLogic.go @@ -55,20 +55,34 @@ func (l *GetInfoByIdLogic) GetInfoById(in *store.IdRequest) (*store.InfoResponse return &store.InfoResponse{ Id: info.Id, Name: info.Name, + UserName: info.UserName, Contact: info.Contact, UserMobile: info.UserMobile, IdCard: info.IdCard, BusinessLicense: info.BusinessLicense, Images: info.Images, + StoreImages: info.StoreImages, Content: info.Content, OpenTime: info.OpenTime, Address: info.Address, + Province: info.Province, + ProvinceName: info.ProvinceName, City: info.City, + CityName: info.CityName, County: info.County, + CountyName: info.CountyName, DistrictIds: info.District, Area: info.Area, BankInfo: info.BankInfo, + Type: info.Type, + SaleId: info.SaleId, + LongitudeWgs84: info.LongitudeWgs84, + LatitudeWgs84: info.LatitudeWgs84, + LongitudeGcj02: info.LongitudeGcj02, + LatitudeGcj02: info.LatitudeGcj02, BuyAmount: info.BuyAmount, ResidualNumber: info.ResidualNumber, + Status: info.Status, + CreateTime: info.CreateTime.String(), }, nil } diff --git a/services/store/internal/logic/getInfoByIdsLogic.go b/services/store/internal/logic/getInfoByIdsLogic.go index 77feb95..cb7368c 100644 --- a/services/store/internal/logic/getInfoByIdsLogic.go +++ b/services/store/internal/logic/getInfoByIdsLogic.go @@ -54,21 +54,35 @@ func (l *GetInfoByIdsLogic) GetInfoByIds(in *store.IdsRequest) (*store.ItemsResp items = append(items, &store.InfoResponse{ Id: item.Id, Name: item.Name, + UserName: item.UserName, Contact: item.Contact, UserMobile: mobile, IdCard: item.IdCard, BusinessLicense: item.BusinessLicense, Images: item.Images, + StoreImages: item.StoreImages, Content: item.Content, OpenTime: item.OpenTime, Address: item.Address, + Province: item.Province, + ProvinceName: item.ProvinceName, City: item.City, + CityName: item.CityName, County: item.County, + CountyName: item.CountyName, DistrictIds: item.District, Area: item.Area, BankInfo: item.BankInfo, + Type: item.Type, + SaleId: item.SaleId, + LongitudeWgs84: item.LongitudeWgs84, + LatitudeWgs84: item.LatitudeWgs84, + LongitudeGcj02: item.LongitudeGcj02, + LatitudeGcj02: item.LatitudeGcj02, BuyAmount: item.BuyAmount, ResidualNumber: item.ResidualNumber, + Status: item.Status, + CreateTime: item.CreateTime.String(), }) } diff --git a/services/store/internal/logic/webCheckPayPasswordLogic.go b/services/store/internal/logic/webCheckPayPasswordLogic.go index a911f7a..961f397 100644 --- a/services/store/internal/logic/webCheckPayPasswordLogic.go +++ b/services/store/internal/logic/webCheckPayPasswordLogic.go @@ -4,11 +4,11 @@ import ( "context" "lone-services/pkg/modelbase" "lone-services/pkg/utils" + store "lone-services/rpc/store/pb" "lone-services/services/store/internal/dao" "lone-services/services/store/internal/model" "strconv" - "lone-services/rpc/store/pb" "lone-services/services/store/internal/svc" "github.com/zeromicro/go-zero/core/logx" @@ -36,7 +36,7 @@ func (l *WebCheckPayPasswordLogic) WebCheckPayPassword(in *store.EmptyRequest) ( } var info dao.StoreWebPassword - w := modelbase.Params{Eq: map[string]string{"id": strconv.FormatInt(adminInfo.ID, utils.NumberTen)}} + w := modelbase.Params{Eq: map[string]string{"id": strconv.FormatInt(adminInfo.BizId, utils.NumberTen)}} err := model.StoreModel{}.Init().GetOne(w, &info) if err != nil { l.Logger.Error(err) diff --git a/services/store/internal/logic/webDepositCreateLogic.go b/services/store/internal/logic/webDepositCreateLogic.go index 9422cec..c40e95f 100644 --- a/services/store/internal/logic/webDepositCreateLogic.go +++ b/services/store/internal/logic/webDepositCreateLogic.go @@ -7,7 +7,7 @@ import ( "lone-services/services/store/internal/model" "lone-services/services/store/validator" - "lone-services/rpc/store/pb" + store "lone-services/rpc/store/pb" "lone-services/services/store/internal/svc" "github.com/zeromicro/go-zero/core/logx" @@ -39,7 +39,7 @@ func (l *WebDepositCreateLogic) WebDepositCreate(in *store.WebDepositCreateReque } info := dao.DepositCreate{ - StoreId: adminInfo.ID, + StoreId: adminInfo.BizId, Amount: in.Amount, Bill: in.Bill, Status: utils.StatusWaitPass, diff --git a/services/store/internal/logic/webDepositItemsLogic.go b/services/store/internal/logic/webDepositItemsLogic.go index a3d858c..8f099bf 100644 --- a/services/store/internal/logic/webDepositItemsLogic.go +++ b/services/store/internal/logic/webDepositItemsLogic.go @@ -4,7 +4,7 @@ import ( "context" "lone-services/pkg/modelbase" "lone-services/pkg/utils" - "lone-services/rpc/store/pb" + store "lone-services/rpc/store/pb" "lone-services/services/store/internal/dao" "lone-services/services/store/internal/model" "lone-services/services/store/internal/svc" @@ -41,7 +41,7 @@ func (l *WebDepositItemsLogic) WebDepositItems(in *store.WebDepositItemsRequest) var info []dao.DepositWebInfo w := modelbase.Params{ - Eq: map[string]string{"store_id": strconv.FormatInt(adminInfo.ID, utils.NumberTen)}, + Eq: map[string]string{"store_id": strconv.FormatInt(adminInfo.BizId, utils.NumberTen)}, Page: int(in.Page), Size: int(in.Size), Order: "id desc", diff --git a/services/store/internal/logic/webInfoLogic.go b/services/store/internal/logic/webInfoLogic.go index ea69c13..fe979b4 100644 --- a/services/store/internal/logic/webInfoLogic.go +++ b/services/store/internal/logic/webInfoLogic.go @@ -8,7 +8,7 @@ import ( "lone-services/services/store/internal/model" "strconv" - "lone-services/rpc/store/pb" + store "lone-services/rpc/store/pb" "lone-services/services/store/internal/svc" "github.com/zeromicro/go-zero/core/logx" @@ -36,7 +36,7 @@ func (l *WebInfoLogic) WebInfo(in *store.EmptyRequest) (*store.Response, error) } var info dao.StoreInfo modelObj := model.StoreModel{}.Init() - w := modelbase.Params{Eq: map[string]string{"id": strconv.FormatInt(adminInfo.ID, utils.NumberTen)}} + w := modelbase.Params{Eq: map[string]string{"id": strconv.FormatInt(adminInfo.BizId, utils.NumberTen)}} err := modelObj.GetOne(w, &info) if err != nil { l.Logger.Error(err) diff --git a/services/store/internal/logic/webLowerStoreItemsLogic.go b/services/store/internal/logic/webLowerStoreItemsLogic.go index fb0608f..1669b5c 100644 --- a/services/store/internal/logic/webLowerStoreItemsLogic.go +++ b/services/store/internal/logic/webLowerStoreItemsLogic.go @@ -11,7 +11,7 @@ import ( "strconv" "strings" - "lone-services/rpc/store/pb" + store "lone-services/rpc/store/pb" "lone-services/services/store/internal/svc" "github.com/samber/lo" @@ -46,7 +46,7 @@ func (l *WebLowerStoreItemsLogic) WebLowerStoreItems(in *store.WebLowerStoreItem return l.fail(utils.ErrorNoLogin) } - saleId := adminInfo.ID + saleId := adminInfo.BizId if in.SaleId > utils.NumberZero { saleId = in.SaleId } diff --git a/services/store/internal/logic/webPayMoneyLogic.go b/services/store/internal/logic/webPayMoneyLogic.go index cd20c39..acbc008 100644 --- a/services/store/internal/logic/webPayMoneyLogic.go +++ b/services/store/internal/logic/webPayMoneyLogic.go @@ -4,11 +4,11 @@ import ( "context" "lone-services/pkg/modelbase" "lone-services/pkg/utils" + store "lone-services/rpc/store/pb" "lone-services/services/store/internal/dao" "lone-services/services/store/internal/model" "strconv" - "lone-services/rpc/store/pb" "lone-services/services/store/internal/svc" "github.com/zeromicro/go-zero/core/logx" @@ -36,7 +36,7 @@ func (l *WebPayMoneyLogic) WebPayMoney(in *store.EmptyRequest) (*store.Response, } var info dao.StoreInfo modelObj := model.StoreModel{}.Init() - w := modelbase.Params{Eq: map[string]string{"id": strconv.FormatInt(adminInfo.ID, utils.NumberTen)}} + w := modelbase.Params{Eq: map[string]string{"id": strconv.FormatInt(adminInfo.BizId, utils.NumberTen)}} err := modelObj.GetOne(w, &info) if err != nil { l.Logger.Error(err) diff --git a/services/store/internal/logic/webSetPayPasswordLogic.go b/services/store/internal/logic/webSetPayPasswordLogic.go index 066dfb6..f192cc6 100644 --- a/services/store/internal/logic/webSetPayPasswordLogic.go +++ b/services/store/internal/logic/webSetPayPasswordLogic.go @@ -9,7 +9,7 @@ import ( "lone-services/services/store/validator" "strconv" - "lone-services/rpc/store/pb" + store "lone-services/rpc/store/pb" "lone-services/services/store/internal/svc" "github.com/zeromicro/go-zero/core/logx" @@ -41,7 +41,7 @@ func (l *WebSetPayPasswordLogic) WebSetPayPassword(in *store.WebSetPayPasswordRe } var info dao.StoreWebPassword - w := modelbase.Params{Eq: map[string]string{"id": strconv.FormatInt(adminInfo.ID, utils.NumberTen)}} + w := modelbase.Params{Eq: map[string]string{"id": strconv.FormatInt(adminInfo.BizId, utils.NumberTen)}} modelObj := model.StoreModel{}.Init() err := modelObj.GetOne(w, &info) if err != nil { diff --git a/services/store/internal/logic/webStoreAddLogic.go b/services/store/internal/logic/webStoreAddLogic.go index 3bc78db..1be878b 100644 --- a/services/store/internal/logic/webStoreAddLogic.go +++ b/services/store/internal/logic/webStoreAddLogic.go @@ -6,7 +6,7 @@ import ( "lone-services/pkg/wecomrpc" chore "lone-services/rpc/chore/pb" sale "lone-services/rpc/sale/pb" - "lone-services/rpc/store/pb" + store "lone-services/rpc/store/pb" user "lone-services/rpc/user/pb" "lone-services/services/store/internal/dao" "lone-services/services/store/internal/model" @@ -72,7 +72,7 @@ func (l *WebStoreAddLogic) WebStoreAdd(in *store.WebStoreAddReq) (*store.Respons return l.fail(utils.SetError(utils.Fail, cErr.GetMsg())) } - groupId, sErr := l.getSaleInfo(adminInfo.ID) + groupId, sErr := l.getSaleInfo(adminInfo.BizId) if sErr != utils.Ok { return l.fail(sErr) } @@ -96,7 +96,7 @@ func (l *WebStoreAddLogic) WebStoreAdd(in *store.WebStoreAddReq) (*store.Respons LatitudeWgs84: v.LatitudeWgs84, LongitudeGcj02: v.LongitudeGcj02, LatitudeGcj02: v.LatitudeGcj02, - SaleId: adminInfo.ID, + SaleId: adminInfo.BizId, UserMobile: encryptMobile, Name: v.Name, BankInfo: v.BankInfo, diff --git a/services/store/internal/server/storeServer.go b/services/store/internal/server/storeServer.go index b963351..7ff9e8a 100644 --- a/services/store/internal/server/storeServer.go +++ b/services/store/internal/server/storeServer.go @@ -1,5 +1,5 @@ // Code generated by goctl. DO NOT EDIT. -// goctl 1.10.2 +// goctl 1.10.1 // Source: store.proto package server diff --git a/services/store/storeclient/store.go b/services/store/storeclient/store.go index 7cacfba..33a7a32 100644 --- a/services/store/storeclient/store.go +++ b/services/store/storeclient/store.go @@ -1,5 +1,5 @@ // Code generated by goctl. DO NOT EDIT. -// goctl 1.10.2 +// goctl 1.10.1 // Source: store.proto package storeClient diff --git a/services/user/internal/dao/session.go b/services/user/internal/dao/session.go index 7fbaec3..4a7069c 100644 --- a/services/user/internal/dao/session.go +++ b/services/user/internal/dao/session.go @@ -24,14 +24,15 @@ type UserLoginSession struct { } type ProfileData struct { - Type uint8 `json:"type"` - Base ProfileBase `json:"base"` - Sale *ProfileSaleData `json:"sale,omitempty"` - Store any `json:"store,omitempty"` + Type uint8 `json:"type"` + Base ProfileBase `json:"base"` + Detail *ProfileDetail `json:"detail,omitempty"` + Sale *ProfileSaleData `json:"sale,omitempty"` + Store any `json:"store,omitempty"` } type ProfileBase struct { - UserId int64 `json:"user_id"` + Id int64 `json:"id"` Name string `json:"name"` Avatar string `json:"avatar"` Mobile string `json:"mobile"` diff --git a/services/user/internal/dao/user_detail.go b/services/user/internal/dao/user_detail.go new file mode 100644 index 0000000..1352d54 --- /dev/null +++ b/services/user/internal/dao/user_detail.go @@ -0,0 +1,23 @@ +package dao + +import "lone-services/pkg/utils" + +type UserDetail struct { + Id int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"` + UserId int64 `gorm:"column:user_id" json:"user_id"` + RealName string `gorm:"column:real_name" json:"real_name"` + IdCard string `gorm:"column:id_card" json:"id_card"` + CreatedAt utils.CustomTime `gorm:"column:created_at" json:"created_at"` + UpdatedAt utils.CustomTime `gorm:"column:updated_at" json:"updated_at"` +} + +type UserDetailCreate struct { + Id int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"` + UserId int64 `gorm:"column:user_id" json:"user_id"` + RealName string `gorm:"column:real_name" json:"real_name"` + IdCard string `gorm:"column:id_card" json:"id_card"` +} + +type ProfileDetail struct { + RealName string `json:"real_name"` +} diff --git a/services/user/internal/logic/authHelper.go b/services/user/internal/logic/authHelper.go index 2738e47..95ba07d 100644 --- a/services/user/internal/logic/authHelper.go +++ b/services/user/internal/logic/authHelper.go @@ -110,6 +110,9 @@ func resolveOrCreateWechatUser(ctx context.Context, db *gorm.DB, openid, unionid if openCred.Status == dao.StatusDisabled { return utils.NumberZero, status.Error(codes.FailedPrecondition, "登录凭证已禁用") } + if err := ensureUserDetail(db, openCred.UserId); err != nil { + return utils.NumberZero, err + } if err := ensureUserClient(db, openCred.UserId, clientCode, utils.NumberZero); err != nil { return utils.NumberZero, err } @@ -141,6 +144,9 @@ func resolveOrCreateWechatUser(ctx context.Context, db *gorm.DB, openid, unionid userId = add.Id } + if err := ensureUserDetail(tx, userId); err != nil { + return err + } if err := createWechatCredentials(tx, userId, openid, unionid, subjectType); err != nil { return err } diff --git a/services/user/internal/logic/bizUser.go b/services/user/internal/logic/bizUser.go index 9d6abf5..8db8efb 100644 --- a/services/user/internal/logic/bizUser.go +++ b/services/user/internal/logic/bizUser.go @@ -2,7 +2,6 @@ package logic import ( "context" - "fmt" "strconv" "lone-services/pkg/modelbase" @@ -39,7 +38,7 @@ func ensureClientBizUser(ctx context.Context, svcCtx *svc.ServiceContext, userId return err } if bizId < utils.NumberOne { - return status.Error(codes.Internal, "业务用户创建失败") + return nil } _, err = model.UserClientModel{}.Init().Edit(modelbase.Params{ @@ -55,7 +54,7 @@ func createBizUser(ctx context.Context, svcCtx *svc.ServiceContext, serviceKey s case "user_skin": return createAnalysisBizUser(ctx, svcCtx.AnalysisSvcName) default: - return utils.NumberZero, status.Error(codes.InvalidArgument, fmt.Sprintf("unsupported biz_user service: %s", serviceKey)) + return utils.NumberZero, nil } } diff --git a/services/user/internal/logic/infoLogic.go b/services/user/internal/logic/infoLogic.go index e1d42cd..1f7a6c1 100644 --- a/services/user/internal/logic/infoLogic.go +++ b/services/user/internal/logic/infoLogic.go @@ -45,7 +45,7 @@ func (l *InfoLogic) Info(in *user.InfoReq) (*user.Response, error) { ret := dao.ProfileData{ Type: userType, Base: dao.ProfileBase{ - UserId: row.Id, + Id: row.Id, Name: row.Name, Avatar: row.Avatar, Mobile: mobile, @@ -55,6 +55,17 @@ func (l *InfoLogic) Info(in *user.InfoReq) (*user.Response, error) { }, } + detail, detailErr := loadUserDetail(row.Id) + if detailErr != nil { + l.Errorf("info load detail: %v", detailErr) + return failResponse(utils.Fail), nil + } + if detail != nil { + ret.Detail = &dao.ProfileDetail{RealName: detail.RealName} + } else { + ret.Detail = &dao.ProfileDetail{} + } + switch userType { case dao.TypeUser: return okResponse(ret), nil diff --git a/services/user/internal/logic/internalCreateLogic.go b/services/user/internal/logic/internalCreateLogic.go index dd543a3..288c50c 100644 --- a/services/user/internal/logic/internalCreateLogic.go +++ b/services/user/internal/logic/internalCreateLogic.go @@ -118,6 +118,10 @@ func (l *InternalCreateLogic) InternalCreate(in *user.InternalCreateReq) (*user. userId = add.Id } + if err := ensureUserDetail(tx, userId); err != nil { + return err + } + for _, subjectType := range subjectTypes { for _, credType := range credentialTypes { if err := ensureCredential(tx, userId, credType, req.Identifier, req.Secret, encryptMobile, subjectType); err != nil { diff --git a/services/user/internal/logic/internalUsersByBizLogic.go b/services/user/internal/logic/internalUsersByBizLogic.go new file mode 100644 index 0000000..1aae3f3 --- /dev/null +++ b/services/user/internal/logic/internalUsersByBizLogic.go @@ -0,0 +1,139 @@ +package logic + +import ( + "context" + "strconv" + + "lone-services/pkg/modelbase" + "lone-services/pkg/utils" + "lone-services/pkg/validate" + user "lone-services/rpc/user/pb" + "lone-services/services/user/internal/dao" + "lone-services/services/user/internal/model" + "lone-services/services/user/internal/svc" + "lone-services/services/user/validator" + + "github.com/zeromicro/go-zero/core/logx" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +type InternalUsersByBizLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewInternalUsersByBizLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InternalUsersByBizLogic { + return &InternalUsersByBizLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *InternalUsersByBizLogic) InternalUsersByBiz(in *user.InternalUsersByBizReq) (*user.InternalUsersByBizData, error) { + var req validator.InternalUsersByBizValidator + if msg := validate.ValidateFromProto(in, &req); msg != utils.StringEmpty { + return nil, status.Error(codes.InvalidArgument, msg) + } + + hasFilter := req.Keyword != utils.StringEmpty || req.Gender > utils.NumberZero || req.BirthdayGte != utils.StringEmpty || req.BirthdayLte != utils.StringEmpty + if len(req.BizIds) == utils.NumberZero && !hasFilter { + return nil, status.Error(codes.InvalidArgument, "请指定用户或筛选条件") + } + + bizIds := make([]string, 0, len(req.BizIds)) + seenBiz := make(map[int64]struct{}, len(req.BizIds)) + for _, id := range req.BizIds { + if id < utils.NumberOne { + continue + } + if _, ok := seenBiz[id]; ok { + continue + } + seenBiz[id] = struct{}{} + bizIds = append(bizIds, strconv.FormatInt(id, utils.NumberTen)) + } + + clientWhere := modelbase.Params{ + Eq: map[string]string{ + "client_code": req.ClientCode, + "status": strconv.Itoa(int(dao.StatusEnabled)), + }, + } + if len(bizIds) > utils.NumberZero { + clientWhere.In = map[string][]string{"biz_id": bizIds} + } + + var clients []dao.UserClient + clientModel := model.UserClientModel{}.Init() + if err := clientModel.Items(clientWhere, &clients); err != nil { + l.Errorf("internal users by biz clients: %v", err) + return nil, status.Error(codes.Internal, utils.Fail.Msg) + } + if len(clients) == utils.NumberZero { + return &user.InternalUsersByBizData{Items: []*user.BizUserItem{}}, nil + } + + userIds := make([]string, 0, len(clients)) + bizByUser := make(map[int64]int64, len(clients)) + seenUser := make(map[int64]struct{}, len(clients)) + for _, row := range clients { + if row.UserId < utils.NumberOne || row.BizId < utils.NumberOne { + continue + } + bizByUser[row.UserId] = row.BizId + if _, ok := seenUser[row.UserId]; ok { + continue + } + seenUser[row.UserId] = struct{}{} + userIds = append(userIds, strconv.FormatInt(row.UserId, utils.NumberTen)) + } + if len(userIds) == utils.NumberZero { + return &user.InternalUsersByBizData{Items: []*user.BizUserItem{}}, nil + } + + userWhere := modelbase.Params{ + In: map[string][]string{"id": userIds}, + } + if req.Keyword != utils.StringEmpty { + userWhere.Like = map[string]string{"name LIKE ?": "%" + req.Keyword + "%"} + } + if req.Gender > utils.NumberZero { + if userWhere.Eq == nil { + userWhere.Eq = map[string]string{} + } + userWhere.Eq["gender"] = strconv.FormatUint(uint64(req.Gender), utils.NumberTen) + } + switch { + case req.BirthdayGte != utils.StringEmpty && req.BirthdayLte != utils.StringEmpty: + userWhere.Between = map[string][2]string{"birthday": {req.BirthdayGte, req.BirthdayLte}} + case req.BirthdayGte != utils.StringEmpty: + userWhere.Other = map[string]string{"birthday >= ?": req.BirthdayGte} + case req.BirthdayLte != utils.StringEmpty: + userWhere.Other = map[string]string{"birthday <= ?": req.BirthdayLte} + } + + var rows []dao.UserRow + userModel := model.UserModel{}.Init() + if err := userModel.Items(userWhere, &rows); err != nil { + l.Errorf("internal users by biz users: %v", err) + return nil, status.Error(codes.Internal, utils.Fail.Msg) + } + + items := make([]*user.BizUserItem, 0, len(rows)) + for i := range rows { + items = append(items, &user.BizUserItem{ + BizId: bizByUser[rows[i].Id], + UserId: rows[i].Id, + Mobile: rows[i].Mobile, + Name: rows[i].Name, + Avatar: rows[i].Avatar, + Gender: uint32(rows[i].Gender), + Birthday: rows[i].Birthday.DateString(), + Status: uint32(rows[i].Status), + }) + } + return &user.InternalUsersByBizData{Items: items}, nil +} diff --git a/services/user/internal/logic/updateLogic.go b/services/user/internal/logic/updateLogic.go new file mode 100644 index 0000000..88939cc --- /dev/null +++ b/services/user/internal/logic/updateLogic.go @@ -0,0 +1,144 @@ +package logic + +import ( + "context" + "strconv" + "time" + + "lone-services/pkg/modelbase" + "lone-services/pkg/utils" + "lone-services/pkg/validate" + user "lone-services/rpc/user/pb" + "lone-services/services/user/internal/dao" + "lone-services/services/user/internal/model" + "lone-services/services/user/internal/svc" + "lone-services/services/user/validator" + + "github.com/zeromicro/go-zero/core/logx" + "gorm.io/gorm" +) + +type UpdateLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateLogic { + return &UpdateLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *UpdateLogic) Update(in *user.UpdateReq) (*user.Response, error) { + var req validator.UpdateValidator + if msg := validate.ValidateFromProto(in, &req); msg != utils.StringEmpty { + return outResponse(utils.ErrorParams, msg), nil + } + if req.Birthday != utils.StringEmpty { + if _, err := time.ParseInLocation("2006-01-02", req.Birthday, time.Local); err != nil { + return outResponse(utils.ErrorParams, "生日格式不正确"), nil + } + } + + loginUser := utils.GetUserFromCtx(l.ctx) + if loginUser.ID < utils.NumberOne { + return failResponse(utils.ErrorNoLoginInfo), nil + } + + row, err := loadEnabledUser(loginUser.ID) + if err != nil { + l.Errorf("update load user: %v", err) + return failResponse(utils.ErrorNotFund), nil + } + + userUpdates := map[string]interface{}{} + if req.Name != utils.StringEmpty { + userUpdates["name"] = req.Name + } + if req.Avatar != utils.StringEmpty { + userUpdates["avatar"] = req.Avatar + } + if req.Gender > utils.NumberZero { + userUpdates["gender"] = uint8(req.Gender) + } + if req.Birthday != utils.StringEmpty { + userUpdates["birthday"] = req.Birthday + } + + if req.Mobile != utils.StringEmpty { + enc, encErr := utils.EncryptPhone(req.Mobile) + if encErr != nil { + l.Errorf("update encrypt mobile: %v", encErr) + return failResponse(utils.ErrorEncryptAesError), nil + } + if enc != row.Mobile { + occupied, occErr := findUserByMobile(enc) + if occErr != nil { + l.Errorf("update mobile unique: %v", occErr) + return failResponse(utils.Fail), nil + } + if occupied != nil && occupied.Id != row.Id { + return failResponse(utils.ErrorDataIsExist), nil + } + userUpdates["mobile"] = enc + } + } + + detailUpdates := map[string]interface{}{} + if req.RealName != utils.StringEmpty { + detailUpdates["real_name"] = req.RealName + } + + if len(userUpdates) == utils.NumberZero && len(detailUpdates) == utils.NumberZero { + return outResponse(utils.ErrorParams, "没有需要更新的字段"), nil + } + + txErr := l.svcCtx.DB.WithContext(l.ctx).Transaction(func(tx *gorm.DB) error { + if len(userUpdates) > utils.NumberZero { + userModel := model.UserModel{}.Init() + userModel.Base = userModel.Base.WithTX(tx) + if _, err := userModel.Edit(modelbase.Params{ + Eq: map[string]string{"id": strconv.FormatInt(row.Id, utils.NumberTen)}, + }, userUpdates); err != nil { + return err + } + } + + if err := ensureUserDetail(tx, row.Id); err != nil { + return err + } + if len(detailUpdates) > utils.NumberZero { + detailModel := model.UserDetailModel{}.Init() + detailModel.Base = detailModel.Base.WithTX(tx) + if _, err := detailModel.Edit(modelbase.Params{ + Eq: map[string]string{"user_id": strconv.FormatInt(row.Id, utils.NumberTen)}, + }, detailUpdates); err != nil { + return err + } + } + return nil + }) + if txErr != nil { + l.Errorf("update tx: %v", txErr) + return failResponse(utils.Fail), nil + } + + return okResponse(nil), nil +} + +func findUserByMobile(encryptMobile string) (*dao.UserRow, error) { + var row dao.UserRow + err := model.UserModel{}.Init().GetOne(modelbase.Params{ + Eq: map[string]string{"mobile": encryptMobile}, + }, &row) + if err != nil { + return nil, err + } + if row.Id < utils.NumberOne { + return nil, nil + } + return &row, nil +} diff --git a/services/user/internal/logic/userDetail.go b/services/user/internal/logic/userDetail.go new file mode 100644 index 0000000..55353b0 --- /dev/null +++ b/services/user/internal/logic/userDetail.go @@ -0,0 +1,54 @@ +package logic + +import ( + "strconv" + + "lone-services/pkg/modelbase" + "lone-services/pkg/utils" + "lone-services/services/user/internal/dao" + "lone-services/services/user/internal/model" + + "gorm.io/gorm" +) + +func ensureUserDetail(tx *gorm.DB, userId int64) error { + if userId < utils.NumberOne { + return nil + } + + detailModel := model.UserDetailModel{}.Init() + if tx != nil { + detailModel.Base = detailModel.Base.WithTX(tx) + } + + var exist dao.UserDetail + if err := detailModel.GetOne(modelbase.Params{ + Eq: map[string]string{"user_id": strconv.FormatInt(userId, utils.NumberTen)}, + }, &exist); err != nil { + return err + } + if exist.Id > utils.NumberZero { + return nil + } + + return detailModel.Create(&dao.UserDetailCreate{ + UserId: userId, + }) +} + +func loadUserDetail(userId int64) (*dao.UserDetail, error) { + if userId < utils.NumberOne { + return nil, nil + } + var row dao.UserDetail + err := model.UserDetailModel{}.Init().GetOne(modelbase.Params{ + Eq: map[string]string{"user_id": strconv.FormatInt(userId, utils.NumberTen)}, + }, &row) + if err != nil { + return nil, err + } + if row.Id < utils.NumberOne { + return nil, nil + } + return &row, nil +} diff --git a/services/user/internal/model/user_detail.go b/services/user/internal/model/user_detail.go new file mode 100644 index 0000000..9402a9c --- /dev/null +++ b/services/user/internal/model/user_detail.go @@ -0,0 +1,23 @@ +package model + +import ( + "lone-services/pkg/modelbase" + "lone-services/services/user/internal/dao" +) + +type UserDetailModel struct { + modelbase.Base +} + +func (m UserDetailModel) TableName() string { + return modelbase.Prefix() + "user_detail" +} + +func (m UserDetailModel) Init() UserDetailModel { + m.Table = m.TableName() + return m +} + +func (m UserDetailModel) Create(data *dao.UserDetailCreate) error { + return m.Base.Create(data) +} diff --git a/services/user/internal/server/userServer.go b/services/user/internal/server/userServer.go index b9ca5db..697fdae 100644 --- a/services/user/internal/server/userServer.go +++ b/services/user/internal/server/userServer.go @@ -48,6 +48,11 @@ func (s *UserServer) Info(ctx context.Context, in *user.InfoReq) (*user.Response return l.Info(in) } +func (s *UserServer) Update(ctx context.Context, in *user.UpdateReq) (*user.Response, error) { + l := logic.NewUpdateLogic(ctx, s.svcCtx) + return l.Update(in) +} + func (s *UserServer) Password(ctx context.Context, in *user.PasswordReq) (*user.Response, error) { l := logic.NewPasswordLogic(ctx, s.svcCtx) return l.Password(in) @@ -117,3 +122,8 @@ func (s *UserServer) InternalVerifyPassword(ctx context.Context, in *user.Intern l := logic.NewInternalVerifyPasswordLogic(ctx, s.svcCtx) return l.InternalVerifyPassword(in) } + +func (s *UserServer) InternalUsersByBiz(ctx context.Context, in *user.InternalUsersByBizReq) (*user.InternalUsersByBizData, error) { + l := logic.NewInternalUsersByBizLogic(ctx, s.svcCtx) + return l.InternalUsersByBiz(in) +} diff --git a/services/user/userClient/user.go b/services/user/userClient/user.go index ab50fb6..2bf1c49 100644 --- a/services/user/userClient/user.go +++ b/services/user/userClient/user.go @@ -14,6 +14,7 @@ import ( ) type ( + BizUserItem = user.BizUserItem ClientReq = user.ClientReq GenerateQrcodeReq = user.GenerateQrcodeReq GetOpenidReq = user.GetOpenidReq @@ -32,6 +33,8 @@ type ( InternalUpdateMobileData = user.InternalUpdateMobileData InternalUpdateMobileReq = user.InternalUpdateMobileReq InternalUpdateReq = user.InternalUpdateReq + InternalUsersByBizData = user.InternalUsersByBizData + InternalUsersByBizReq = user.InternalUsersByBizReq InternalUsersByIdsData = user.InternalUsersByIdsData InternalUsersByIdsReq = user.InternalUsersByIdsReq InternalVerifyPasswordData = user.InternalVerifyPasswordData @@ -41,6 +44,7 @@ type ( QrcodeLoginReq = user.QrcodeLoginReq QrcodeScanReq = user.QrcodeScanReq Response = user.Response + UpdateReq = user.UpdateReq UserBriefItem = user.UserBriefItem UserItemsReq = user.UserItemsReq UserStatusReq = user.UserStatusReq @@ -51,6 +55,7 @@ type ( QrcodeScan(ctx context.Context, in *QrcodeScanReq, opts ...grpc.CallOption) (*Response, error) QrcodeLogin(ctx context.Context, in *QrcodeLoginReq, opts ...grpc.CallOption) (*Response, error) Info(ctx context.Context, in *InfoReq, opts ...grpc.CallOption) (*Response, error) + Update(ctx context.Context, in *UpdateReq, opts ...grpc.CallOption) (*Response, error) Password(ctx context.Context, in *PasswordReq, opts ...grpc.CallOption) (*Response, error) GetOpenid(ctx context.Context, in *GetOpenidReq, opts ...grpc.CallOption) (*Response, error) Client(ctx context.Context, in *ClientReq, opts ...grpc.CallOption) (*Response, error) @@ -65,6 +70,7 @@ type ( InternalRevokeBizClient(ctx context.Context, in *InternalRevokeBizClientReq, opts ...grpc.CallOption) (*InternalRevokeBizClientData, error) InternalGetUserInfo(ctx context.Context, in *InternalGetUserInfoReq, opts ...grpc.CallOption) (*InternalGetUserInfoData, error) InternalVerifyPassword(ctx context.Context, in *InternalVerifyPasswordReq, opts ...grpc.CallOption) (*InternalVerifyPasswordData, error) + InternalUsersByBiz(ctx context.Context, in *InternalUsersByBizReq, opts ...grpc.CallOption) (*InternalUsersByBizData, error) } defaultUser struct { @@ -103,6 +109,11 @@ func (m *defaultUser) Info(ctx context.Context, in *InfoReq, opts ...grpc.CallOp return client.Info(ctx, in, opts...) } +func (m *defaultUser) Update(ctx context.Context, in *UpdateReq, opts ...grpc.CallOption) (*Response, error) { + client := user.NewUserClient(m.cli.Conn()) + return client.Update(ctx, in, opts...) +} + func (m *defaultUser) Password(ctx context.Context, in *PasswordReq, opts ...grpc.CallOption) (*Response, error) { client := user.NewUserClient(m.cli.Conn()) return client.Password(ctx, in, opts...) @@ -172,3 +183,8 @@ func (m *defaultUser) InternalVerifyPassword(ctx context.Context, in *InternalVe client := user.NewUserClient(m.cli.Conn()) return client.InternalVerifyPassword(ctx, in, opts...) } + +func (m *defaultUser) InternalUsersByBiz(ctx context.Context, in *InternalUsersByBizReq, opts ...grpc.CallOption) (*InternalUsersByBizData, error) { + client := user.NewUserClient(m.cli.Conn()) + return client.InternalUsersByBiz(ctx, in, opts...) +} diff --git a/services/user/validator/user.go b/services/user/validator/user.go index ef8903e..c0baa02 100644 --- a/services/user/validator/user.go +++ b/services/user/validator/user.go @@ -60,6 +60,26 @@ func (p LoginValidator) GetMessage() validate.ValidatorMessages { } } +type UpdateValidator struct { + Name string `validate:"omitempty,max=64"` + Avatar string `validate:"omitempty,max=512"` + Gender uint32 `validate:"omitempty,oneof=0 1 2 3"` + Birthday string `validate:"omitempty,max=32"` + Mobile string `validate:"omitempty,len=11"` + RealName string `validate:"omitempty,max=64"` +} + +func (p UpdateValidator) GetMessage() validate.ValidatorMessages { + return validate.ValidatorMessages{ + "Name.max": "昵称过长", + "Avatar.max": "头像地址过长", + "Gender.oneof": "性别不正确", + "Birthday.max": "生日过长", + "Mobile.len": "手机号格式不正确", + "RealName.max": "真实姓名过长", + } +} + type PasswordValidator struct { OldPassword string `validate:"required,max=64"` Password string `validate:"required,min=6,max=64"` @@ -152,6 +172,23 @@ func (p InternalGetUserInfoValidator) GetMessage() validate.ValidatorMessages { } } +type InternalUsersByBizValidator struct { + ClientCode string `validate:"required,max=64"` + BizIds []int64 `validate:"omitempty,dive,gt=0"` + Keyword string `validate:"omitempty,max=64"` + Gender uint32 `validate:"omitempty,oneof=0 1 2 3"` + BirthdayGte string `validate:"omitempty,max=32"` + BirthdayLte string `validate:"omitempty,max=32"` +} + +func (p InternalUsersByBizValidator) GetMessage() validate.ValidatorMessages { + return validate.ValidatorMessages{ + "ClientCode.required": "客户端不能为空", + "ClientCode.max": "客户端过长", + "Gender.oneof": "性别不正确", + } +} + type InternalUsersByIdsValidator struct { Ids []int64 `validate:"required,min=1,dive,gt=0"` }