From 15a56163084511ca03f12e3f0ab1e9aacc102950 Mon Sep 17 00:00:00 2001 From: zzw <1464003642@qq.com> Date: Wed, 4 Nov 2026 11:46:54 +0800 Subject: [PATCH] feat: scan graph --- rpc/analysis/analysis.pb | Bin 21526 -> 23800 bytes rpc/analysis/analysis.proto | 148 +++ rpc/analysis/pb/analysis.pb.go | 1046 +++++++++++++++-- rpc/analysis/pb/analysis_grpc.pb.go | 420 ++++++- rpc/user/pb/user.pb.go | 18 +- rpc/user/user.pb | Bin 20084 -> 20109 bytes rpc/user/user.proto | 2 + .../client/analysisadmin/analysisAdmin.go | 77 ++ .../client/analysisuser/analysisUser.go | 2 - .../analysis/internal/callback/faceback.go | 3 +- services/analysis/internal/dao/authorize.go | 27 + services/analysis/internal/dao/graph.go | 11 +- services/analysis/internal/dao/remark.go | 1 + services/analysis/internal/dao/store.go | 13 + services/analysis/internal/dao/view.go | 22 + .../logic/analysisadmin/bindStoreLogic.go | 142 +++ .../logic/analysisadmin/bindUserLogic.go | 162 +++ .../logic/analysisadmin/graphCreateLogic.go | 64 + .../logic/analysisadmin/graphDeleteLogic.go | 55 + .../logic/analysisadmin/graphListLogic.go | 105 ++ .../logic/analysisadmin/graphTypesLogic.go | 57 + .../logic/analysisadmin/graphUpdateLogic.go | 67 ++ .../internal/logic/analysisadmin/helpers.go | 170 +++ .../logic/analysisadmin/scanDetailLogic.go | 67 ++ .../logic/analysisadmin/scanListLogic.go | 200 ++++ .../logic/analysisadmin/scanStateLogic.go | 54 + .../logic/analysisadmin/storeListLogic.go | 171 +++ .../logic/analysisdevice/faceLoginLogic.go | 3 - .../analysisadmin/analysisAdminServer.go | 55 + .../server/analysisuser/analysisUserServer.go | 1 - services/analysis/validator/view.go | 152 +++ services/store/internal/logic/itemsLogic.go | 2 +- services/store/validator/store.go | 3 +- .../internal/logic/internalUpdateLogic.go | 12 +- .../internal/logic/internalUsersByBizLogic.go | 5 - services/user/validator/user.go | 1 + 36 files changed, 3203 insertions(+), 135 deletions(-) create mode 100644 services/analysis/internal/logic/analysisadmin/bindStoreLogic.go create mode 100644 services/analysis/internal/logic/analysisadmin/bindUserLogic.go create mode 100644 services/analysis/internal/logic/analysisadmin/graphCreateLogic.go create mode 100644 services/analysis/internal/logic/analysisadmin/graphDeleteLogic.go create mode 100644 services/analysis/internal/logic/analysisadmin/graphListLogic.go create mode 100644 services/analysis/internal/logic/analysisadmin/graphTypesLogic.go create mode 100644 services/analysis/internal/logic/analysisadmin/graphUpdateLogic.go create mode 100644 services/analysis/internal/logic/analysisadmin/scanDetailLogic.go create mode 100644 services/analysis/internal/logic/analysisadmin/scanListLogic.go create mode 100644 services/analysis/internal/logic/analysisadmin/scanStateLogic.go create mode 100644 services/analysis/internal/logic/analysisadmin/storeListLogic.go diff --git a/rpc/analysis/analysis.pb b/rpc/analysis/analysis.pb index 34f72ea573a68b7a9b844cc264219d24fbe6a794..2fc7f802c64f591bdea0e236ef81e18c39b90ad3 100644 GIT binary patch delta 1659 zcmaJ>&rcIU6i!8jIcG5+&GeoAVP!Qgn)W-Wz1qa&oxhKemi&&DQV#e~v}-+X#; zvQ4w3caI&sXteZfk4UBz|5MuZS|I(JVLL!ZNl#PTW=ND&ForYRc*U}Dffr{GhiMb1 zX?Hz|YE84&@*eFFN!pI)_`L21zqweP3Nu9nP7#Wi1*QsfG{XcFcBFYSb zcyNCa(V(NN+U+O}d6bV@T61UPpvi23mCEEIHgZo5$7CxGtMgj}m-d8xwT9&|%fagl z`@BzSAq-ln3)28Z2T5YTWukv61wydTVK03=#?r@F7+r2LaSMJpH{6D5ORKwPrxc9o zEJ-?`Dw~){6w@r@<@%3L ziRI0Qxi;KMxaW@q#DQ{m9wN%m(Xing-l;r!hVp`Vy{L3ss(EvP&j2NyX#?IQX)JO#j&|K7 z%<(0)blU~ja67~33Nx9*x}$k}b)0`%N^_=W=3N3E%fkelO$B^Bi?);W7Dd_4&YZ@%uLB*b) analysis.InternalCreateUserReq - 3, // 1: analysis.Analysis.InternalSetRegistered:input_type -> analysis.InternalSetRegisteredReq - 7, // 2: analysis.Analysis.AgreementInfo:input_type -> analysis.AgreementInfoReq - 9, // 3: analysis.Analysis.Switch:input_type -> analysis.SwitchReq - 10, // 4: analysis.Analysis.QrcodeInfo:input_type -> analysis.QrcodeInfoReq - 32, // 5: analysis.Analysis.Log:input_type -> analysis.LogReq - 33, // 6: analysis.Analysis.Overview:input_type -> analysis.OverviewReq - 34, // 7: analysis.Analysis.User:input_type -> analysis.UserReq - 35, // 8: analysis.Analysis.UserDetail:input_type -> analysis.UserDetailReq - 36, // 9: analysis.Analysis.UserFacepp:input_type -> analysis.TaskIdReq - 31, // 10: analysis.Analysis.UserMode:input_type -> analysis.EmptyReq - 32, // 11: analysis.Analysis.UserLog:input_type -> analysis.LogReq - 31, // 12: analysis.Analysis.Banners:input_type -> analysis.EmptyReq - 37, // 13: analysis.Analysis.QrcodeShare:input_type -> analysis.QrcodeShareReq - 38, // 14: analysis.Analysis.GraphDetail:input_type -> analysis.GraphDetailReq - 36, // 15: analysis.Analysis.FaceppMaps:input_type -> analysis.TaskIdReq - 39, // 16: analysis.Analysis.FaceppMapBoxes:input_type -> analysis.FaceppMapBoxesReq - 40, // 17: analysis.Analysis.FaceppMapBoxDelete:input_type -> analysis.IdReq - 41, // 18: analysis.Analysis.ImagesDate:input_type -> analysis.ImagesDateReq - 42, // 19: analysis.Analysis.ImagesList:input_type -> analysis.ImagesListReq - 36, // 20: analysis.Analysis.ModeImage:input_type -> analysis.TaskIdReq - 43, // 21: analysis.Analysis.DeviceUpdate:input_type -> analysis.DeviceUpdateReq - 6, // 22: analysis.AnalysisUser.FaceBind:input_type -> analysis.FaceBindReq - 5, // 23: analysis.AnalysisUser.UserImprove:input_type -> analysis.UserImproveReq - 8, // 24: analysis.AnalysisUser.UserDelete:input_type -> analysis.UserDeleteReq - 18, // 25: analysis.AnalysisUser.UserAuth:input_type -> analysis.UserAuthReq - 19, // 26: analysis.AnalysisUser.UserAuthList:input_type -> analysis.UserAuthListReq - 20, // 27: analysis.AnalysisUser.UserAuthDelete:input_type -> analysis.UserAuthDeleteReq - 21, // 28: analysis.AnalysisUser.UserAuthUpdate:input_type -> analysis.UserAuthUpdateReq - 22, // 29: analysis.AnalysisUser.DeviceBind:input_type -> analysis.DeviceBindReq - 23, // 30: analysis.AnalysisUser.DeviceInfo:input_type -> analysis.DeviceInfoReq - 29, // 31: analysis.AnalysisUser.UserLogDelete:input_type -> analysis.UserLogDeleteReq - 30, // 32: analysis.AnalysisUser.UserStatus:input_type -> analysis.UserStatusReq - 11, // 33: analysis.AnalysisStore.StoreAuth:input_type -> analysis.StoreAuthReq - 12, // 34: analysis.AnalysisStore.StoreAuthQrcode:input_type -> analysis.StoreAuthQrcodeReq - 13, // 35: analysis.AnalysisStore.StoreInfo:input_type -> analysis.StoreInfoReq - 15, // 36: analysis.AnalysisStore.StoreUserList:input_type -> analysis.StoreUserListReq - 16, // 37: analysis.AnalysisStore.StoreUserUpdate:input_type -> analysis.StoreUserUpdateReq - 17, // 38: analysis.AnalysisStore.StoreUserInfo:input_type -> analysis.StoreUserInfoReq - 47, // 39: analysis.AnalysisDevice.FaceLogin:input_type -> analysis.FaceLoginReq - 24, // 40: analysis.AnalysisDevice.Policy:input_type -> analysis.DevicePolicyReq - 25, // 41: analysis.AnalysisDevice.Display:input_type -> analysis.DeviceDisplayReq - 26, // 42: analysis.AnalysisDevice.OssCallback:input_type -> analysis.OssCallbackReq - 28, // 43: analysis.AnalysisDevice.PyCallback:input_type -> analysis.PyCallbackReq - 44, // 44: analysis.AnalysisAdmin.UserList:input_type -> analysis.AdminUserListReq - 45, // 45: analysis.AnalysisAdmin.UserArchive:input_type -> analysis.AdminUserArchiveReq - 46, // 46: analysis.AnalysisAdmin.UserDetail:input_type -> analysis.AdminUserDetailReq - 2, // 47: analysis.Analysis.InternalCreateUser:output_type -> analysis.InternalCreateUserData - 4, // 48: analysis.Analysis.InternalSetRegistered:output_type -> analysis.InternalSetRegisteredData - 0, // 49: analysis.Analysis.AgreementInfo:output_type -> analysis.Response - 0, // 50: analysis.Analysis.Switch:output_type -> analysis.Response - 0, // 51: analysis.Analysis.QrcodeInfo:output_type -> analysis.Response - 0, // 52: analysis.Analysis.Log:output_type -> analysis.Response - 0, // 53: analysis.Analysis.Overview:output_type -> analysis.Response - 0, // 54: analysis.Analysis.User:output_type -> analysis.Response - 0, // 55: analysis.Analysis.UserDetail:output_type -> analysis.Response - 0, // 56: analysis.Analysis.UserFacepp:output_type -> analysis.Response - 0, // 57: analysis.Analysis.UserMode:output_type -> analysis.Response - 0, // 58: analysis.Analysis.UserLog:output_type -> analysis.Response - 0, // 59: analysis.Analysis.Banners:output_type -> analysis.Response - 0, // 60: analysis.Analysis.QrcodeShare:output_type -> analysis.Response - 0, // 61: analysis.Analysis.GraphDetail:output_type -> analysis.Response - 0, // 62: analysis.Analysis.FaceppMaps:output_type -> analysis.Response - 0, // 63: analysis.Analysis.FaceppMapBoxes:output_type -> analysis.Response - 0, // 64: analysis.Analysis.FaceppMapBoxDelete:output_type -> analysis.Response - 0, // 65: analysis.Analysis.ImagesDate:output_type -> analysis.Response - 0, // 66: analysis.Analysis.ImagesList:output_type -> analysis.Response - 0, // 67: analysis.Analysis.ModeImage:output_type -> analysis.Response - 0, // 68: analysis.Analysis.DeviceUpdate:output_type -> analysis.Response - 0, // 69: analysis.AnalysisUser.FaceBind:output_type -> analysis.Response - 0, // 70: analysis.AnalysisUser.UserImprove:output_type -> analysis.Response - 0, // 71: analysis.AnalysisUser.UserDelete:output_type -> analysis.Response - 0, // 72: analysis.AnalysisUser.UserAuth:output_type -> analysis.Response - 0, // 73: analysis.AnalysisUser.UserAuthList:output_type -> analysis.Response - 0, // 74: analysis.AnalysisUser.UserAuthDelete:output_type -> analysis.Response - 0, // 75: analysis.AnalysisUser.UserAuthUpdate:output_type -> analysis.Response - 0, // 76: analysis.AnalysisUser.DeviceBind:output_type -> analysis.Response - 0, // 77: analysis.AnalysisUser.DeviceInfo:output_type -> analysis.Response - 0, // 78: analysis.AnalysisUser.UserLogDelete:output_type -> analysis.Response - 0, // 79: analysis.AnalysisUser.UserStatus:output_type -> analysis.Response - 0, // 80: analysis.AnalysisStore.StoreAuth:output_type -> analysis.Response - 0, // 81: analysis.AnalysisStore.StoreAuthQrcode:output_type -> analysis.Response - 0, // 82: analysis.AnalysisStore.StoreInfo:output_type -> analysis.Response - 0, // 83: analysis.AnalysisStore.StoreUserList:output_type -> analysis.Response - 0, // 84: analysis.AnalysisStore.StoreUserUpdate:output_type -> analysis.Response - 0, // 85: analysis.AnalysisStore.StoreUserInfo:output_type -> analysis.Response - 0, // 86: analysis.AnalysisDevice.FaceLogin:output_type -> analysis.Response - 0, // 87: analysis.AnalysisDevice.Policy:output_type -> analysis.Response - 0, // 88: analysis.AnalysisDevice.Display:output_type -> analysis.Response - 27, // 89: analysis.AnalysisDevice.OssCallback:output_type -> analysis.OssCallbackResp - 0, // 90: analysis.AnalysisDevice.PyCallback:output_type -> analysis.Response - 0, // 91: analysis.AnalysisAdmin.UserList:output_type -> analysis.Response - 0, // 92: analysis.AnalysisAdmin.UserArchive:output_type -> analysis.Response - 0, // 93: analysis.AnalysisAdmin.UserDetail:output_type -> analysis.Response - 47, // [47:94] is the sub-list for method output_type - 0, // [0:47] 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 + 54, // 0: analysis.AdminGraphCreateReq.title:type_name -> analysis.AdminGraphTitleItem + 55, // 1: analysis.AdminGraphCreateReq.images:type_name -> analysis.AdminGraphImageItem + 54, // 2: analysis.AdminGraphUpdateReq.title:type_name -> analysis.AdminGraphTitleItem + 55, // 3: analysis.AdminGraphUpdateReq.images:type_name -> analysis.AdminGraphImageItem + 1, // 4: analysis.Analysis.InternalCreateUser:input_type -> analysis.InternalCreateUserReq + 3, // 5: analysis.Analysis.InternalSetRegistered:input_type -> analysis.InternalSetRegisteredReq + 7, // 6: analysis.Analysis.AgreementInfo:input_type -> analysis.AgreementInfoReq + 9, // 7: analysis.Analysis.Switch:input_type -> analysis.SwitchReq + 10, // 8: analysis.Analysis.QrcodeInfo:input_type -> analysis.QrcodeInfoReq + 32, // 9: analysis.Analysis.Log:input_type -> analysis.LogReq + 33, // 10: analysis.Analysis.Overview:input_type -> analysis.OverviewReq + 34, // 11: analysis.Analysis.User:input_type -> analysis.UserReq + 35, // 12: analysis.Analysis.UserDetail:input_type -> analysis.UserDetailReq + 36, // 13: analysis.Analysis.UserFacepp:input_type -> analysis.TaskIdReq + 31, // 14: analysis.Analysis.UserMode:input_type -> analysis.EmptyReq + 32, // 15: analysis.Analysis.UserLog:input_type -> analysis.LogReq + 31, // 16: analysis.Analysis.Banners:input_type -> analysis.EmptyReq + 37, // 17: analysis.Analysis.QrcodeShare:input_type -> analysis.QrcodeShareReq + 38, // 18: analysis.Analysis.GraphDetail:input_type -> analysis.GraphDetailReq + 36, // 19: analysis.Analysis.FaceppMaps:input_type -> analysis.TaskIdReq + 39, // 20: analysis.Analysis.FaceppMapBoxes:input_type -> analysis.FaceppMapBoxesReq + 40, // 21: analysis.Analysis.FaceppMapBoxDelete:input_type -> analysis.IdReq + 41, // 22: analysis.Analysis.ImagesDate:input_type -> analysis.ImagesDateReq + 42, // 23: analysis.Analysis.ImagesList:input_type -> analysis.ImagesListReq + 36, // 24: analysis.Analysis.ModeImage:input_type -> analysis.TaskIdReq + 43, // 25: analysis.Analysis.DeviceUpdate:input_type -> analysis.DeviceUpdateReq + 6, // 26: analysis.AnalysisUser.FaceBind:input_type -> analysis.FaceBindReq + 5, // 27: analysis.AnalysisUser.UserImprove:input_type -> analysis.UserImproveReq + 8, // 28: analysis.AnalysisUser.UserDelete:input_type -> analysis.UserDeleteReq + 18, // 29: analysis.AnalysisUser.UserAuth:input_type -> analysis.UserAuthReq + 19, // 30: analysis.AnalysisUser.UserAuthList:input_type -> analysis.UserAuthListReq + 20, // 31: analysis.AnalysisUser.UserAuthDelete:input_type -> analysis.UserAuthDeleteReq + 21, // 32: analysis.AnalysisUser.UserAuthUpdate:input_type -> analysis.UserAuthUpdateReq + 22, // 33: analysis.AnalysisUser.DeviceBind:input_type -> analysis.DeviceBindReq + 23, // 34: analysis.AnalysisUser.DeviceInfo:input_type -> analysis.DeviceInfoReq + 29, // 35: analysis.AnalysisUser.UserLogDelete:input_type -> analysis.UserLogDeleteReq + 30, // 36: analysis.AnalysisUser.UserStatus:input_type -> analysis.UserStatusReq + 11, // 37: analysis.AnalysisStore.StoreAuth:input_type -> analysis.StoreAuthReq + 12, // 38: analysis.AnalysisStore.StoreAuthQrcode:input_type -> analysis.StoreAuthQrcodeReq + 13, // 39: analysis.AnalysisStore.StoreInfo:input_type -> analysis.StoreInfoReq + 15, // 40: analysis.AnalysisStore.StoreUserList:input_type -> analysis.StoreUserListReq + 16, // 41: analysis.AnalysisStore.StoreUserUpdate:input_type -> analysis.StoreUserUpdateReq + 17, // 42: analysis.AnalysisStore.StoreUserInfo:input_type -> analysis.StoreUserInfoReq + 60, // 43: analysis.AnalysisDevice.FaceLogin:input_type -> analysis.FaceLoginReq + 24, // 44: analysis.AnalysisDevice.Policy:input_type -> analysis.DevicePolicyReq + 25, // 45: analysis.AnalysisDevice.Display:input_type -> analysis.DeviceDisplayReq + 26, // 46: analysis.AnalysisDevice.OssCallback:input_type -> analysis.OssCallbackReq + 28, // 47: analysis.AnalysisDevice.PyCallback:input_type -> analysis.PyCallbackReq + 44, // 48: analysis.AnalysisAdmin.UserList:input_type -> analysis.AdminUserListReq + 45, // 49: analysis.AnalysisAdmin.UserArchive:input_type -> analysis.AdminUserArchiveReq + 46, // 50: analysis.AnalysisAdmin.UserDetail:input_type -> analysis.AdminUserDetailReq + 47, // 51: analysis.AnalysisAdmin.BindStore:input_type -> analysis.AdminBindStoreReq + 48, // 52: analysis.AnalysisAdmin.BindUser:input_type -> analysis.AdminBindUserReq + 49, // 53: analysis.AnalysisAdmin.StoreList:input_type -> analysis.AdminStoreListReq + 50, // 54: analysis.AnalysisAdmin.ScanList:input_type -> analysis.AdminScanListReq + 51, // 55: analysis.AnalysisAdmin.ScanDetail:input_type -> analysis.AdminScanDetailReq + 52, // 56: analysis.AnalysisAdmin.ScanState:input_type -> analysis.AdminScanStateReq + 53, // 57: analysis.AnalysisAdmin.GraphTypes:input_type -> analysis.AdminGraphTypesReq + 56, // 58: analysis.AnalysisAdmin.GraphCreate:input_type -> analysis.AdminGraphCreateReq + 57, // 59: analysis.AnalysisAdmin.GraphDelete:input_type -> analysis.AdminGraphDeleteReq + 58, // 60: analysis.AnalysisAdmin.GraphUpdate:input_type -> analysis.AdminGraphUpdateReq + 59, // 61: analysis.AnalysisAdmin.GraphList:input_type -> analysis.AdminGraphListReq + 2, // 62: analysis.Analysis.InternalCreateUser:output_type -> analysis.InternalCreateUserData + 4, // 63: analysis.Analysis.InternalSetRegistered:output_type -> analysis.InternalSetRegisteredData + 0, // 64: analysis.Analysis.AgreementInfo:output_type -> analysis.Response + 0, // 65: analysis.Analysis.Switch:output_type -> analysis.Response + 0, // 66: analysis.Analysis.QrcodeInfo:output_type -> analysis.Response + 0, // 67: analysis.Analysis.Log:output_type -> analysis.Response + 0, // 68: analysis.Analysis.Overview:output_type -> analysis.Response + 0, // 69: analysis.Analysis.User:output_type -> analysis.Response + 0, // 70: analysis.Analysis.UserDetail:output_type -> analysis.Response + 0, // 71: analysis.Analysis.UserFacepp:output_type -> analysis.Response + 0, // 72: analysis.Analysis.UserMode:output_type -> analysis.Response + 0, // 73: analysis.Analysis.UserLog:output_type -> analysis.Response + 0, // 74: analysis.Analysis.Banners:output_type -> analysis.Response + 0, // 75: analysis.Analysis.QrcodeShare:output_type -> analysis.Response + 0, // 76: analysis.Analysis.GraphDetail:output_type -> analysis.Response + 0, // 77: analysis.Analysis.FaceppMaps:output_type -> analysis.Response + 0, // 78: analysis.Analysis.FaceppMapBoxes:output_type -> analysis.Response + 0, // 79: analysis.Analysis.FaceppMapBoxDelete:output_type -> analysis.Response + 0, // 80: analysis.Analysis.ImagesDate:output_type -> analysis.Response + 0, // 81: analysis.Analysis.ImagesList:output_type -> analysis.Response + 0, // 82: analysis.Analysis.ModeImage:output_type -> analysis.Response + 0, // 83: analysis.Analysis.DeviceUpdate:output_type -> analysis.Response + 0, // 84: analysis.AnalysisUser.FaceBind:output_type -> analysis.Response + 0, // 85: analysis.AnalysisUser.UserImprove:output_type -> analysis.Response + 0, // 86: analysis.AnalysisUser.UserDelete:output_type -> analysis.Response + 0, // 87: analysis.AnalysisUser.UserAuth:output_type -> analysis.Response + 0, // 88: analysis.AnalysisUser.UserAuthList:output_type -> analysis.Response + 0, // 89: analysis.AnalysisUser.UserAuthDelete:output_type -> analysis.Response + 0, // 90: analysis.AnalysisUser.UserAuthUpdate:output_type -> analysis.Response + 0, // 91: analysis.AnalysisUser.DeviceBind:output_type -> analysis.Response + 0, // 92: analysis.AnalysisUser.DeviceInfo:output_type -> analysis.Response + 0, // 93: analysis.AnalysisUser.UserLogDelete:output_type -> analysis.Response + 0, // 94: analysis.AnalysisUser.UserStatus:output_type -> analysis.Response + 0, // 95: analysis.AnalysisStore.StoreAuth:output_type -> analysis.Response + 0, // 96: analysis.AnalysisStore.StoreAuthQrcode:output_type -> analysis.Response + 0, // 97: analysis.AnalysisStore.StoreInfo:output_type -> analysis.Response + 0, // 98: analysis.AnalysisStore.StoreUserList:output_type -> analysis.Response + 0, // 99: analysis.AnalysisStore.StoreUserUpdate:output_type -> analysis.Response + 0, // 100: analysis.AnalysisStore.StoreUserInfo:output_type -> analysis.Response + 0, // 101: analysis.AnalysisDevice.FaceLogin:output_type -> analysis.Response + 0, // 102: analysis.AnalysisDevice.Policy:output_type -> analysis.Response + 0, // 103: analysis.AnalysisDevice.Display:output_type -> analysis.Response + 27, // 104: analysis.AnalysisDevice.OssCallback:output_type -> analysis.OssCallbackResp + 0, // 105: analysis.AnalysisDevice.PyCallback:output_type -> analysis.Response + 0, // 106: analysis.AnalysisAdmin.UserList:output_type -> analysis.Response + 0, // 107: analysis.AnalysisAdmin.UserArchive:output_type -> analysis.Response + 0, // 108: analysis.AnalysisAdmin.UserDetail:output_type -> analysis.Response + 0, // 109: analysis.AnalysisAdmin.BindStore:output_type -> analysis.Response + 0, // 110: analysis.AnalysisAdmin.BindUser:output_type -> analysis.Response + 0, // 111: analysis.AnalysisAdmin.StoreList:output_type -> analysis.Response + 0, // 112: analysis.AnalysisAdmin.ScanList:output_type -> analysis.Response + 0, // 113: analysis.AnalysisAdmin.ScanDetail:output_type -> analysis.Response + 0, // 114: analysis.AnalysisAdmin.ScanState:output_type -> analysis.Response + 0, // 115: analysis.AnalysisAdmin.GraphTypes:output_type -> analysis.Response + 0, // 116: analysis.AnalysisAdmin.GraphCreate:output_type -> analysis.Response + 0, // 117: analysis.AnalysisAdmin.GraphDelete:output_type -> analysis.Response + 0, // 118: analysis.AnalysisAdmin.GraphUpdate:output_type -> analysis.Response + 0, // 119: analysis.AnalysisAdmin.GraphList:output_type -> analysis.Response + 62, // [62:120] is the sub-list for method output_type + 4, // [4:62] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name } func init() { file_analysis_analysis_proto_init() } @@ -2810,7 +3640,7 @@ func file_analysis_analysis_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_analysis_analysis_proto_rawDesc), len(file_analysis_analysis_proto_rawDesc)), NumEnums: 0, - NumMessages: 48, + NumMessages: 61, NumExtensions: 0, NumServices: 5, }, diff --git a/rpc/analysis/pb/analysis_grpc.pb.go b/rpc/analysis/pb/analysis_grpc.pb.go index 4f6a0ad..e6d652c 100644 --- a/rpc/analysis/pb/analysis_grpc.pb.go +++ b/rpc/analysis/pb/analysis_grpc.pb.go @@ -938,7 +938,6 @@ const ( type AnalysisUserClient interface { FaceBind(ctx context.Context, in *FaceBindReq, opts ...grpc.CallOption) (*Response, error) UserImprove(ctx context.Context, in *UserImproveReq, opts ...grpc.CallOption) (*Response, error) - // UserDelete 按平台 users.id 级联删除:analysis.users、人脸向量、以及 user 侧关联表。 UserDelete(ctx context.Context, in *UserDeleteReq, opts ...grpc.CallOption) (*Response, error) UserAuth(ctx context.Context, in *UserAuthReq, opts ...grpc.CallOption) (*Response, error) UserAuthList(ctx context.Context, in *UserAuthListReq, opts ...grpc.CallOption) (*Response, error) @@ -1074,7 +1073,6 @@ func (c *analysisUserClient) UserStatus(ctx context.Context, in *UserStatusReq, type AnalysisUserServer interface { FaceBind(context.Context, *FaceBindReq) (*Response, error) UserImprove(context.Context, *UserImproveReq) (*Response, error) - // UserDelete 按平台 users.id 级联删除:analysis.users、人脸向量、以及 user 侧关联表。 UserDelete(context.Context, *UserDeleteReq) (*Response, error) UserAuth(context.Context, *UserAuthReq) (*Response, error) UserAuthList(context.Context, *UserAuthListReq) (*Response, error) @@ -1952,6 +1950,17 @@ const ( AnalysisAdmin_UserList_FullMethodName = "/analysis.AnalysisAdmin/UserList" AnalysisAdmin_UserArchive_FullMethodName = "/analysis.AnalysisAdmin/UserArchive" AnalysisAdmin_UserDetail_FullMethodName = "/analysis.AnalysisAdmin/UserDetail" + AnalysisAdmin_BindStore_FullMethodName = "/analysis.AnalysisAdmin/BindStore" + AnalysisAdmin_BindUser_FullMethodName = "/analysis.AnalysisAdmin/BindUser" + AnalysisAdmin_StoreList_FullMethodName = "/analysis.AnalysisAdmin/StoreList" + AnalysisAdmin_ScanList_FullMethodName = "/analysis.AnalysisAdmin/ScanList" + AnalysisAdmin_ScanDetail_FullMethodName = "/analysis.AnalysisAdmin/ScanDetail" + AnalysisAdmin_ScanState_FullMethodName = "/analysis.AnalysisAdmin/ScanState" + AnalysisAdmin_GraphTypes_FullMethodName = "/analysis.AnalysisAdmin/GraphTypes" + AnalysisAdmin_GraphCreate_FullMethodName = "/analysis.AnalysisAdmin/GraphCreate" + AnalysisAdmin_GraphDelete_FullMethodName = "/analysis.AnalysisAdmin/GraphDelete" + AnalysisAdmin_GraphUpdate_FullMethodName = "/analysis.AnalysisAdmin/GraphUpdate" + AnalysisAdmin_GraphList_FullMethodName = "/analysis.AnalysisAdmin/GraphList" ) // AnalysisAdminClient is the client API for AnalysisAdmin service. @@ -1961,6 +1970,17 @@ type AnalysisAdminClient interface { UserList(ctx context.Context, in *AdminUserListReq, opts ...grpc.CallOption) (*Response, error) UserArchive(ctx context.Context, in *AdminUserArchiveReq, opts ...grpc.CallOption) (*Response, error) UserDetail(ctx context.Context, in *AdminUserDetailReq, opts ...grpc.CallOption) (*Response, error) + BindStore(ctx context.Context, in *AdminBindStoreReq, opts ...grpc.CallOption) (*Response, error) + BindUser(ctx context.Context, in *AdminBindUserReq, opts ...grpc.CallOption) (*Response, error) + StoreList(ctx context.Context, in *AdminStoreListReq, opts ...grpc.CallOption) (*Response, error) + ScanList(ctx context.Context, in *AdminScanListReq, opts ...grpc.CallOption) (*Response, error) + ScanDetail(ctx context.Context, in *AdminScanDetailReq, opts ...grpc.CallOption) (*Response, error) + ScanState(ctx context.Context, in *AdminScanStateReq, opts ...grpc.CallOption) (*Response, error) + GraphTypes(ctx context.Context, in *AdminGraphTypesReq, opts ...grpc.CallOption) (*Response, error) + GraphCreate(ctx context.Context, in *AdminGraphCreateReq, opts ...grpc.CallOption) (*Response, error) + GraphDelete(ctx context.Context, in *AdminGraphDeleteReq, opts ...grpc.CallOption) (*Response, error) + GraphUpdate(ctx context.Context, in *AdminGraphUpdateReq, opts ...grpc.CallOption) (*Response, error) + GraphList(ctx context.Context, in *AdminGraphListReq, opts ...grpc.CallOption) (*Response, error) } type analysisAdminClient struct { @@ -2001,6 +2021,116 @@ func (c *analysisAdminClient) UserDetail(ctx context.Context, in *AdminUserDetai return out, nil } +func (c *analysisAdminClient) BindStore(ctx context.Context, in *AdminBindStoreReq, opts ...grpc.CallOption) (*Response, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Response) + err := c.cc.Invoke(ctx, AnalysisAdmin_BindStore_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *analysisAdminClient) BindUser(ctx context.Context, in *AdminBindUserReq, opts ...grpc.CallOption) (*Response, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Response) + err := c.cc.Invoke(ctx, AnalysisAdmin_BindUser_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *analysisAdminClient) StoreList(ctx context.Context, in *AdminStoreListReq, opts ...grpc.CallOption) (*Response, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Response) + err := c.cc.Invoke(ctx, AnalysisAdmin_StoreList_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *analysisAdminClient) ScanList(ctx context.Context, in *AdminScanListReq, opts ...grpc.CallOption) (*Response, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Response) + err := c.cc.Invoke(ctx, AnalysisAdmin_ScanList_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *analysisAdminClient) ScanDetail(ctx context.Context, in *AdminScanDetailReq, opts ...grpc.CallOption) (*Response, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Response) + err := c.cc.Invoke(ctx, AnalysisAdmin_ScanDetail_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *analysisAdminClient) ScanState(ctx context.Context, in *AdminScanStateReq, opts ...grpc.CallOption) (*Response, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Response) + err := c.cc.Invoke(ctx, AnalysisAdmin_ScanState_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *analysisAdminClient) GraphTypes(ctx context.Context, in *AdminGraphTypesReq, opts ...grpc.CallOption) (*Response, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Response) + err := c.cc.Invoke(ctx, AnalysisAdmin_GraphTypes_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *analysisAdminClient) GraphCreate(ctx context.Context, in *AdminGraphCreateReq, opts ...grpc.CallOption) (*Response, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Response) + err := c.cc.Invoke(ctx, AnalysisAdmin_GraphCreate_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *analysisAdminClient) GraphDelete(ctx context.Context, in *AdminGraphDeleteReq, opts ...grpc.CallOption) (*Response, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Response) + err := c.cc.Invoke(ctx, AnalysisAdmin_GraphDelete_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *analysisAdminClient) GraphUpdate(ctx context.Context, in *AdminGraphUpdateReq, opts ...grpc.CallOption) (*Response, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Response) + err := c.cc.Invoke(ctx, AnalysisAdmin_GraphUpdate_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *analysisAdminClient) GraphList(ctx context.Context, in *AdminGraphListReq, opts ...grpc.CallOption) (*Response, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Response) + err := c.cc.Invoke(ctx, AnalysisAdmin_GraphList_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + // AnalysisAdminServer is the server API for AnalysisAdmin service. // All implementations must embed UnimplementedAnalysisAdminServer // for forward compatibility. @@ -2008,6 +2138,17 @@ type AnalysisAdminServer interface { UserList(context.Context, *AdminUserListReq) (*Response, error) UserArchive(context.Context, *AdminUserArchiveReq) (*Response, error) UserDetail(context.Context, *AdminUserDetailReq) (*Response, error) + BindStore(context.Context, *AdminBindStoreReq) (*Response, error) + BindUser(context.Context, *AdminBindUserReq) (*Response, error) + StoreList(context.Context, *AdminStoreListReq) (*Response, error) + ScanList(context.Context, *AdminScanListReq) (*Response, error) + ScanDetail(context.Context, *AdminScanDetailReq) (*Response, error) + ScanState(context.Context, *AdminScanStateReq) (*Response, error) + GraphTypes(context.Context, *AdminGraphTypesReq) (*Response, error) + GraphCreate(context.Context, *AdminGraphCreateReq) (*Response, error) + GraphDelete(context.Context, *AdminGraphDeleteReq) (*Response, error) + GraphUpdate(context.Context, *AdminGraphUpdateReq) (*Response, error) + GraphList(context.Context, *AdminGraphListReq) (*Response, error) mustEmbedUnimplementedAnalysisAdminServer() } @@ -2027,6 +2168,39 @@ func (UnimplementedAnalysisAdminServer) UserArchive(context.Context, *AdminUserA func (UnimplementedAnalysisAdminServer) UserDetail(context.Context, *AdminUserDetailReq) (*Response, error) { return nil, status.Error(codes.Unimplemented, "method UserDetail not implemented") } +func (UnimplementedAnalysisAdminServer) BindStore(context.Context, *AdminBindStoreReq) (*Response, error) { + return nil, status.Error(codes.Unimplemented, "method BindStore not implemented") +} +func (UnimplementedAnalysisAdminServer) BindUser(context.Context, *AdminBindUserReq) (*Response, error) { + return nil, status.Error(codes.Unimplemented, "method BindUser not implemented") +} +func (UnimplementedAnalysisAdminServer) StoreList(context.Context, *AdminStoreListReq) (*Response, error) { + return nil, status.Error(codes.Unimplemented, "method StoreList not implemented") +} +func (UnimplementedAnalysisAdminServer) ScanList(context.Context, *AdminScanListReq) (*Response, error) { + return nil, status.Error(codes.Unimplemented, "method ScanList not implemented") +} +func (UnimplementedAnalysisAdminServer) ScanDetail(context.Context, *AdminScanDetailReq) (*Response, error) { + return nil, status.Error(codes.Unimplemented, "method ScanDetail not implemented") +} +func (UnimplementedAnalysisAdminServer) ScanState(context.Context, *AdminScanStateReq) (*Response, error) { + return nil, status.Error(codes.Unimplemented, "method ScanState not implemented") +} +func (UnimplementedAnalysisAdminServer) GraphTypes(context.Context, *AdminGraphTypesReq) (*Response, error) { + return nil, status.Error(codes.Unimplemented, "method GraphTypes not implemented") +} +func (UnimplementedAnalysisAdminServer) GraphCreate(context.Context, *AdminGraphCreateReq) (*Response, error) { + return nil, status.Error(codes.Unimplemented, "method GraphCreate not implemented") +} +func (UnimplementedAnalysisAdminServer) GraphDelete(context.Context, *AdminGraphDeleteReq) (*Response, error) { + return nil, status.Error(codes.Unimplemented, "method GraphDelete not implemented") +} +func (UnimplementedAnalysisAdminServer) GraphUpdate(context.Context, *AdminGraphUpdateReq) (*Response, error) { + return nil, status.Error(codes.Unimplemented, "method GraphUpdate not implemented") +} +func (UnimplementedAnalysisAdminServer) GraphList(context.Context, *AdminGraphListReq) (*Response, error) { + return nil, status.Error(codes.Unimplemented, "method GraphList not implemented") +} func (UnimplementedAnalysisAdminServer) mustEmbedUnimplementedAnalysisAdminServer() {} func (UnimplementedAnalysisAdminServer) testEmbeddedByValue() {} @@ -2102,6 +2276,204 @@ func _AnalysisAdmin_UserDetail_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _AnalysisAdmin_BindStore_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AdminBindStoreReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AnalysisAdminServer).BindStore(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: AnalysisAdmin_BindStore_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AnalysisAdminServer).BindStore(ctx, req.(*AdminBindStoreReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _AnalysisAdmin_BindUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AdminBindUserReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AnalysisAdminServer).BindUser(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: AnalysisAdmin_BindUser_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AnalysisAdminServer).BindUser(ctx, req.(*AdminBindUserReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _AnalysisAdmin_StoreList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AdminStoreListReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AnalysisAdminServer).StoreList(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: AnalysisAdmin_StoreList_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AnalysisAdminServer).StoreList(ctx, req.(*AdminStoreListReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _AnalysisAdmin_ScanList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AdminScanListReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AnalysisAdminServer).ScanList(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: AnalysisAdmin_ScanList_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AnalysisAdminServer).ScanList(ctx, req.(*AdminScanListReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _AnalysisAdmin_ScanDetail_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AdminScanDetailReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AnalysisAdminServer).ScanDetail(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: AnalysisAdmin_ScanDetail_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AnalysisAdminServer).ScanDetail(ctx, req.(*AdminScanDetailReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _AnalysisAdmin_ScanState_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AdminScanStateReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AnalysisAdminServer).ScanState(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: AnalysisAdmin_ScanState_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AnalysisAdminServer).ScanState(ctx, req.(*AdminScanStateReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _AnalysisAdmin_GraphTypes_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AdminGraphTypesReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AnalysisAdminServer).GraphTypes(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: AnalysisAdmin_GraphTypes_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AnalysisAdminServer).GraphTypes(ctx, req.(*AdminGraphTypesReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _AnalysisAdmin_GraphCreate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AdminGraphCreateReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AnalysisAdminServer).GraphCreate(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: AnalysisAdmin_GraphCreate_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AnalysisAdminServer).GraphCreate(ctx, req.(*AdminGraphCreateReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _AnalysisAdmin_GraphDelete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AdminGraphDeleteReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AnalysisAdminServer).GraphDelete(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: AnalysisAdmin_GraphDelete_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AnalysisAdminServer).GraphDelete(ctx, req.(*AdminGraphDeleteReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _AnalysisAdmin_GraphUpdate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AdminGraphUpdateReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AnalysisAdminServer).GraphUpdate(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: AnalysisAdmin_GraphUpdate_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AnalysisAdminServer).GraphUpdate(ctx, req.(*AdminGraphUpdateReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _AnalysisAdmin_GraphList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AdminGraphListReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AnalysisAdminServer).GraphList(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: AnalysisAdmin_GraphList_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AnalysisAdminServer).GraphList(ctx, req.(*AdminGraphListReq)) + } + return interceptor(ctx, in, info, handler) +} + // AnalysisAdmin_ServiceDesc is the grpc.ServiceDesc for AnalysisAdmin service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -2121,6 +2493,50 @@ var AnalysisAdmin_ServiceDesc = grpc.ServiceDesc{ MethodName: "UserDetail", Handler: _AnalysisAdmin_UserDetail_Handler, }, + { + MethodName: "BindStore", + Handler: _AnalysisAdmin_BindStore_Handler, + }, + { + MethodName: "BindUser", + Handler: _AnalysisAdmin_BindUser_Handler, + }, + { + MethodName: "StoreList", + Handler: _AnalysisAdmin_StoreList_Handler, + }, + { + MethodName: "ScanList", + Handler: _AnalysisAdmin_ScanList_Handler, + }, + { + MethodName: "ScanDetail", + Handler: _AnalysisAdmin_ScanDetail_Handler, + }, + { + MethodName: "ScanState", + Handler: _AnalysisAdmin_ScanState_Handler, + }, + { + MethodName: "GraphTypes", + Handler: _AnalysisAdmin_GraphTypes_Handler, + }, + { + MethodName: "GraphCreate", + Handler: _AnalysisAdmin_GraphCreate_Handler, + }, + { + MethodName: "GraphDelete", + Handler: _AnalysisAdmin_GraphDelete_Handler, + }, + { + MethodName: "GraphUpdate", + Handler: _AnalysisAdmin_GraphUpdate_Handler, + }, + { + MethodName: "GraphList", + Handler: _AnalysisAdmin_GraphList_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "analysis/analysis.proto", diff --git a/rpc/user/pb/user.pb.go b/rpc/user/pb/user.pb.go index 0a787ab..d383550 100644 --- a/rpc/user/pb/user.pb.go +++ b/rpc/user/pb/user.pb.go @@ -1187,8 +1187,10 @@ type InternalUpdateReq struct { Secret string `protobuf:"bytes,10,opt,name=secret,proto3" json:"secret,omitempty"` BizId int64 `protobuf:"varint,11,opt,name=biz_id,json=bizId,proto3" json:"biz_id,omitempty"` SubjectType string `protobuf:"bytes,12,opt,name=subject_type,json=subjectType,proto3" json:"subject_type,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + // user_id 可选;>0 时按用户主键更新,否则按 biz_id+subject_type 查找 + UserId int64 `protobuf:"varint,13,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *InternalUpdateReq) Reset() { @@ -1298,6 +1300,13 @@ func (x *InternalUpdateReq) GetSubjectType() string { return "" } +func (x *InternalUpdateReq) GetUserId() int64 { + if x != nil { + return x.UserId + } + return 0 +} + type InternalUpdateData struct { state protoimpl.MessageState `protogen:"open.v1"` UserId int64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` @@ -2592,7 +2601,7 @@ const file_user_user_proto_rawDesc = "" + "\x06mobile\x18\x02 \x01(\tR\x06mobile\x12!\n" + "\fsubject_type\x18\x03 \x01(\tR\vsubjectType\"1\n" + "\x17InternalCheckUpdateData\x12\x16\n" + - "\x06result\x18\x01 \x01(\bR\x06result\"\xc7\x02\n" + + "\x06result\x18\x01 \x01(\bR\x06result\"\xe0\x02\n" + "\x11InternalUpdateReq\x12\x16\n" + "\x06mobile\x18\x02 \x01(\tR\x06mobile\x12\x12\n" + "\x04name\x18\x03 \x01(\tR\x04name\x12\x16\n" + @@ -2608,7 +2617,8 @@ const file_user_user_proto_rawDesc = "" + "\x06secret\x18\n" + " \x01(\tR\x06secret\x12\x15\n" + "\x06biz_id\x18\v \x01(\x03R\x05bizId\x12!\n" + - "\fsubject_type\x18\f \x01(\tR\vsubjectType\"Y\n" + + "\fsubject_type\x18\f \x01(\tR\vsubjectType\x12\x17\n" + + "\auser_id\x18\r \x01(\x03R\x06userId\"Y\n" + "\x12InternalUpdateData\x12\x17\n" + "\auser_id\x18\x01 \x01(\x03R\x06userId\x12\x16\n" + "\x06mobile\x18\x02 \x01(\tR\x06mobile\x12\x12\n" + diff --git a/rpc/user/user.pb b/rpc/user/user.pb index 3979b060a0eaec40101bd7382d061e7a8ad0e90a..9ee532e987803ba3261ed69c87be9c3a715e2234 100644 GIT binary patch delta 54 zcmew|hp~4q;|3>F#*>?!O^etWA8g)cF#toaDO^etWk8j>)0 时按用户主键更新,否则按 biz_id+subject_type 查找 + int64 user_id = 13; } message InternalUpdateData { diff --git a/services/analysis/client/analysisadmin/analysisAdmin.go b/services/analysis/client/analysisadmin/analysisAdmin.go index e59b706..525a6c3 100644 --- a/services/analysis/client/analysisadmin/analysisAdmin.go +++ b/services/analysis/client/analysisadmin/analysisAdmin.go @@ -14,6 +14,17 @@ import ( ) type ( + AdminBindStoreReq = analysis.AdminBindStoreReq + AdminBindUserReq = analysis.AdminBindUserReq + AdminGraphCreateReq = analysis.AdminGraphCreateReq + AdminGraphDeleteReq = analysis.AdminGraphDeleteReq + AdminGraphListReq = analysis.AdminGraphListReq + AdminGraphTypesReq = analysis.AdminGraphTypesReq + AdminGraphUpdateReq = analysis.AdminGraphUpdateReq + AdminScanDetailReq = analysis.AdminScanDetailReq + AdminScanListReq = analysis.AdminScanListReq + AdminScanStateReq = analysis.AdminScanStateReq + AdminStoreListReq = analysis.AdminStoreListReq AdminUserArchiveReq = analysis.AdminUserArchiveReq AdminUserDetailReq = analysis.AdminUserDetailReq AdminUserListReq = analysis.AdminUserListReq @@ -23,6 +34,17 @@ type ( UserList(ctx context.Context, in *AdminUserListReq, opts ...grpc.CallOption) (*Response, error) UserArchive(ctx context.Context, in *AdminUserArchiveReq, opts ...grpc.CallOption) (*Response, error) UserDetail(ctx context.Context, in *AdminUserDetailReq, opts ...grpc.CallOption) (*Response, error) + BindStore(ctx context.Context, in *AdminBindStoreReq, opts ...grpc.CallOption) (*Response, error) + BindUser(ctx context.Context, in *AdminBindUserReq, opts ...grpc.CallOption) (*Response, error) + StoreList(ctx context.Context, in *AdminStoreListReq, opts ...grpc.CallOption) (*Response, error) + ScanList(ctx context.Context, in *AdminScanListReq, opts ...grpc.CallOption) (*Response, error) + ScanDetail(ctx context.Context, in *AdminScanDetailReq, opts ...grpc.CallOption) (*Response, error) + ScanState(ctx context.Context, in *AdminScanStateReq, opts ...grpc.CallOption) (*Response, error) + GraphTypes(ctx context.Context, in *AdminGraphTypesReq, opts ...grpc.CallOption) (*Response, error) + GraphCreate(ctx context.Context, in *AdminGraphCreateReq, opts ...grpc.CallOption) (*Response, error) + GraphDelete(ctx context.Context, in *AdminGraphDeleteReq, opts ...grpc.CallOption) (*Response, error) + GraphUpdate(ctx context.Context, in *AdminGraphUpdateReq, opts ...grpc.CallOption) (*Response, error) + GraphList(ctx context.Context, in *AdminGraphListReq, opts ...grpc.CallOption) (*Response, error) } defaultAnalysisAdmin struct { @@ -50,3 +72,58 @@ func (m *defaultAnalysisAdmin) UserDetail(ctx context.Context, in *AdminUserDeta client := analysis.NewAnalysisAdminClient(m.cli.Conn()) return client.UserDetail(ctx, in, opts...) } + +func (m *defaultAnalysisAdmin) BindStore(ctx context.Context, in *AdminBindStoreReq, opts ...grpc.CallOption) (*Response, error) { + client := analysis.NewAnalysisAdminClient(m.cli.Conn()) + return client.BindStore(ctx, in, opts...) +} + +func (m *defaultAnalysisAdmin) BindUser(ctx context.Context, in *AdminBindUserReq, opts ...grpc.CallOption) (*Response, error) { + client := analysis.NewAnalysisAdminClient(m.cli.Conn()) + return client.BindUser(ctx, in, opts...) +} + +func (m *defaultAnalysisAdmin) StoreList(ctx context.Context, in *AdminStoreListReq, opts ...grpc.CallOption) (*Response, error) { + client := analysis.NewAnalysisAdminClient(m.cli.Conn()) + return client.StoreList(ctx, in, opts...) +} + +func (m *defaultAnalysisAdmin) ScanList(ctx context.Context, in *AdminScanListReq, opts ...grpc.CallOption) (*Response, error) { + client := analysis.NewAnalysisAdminClient(m.cli.Conn()) + return client.ScanList(ctx, in, opts...) +} + +func (m *defaultAnalysisAdmin) ScanDetail(ctx context.Context, in *AdminScanDetailReq, opts ...grpc.CallOption) (*Response, error) { + client := analysis.NewAnalysisAdminClient(m.cli.Conn()) + return client.ScanDetail(ctx, in, opts...) +} + +func (m *defaultAnalysisAdmin) ScanState(ctx context.Context, in *AdminScanStateReq, opts ...grpc.CallOption) (*Response, error) { + client := analysis.NewAnalysisAdminClient(m.cli.Conn()) + return client.ScanState(ctx, in, opts...) +} + +func (m *defaultAnalysisAdmin) GraphTypes(ctx context.Context, in *AdminGraphTypesReq, opts ...grpc.CallOption) (*Response, error) { + client := analysis.NewAnalysisAdminClient(m.cli.Conn()) + return client.GraphTypes(ctx, in, opts...) +} + +func (m *defaultAnalysisAdmin) GraphCreate(ctx context.Context, in *AdminGraphCreateReq, opts ...grpc.CallOption) (*Response, error) { + client := analysis.NewAnalysisAdminClient(m.cli.Conn()) + return client.GraphCreate(ctx, in, opts...) +} + +func (m *defaultAnalysisAdmin) GraphDelete(ctx context.Context, in *AdminGraphDeleteReq, opts ...grpc.CallOption) (*Response, error) { + client := analysis.NewAnalysisAdminClient(m.cli.Conn()) + return client.GraphDelete(ctx, in, opts...) +} + +func (m *defaultAnalysisAdmin) GraphUpdate(ctx context.Context, in *AdminGraphUpdateReq, opts ...grpc.CallOption) (*Response, error) { + client := analysis.NewAnalysisAdminClient(m.cli.Conn()) + return client.GraphUpdate(ctx, in, opts...) +} + +func (m *defaultAnalysisAdmin) GraphList(ctx context.Context, in *AdminGraphListReq, opts ...grpc.CallOption) (*Response, error) { + client := analysis.NewAnalysisAdminClient(m.cli.Conn()) + return client.GraphList(ctx, in, opts...) +} diff --git a/services/analysis/client/analysisuser/analysisUser.go b/services/analysis/client/analysisuser/analysisUser.go index a344ace..5e24d43 100644 --- a/services/analysis/client/analysisuser/analysisUser.go +++ b/services/analysis/client/analysisuser/analysisUser.go @@ -30,7 +30,6 @@ type ( AnalysisUser interface { FaceBind(ctx context.Context, in *FaceBindReq, opts ...grpc.CallOption) (*Response, error) UserImprove(ctx context.Context, in *UserImproveReq, opts ...grpc.CallOption) (*Response, error) - // UserDelete 按平台 users.id 级联删除:analysis.users、人脸向量、以及 user 侧关联表。 UserDelete(ctx context.Context, in *UserDeleteReq, opts ...grpc.CallOption) (*Response, error) UserAuth(ctx context.Context, in *UserAuthReq, opts ...grpc.CallOption) (*Response, error) UserAuthList(ctx context.Context, in *UserAuthListReq, opts ...grpc.CallOption) (*Response, error) @@ -63,7 +62,6 @@ func (m *defaultAnalysisUser) UserImprove(ctx context.Context, in *UserImproveRe return client.UserImprove(ctx, in, opts...) } -// UserDelete 按平台 users.id 级联删除:analysis.users、人脸向量、以及 user 侧关联表。 func (m *defaultAnalysisUser) UserDelete(ctx context.Context, in *UserDeleteReq, opts ...grpc.CallOption) (*Response, error) { client := analysis.NewAnalysisUserClient(m.cli.Conn()) return client.UserDelete(ctx, in, opts...) diff --git a/services/analysis/internal/callback/faceback.go b/services/analysis/internal/callback/faceback.go index 3c600f8..b642328 100644 --- a/services/analysis/internal/callback/faceback.go +++ b/services/analysis/internal/callback/faceback.go @@ -539,6 +539,7 @@ func FinishAnalysis(taskID string, analysis *dao.ImageAnalysis) error { Cover: analysis.Cover, DetectionTime: now, Status: uint8(utils.StatusOk), + State: int8(utils.NumberOne), }) } @@ -549,7 +550,7 @@ func FinishAnalysis(taskID string, analysis *dao.ImageAnalysis) error { "detection_number": newNumber, } if newNumber == utils.NumberTwo { - updateData["status"] = utils.NumberTwo + updateData["state"] = utils.NumberTwo } _, err = model.UserImageLogModel{}.Init().Edit(wLog, updateData) return err diff --git a/services/analysis/internal/dao/authorize.go b/services/analysis/internal/dao/authorize.go index 978c96c..e426cc7 100644 --- a/services/analysis/internal/dao/authorize.go +++ b/services/analysis/internal/dao/authorize.go @@ -20,3 +20,30 @@ type StoreAuthItem struct { CreatedAt string `json:"created_at"` Status int `json:"status"` } + +// AdminBindStoreItem 后台「用户授权门店」列表项(对齐旧 AdminStoreItem) +type AdminBindStoreItem struct { + Id int64 `json:"id"` + Name string `json:"name"` + UserName string `json:"user_name"` + UserMobile string `json:"user_mobile"` + District string `json:"district"` + DistrictText string `json:"district_text"` + ValidityTime string `json:"validity_time"` + Status int `json:"status"` // 1=正常 2=过期 +} + +// AdminBindUserItem 后台「门店授权用户」列表项(对齐旧 AdminUserItem) +type AdminBindUserItem struct { + Id int64 `json:"id"` + UserId int64 `json:"user_id"` + Name string `json:"name"` + Nickname string `json:"nickname"` + Avatar string `json:"avatar"` + Mobile string `json:"mobile"` + Gender uint32 `json:"gender"` + GenderText string `json:"gender_text"` + Birthday string `json:"birthday"` + Age string `json:"age"` + ValidityTime string `json:"validity_time"` +} diff --git a/services/analysis/internal/dao/graph.go b/services/analysis/internal/dao/graph.go index 795783e..a99dca7 100644 --- a/services/analysis/internal/dao/graph.go +++ b/services/analysis/internal/dao/graph.go @@ -14,8 +14,15 @@ type UserGraph struct { } type UserGraphType struct { - Id int64 `gorm:"column:id;primaryKey" json:"id"` - Name string `gorm:"column:name" json:"name"` + Id int64 `gorm:"column:id;primaryKey" json:"id"` + Name string `gorm:"column:name" json:"name"` + Sort int `gorm:"column:sort" json:"sort"` + Status int8 `gorm:"column:status" json:"status"` +} + +type UserGraphTypeResource struct { + Id int64 `json:"id"` + Name string `json:"name"` } type GraphTitleItem struct { diff --git a/services/analysis/internal/dao/remark.go b/services/analysis/internal/dao/remark.go index 46a700a..c16513f 100644 --- a/services/analysis/internal/dao/remark.go +++ b/services/analysis/internal/dao/remark.go @@ -19,6 +19,7 @@ type UserImageLog struct { DetectionTime utils.CustomTime `gorm:"column:detection_time" json:"detection_time"` Cover string `gorm:"column:cover" json:"cover"` Status uint8 `gorm:"column:status" json:"status"` + State int8 `gorm:"column:state" json:"state"` // 1检测过一次 2分析中 3有问题 4已退款 5正常 } type UserImageTag struct { diff --git a/services/analysis/internal/dao/store.go b/services/analysis/internal/dao/store.go index 2c2c96c..517c5a1 100644 --- a/services/analysis/internal/dao/store.go +++ b/services/analysis/internal/dao/store.go @@ -18,6 +18,19 @@ type StoreSkinInfo struct { CreateTime string `json:"create_time"` } +type AdminStoreListItem struct { + Id int64 `json:"id"` + StoreId int64 `json:"store_id"` + Account string `json:"account"` + StoreName string `json:"store_name"` + StoreUserName string `json:"store_user_name"` + StoreUserMobile string `json:"store_user_mobile"` + District string `json:"district"` + DistrictText string `json:"district_text"` + Address string `json:"address"` + Qrcode string `json:"qrcode"` +} + type StoreUserListItem struct { Id int64 `json:"id"` UserId int64 `json:"user_id"` diff --git a/services/analysis/internal/dao/view.go b/services/analysis/internal/dao/view.go index f2861c4..cfce9da 100644 --- a/services/analysis/internal/dao/view.go +++ b/services/analysis/internal/dao/view.go @@ -9,6 +9,28 @@ type ImageLogResource struct { CreateTime string `json:"create_time"` } +type AdminScanListItem struct { + Id int64 `json:"id"` + UserId int64 `json:"user_id"` + DetectionNumber int `json:"detection_number"` + DetectionTime string `json:"detection_time"` + State int `json:"state"` + Username string `json:"username"` + Nickname string `json:"nickname"` + Mobile string `json:"mobile"` + District string `json:"district"` + DistrictText string `json:"district_text"` + Gender int `json:"gender"` + GenderText string `json:"gender_text"` + BirthdayText string `json:"birthday_text"` + CreatedAt string `json:"created_at"` +} + +type AdminScanDetailResource struct { + First *ImageDetailResource `json:"first"` + Second *ImageDetailResource `json:"second"` +} + type ImageOverviewResource struct { Id int64 `json:"id"` UserId int64 `json:"user_id"` diff --git a/services/analysis/internal/logic/analysisadmin/bindStoreLogic.go b/services/analysis/internal/logic/analysisadmin/bindStoreLogic.go new file mode 100644 index 0000000..a904d4a --- /dev/null +++ b/services/analysis/internal/logic/analysisadmin/bindStoreLogic.go @@ -0,0 +1,142 @@ +package analysisadminlogic + +import ( + "context" + "strings" + "time" + + "lone-services/pkg/modelbase" + "lone-services/pkg/utils" + "lone-services/pkg/validate" + 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" + "lone-services/services/analysis/validator" + + "github.com/zeromicro/go-zero/core/logx" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +const bindValidityLayout = "2006-01-02 15:04:05" + +type BindStoreLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewBindStoreLogic(ctx context.Context, svcCtx *svc.ServiceContext) *BindStoreLogic { + return &BindStoreLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *BindStoreLogic) BindStore(in *analysis.AdminBindStoreReq) (*analysis.Response, error) { + var req validator.AdminBindStoreValidator + if msg := validate.ValidateFromProto(in, &req); msg != utils.StringEmpty { + return outParams(msg), nil + } + if _, fail := common.RequireAdmin(l.ctx); fail != nil { + return fail, nil + } + + authList, err := common.ListStoreAuth(req.UserId) + if err != nil { + l.Errorf("admin bind store list auth: %v", err) + return common.FailResponse(utils.Fail), nil + } + if len(authList) == utils.NumberZero { + return common.OkResponse(modelbase.PageResult{Items: []dao.AdminBindStoreItem{}}), nil + } + + storeMap, err := l.loadStores(authList) + if err != nil { + l.Errorf("admin bind store load stores: %v", err) + return common.FailResponse(utils.Fail), nil + } + + now := time.Now() + items := make([]dao.AdminBindStoreItem, 0, len(authList)) + for _, auth := range authList { + store, ok := storeMap[auth.StoreId] + if !ok { + continue + } + itemStatus := utils.NumberOne + if !auth.ValidityTime.IsZero() && auth.ValidityTime.Time.Before(now) { + itemStatus = utils.NumberTwo + } + mobile, _ := utils.DecryptPhone(store.GetUserMobile()) + if mobile == utils.StringEmpty { + mobile = store.GetUserMobile() + } + items = append(items, dao.AdminBindStoreItem{ + Id: store.GetId(), + Name: store.GetName(), + UserName: store.GetUserName(), + UserMobile: mobile, + District: store.GetDistrictIds(), + DistrictText: storeDistrictText(store), + ValidityTime: auth.ValidityTime.Format(bindValidityLayout), + Status: itemStatus, + }) + } + return common.OkResponse(modelbase.PageResult{ + Count: int64(len(items)), + Items: items, + }), nil +} + +func (l *BindStoreLogic) loadStores(authList []dao.UserStoreAuth) (map[int64]*storepb.InfoResponse, error) { + ids := make([]int64, 0, len(authList)) + seen := make(map[int64]struct{}, len(authList)) + for _, row := range authList { + if _, ok := seen[row.StoreId]; ok { + continue + } + seen[row.StoreId] = struct{}{} + ids = append(ids, row.StoreId) + } + if len(ids) == utils.NumberZero { + return map[int64]*storepb.InfoResponse{}, nil + } + + svcName := utils.GetConfigString("services.store") + if svcName == utils.StringEmpty { + return nil, status.Error(codes.FailedPrecondition, "store service empty") + } + cli, err := svc.GetRpcClient(svcName) + if err != nil { + return nil, err + } + res, err := storepb.NewStoreClient(cli.Conn()).GetInfoByIds(l.ctx, &storepb.IdsRequest{Ids: ids}) + if err != nil { + if st, ok := status.FromError(err); ok && st.Message() == utils.ErrorNotFund.Msg { + return map[int64]*storepb.InfoResponse{}, nil + } + return nil, err + } + out := make(map[int64]*storepb.InfoResponse, len(res.GetItems())) + for _, item := range res.GetItems() { + out[item.GetId()] = item + } + return out, nil +} + +func storeDistrictText(info *storepb.InfoResponse) string { + if info == nil { + return utils.StringEmpty + } + parts := make([]string, 0, 3) + for _, name := range []string{info.GetProvinceName(), info.GetCityName(), info.GetCountyName()} { + if name != utils.StringEmpty { + parts = append(parts, name) + } + } + return strings.Join(parts, "") +} diff --git a/services/analysis/internal/logic/analysisadmin/bindUserLogic.go b/services/analysis/internal/logic/analysisadmin/bindUserLogic.go new file mode 100644 index 0000000..30d86b3 --- /dev/null +++ b/services/analysis/internal/logic/analysisadmin/bindUserLogic.go @@ -0,0 +1,162 @@ +package analysisadminlogic + +import ( + "context" + "strconv" + + "lone-services/pkg/modelbase" + "lone-services/pkg/utils" + "lone-services/pkg/validate" + analysis "lone-services/rpc/analysis/pb" + userpb "lone-services/rpc/user/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" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +type BindUserLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewBindUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *BindUserLogic { + return &BindUserLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *BindUserLogic) BindUser(in *analysis.AdminBindUserReq) (*analysis.Response, error) { + var req validator.AdminBindUserValidator + if msg := validate.ValidateFromProto(in, &req); msg != utils.StringEmpty { + return outParams(msg), nil + } + if _, fail := common.RequireAdmin(l.ctx); fail != nil { + return fail, nil + } + + params := modelbase.Params{ + Eq: map[string]string{ + "store_id": strconv.FormatInt(req.StoreId, utils.NumberTen), + "status": strconv.Itoa(int(dao.StatusEnabled)), + }, + Order: "id desc", + Page: int(req.Page), + Size: int(req.Size), + } + + if req.Keyword != utils.StringEmpty { + bizIds, err := l.filterBizIds(req.Keyword) + if err != nil { + l.Errorf("admin bind user filter: %v", err) + return common.FailResponse(utils.Fail), nil + } + if len(bizIds) == utils.NumberZero { + return common.OkResponse(modelbase.PageResult{Items: []dao.AdminBindUserItem{}}), nil + } + params.In = map[string][]string{"user_id": idStrings(bizIds)} + } + + var authList []dao.UserStoreAuth + page, err := model.UserStoreAuthModel{}.Init().Page(params, &authList) + if err != nil { + l.Errorf("admin bind user page: %v", err) + return common.FailResponse(utils.Fail), nil + } + if len(authList) == utils.NumberZero { + page.Items = []dao.AdminBindUserItem{} + return common.OkResponse(page), nil + } + + pageIds := make([]int64, 0, len(authList)) + for _, row := range authList { + pageIds = append(pageIds, row.UserId) + } + profiles, err := l.loadProfiles(pageIds) + if err != nil { + l.Errorf("admin bind user profiles: %v", err) + return common.FailResponse(utils.Fail), nil + } + + items := make([]dao.AdminBindUserItem, 0, len(authList)) + for _, row := range authList { + item := dao.AdminBindUserItem{ + Id: row.Id, + UserId: row.UserId, + ValidityTime: row.ValidityTime.Format(bindValidityLayout), + } + if profile, ok := profiles[row.UserId]; ok { + item.Name = profile.GetName() + item.Nickname = profile.GetName() + item.Avatar = profile.GetAvatar() + mobile, _ := utils.DecryptPhone(profile.GetMobile()) + item.Mobile = mobile + item.Gender = profile.GetGender() + item.GenderText = formatGender(item.Gender) + item.Birthday = profile.GetBirthday() + item.Age = utils.CalcAgeStr(item.Birthday) + } else { + item.GenderText = formatGender(utils.NumberZero) + } + items = append(items, item) + } + page.Items = items + return common.OkResponse(page), nil +} + +func (l *BindUserLogic) filterBizIds(keyword 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, + }) + if err != nil { + return nil, err + } + ids := make([]int64, 0, len(res.GetItems())) + for _, item := range res.GetItems() { + if item.GetBizId() > utils.NumberZero { + ids = append(ids, item.GetBizId()) + } + } + return ids, nil +} + +func (l *BindUserLogic) loadProfiles(bizIds []int64) (map[int64]*userpb.BizUserItem, error) { + out := make(map[int64]*userpb.BizUserItem, len(bizIds)) + if len(bizIds) == utils.NumberZero { + return out, nil + } + 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 + } + for _, item := range res.GetItems() { + out[item.GetBizId()] = item + } + return out, nil +} diff --git a/services/analysis/internal/logic/analysisadmin/graphCreateLogic.go b/services/analysis/internal/logic/analysisadmin/graphCreateLogic.go new file mode 100644 index 0000000..aa234c2 --- /dev/null +++ b/services/analysis/internal/logic/analysisadmin/graphCreateLogic.go @@ -0,0 +1,64 @@ +package analysisadminlogic + +import ( + "context" + + "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" + + jsoniter "github.com/json-iterator/go" + "github.com/zeromicro/go-zero/core/logx" +) + +type GraphCreateLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewGraphCreateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GraphCreateLogic { + return &GraphCreateLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *GraphCreateLogic) GraphCreate(in *analysis.AdminGraphCreateReq) (*analysis.Response, error) { + req := validator.AdminGraphCreateValidator{ + Type: int(in.GetType()), + Name: in.GetName(), + Title: toAdminGraphTitles(in.GetTitle()), + Images: toAdminGraphImages(in.GetImages()), + } + if msg := validate.ValidateStruct(&req); msg != utils.StringEmpty { + return outParams(msg), nil + } + if _, fail := common.RequireAdmin(l.ctx); fail != nil { + return fail, nil + } + + titleJson, _ := jsoniter.MarshalToString(toDaoGraphTitles(req.Title)) + imagesJson, _ := jsoniter.MarshalToString(toDaoGraphImages(req.Images)) + now := utils.Now() + err := model.GraphModel{}.Init().Create(&dao.UserGraph{ + Type: req.Type, + Name: req.Name, + Title: titleJson, + Images: imagesJson, + Status: int8(utils.StatusOk), + CreateAt: now, + UpdateAt: now, + }) + if err != nil { + l.Errorf("admin graph create: %v", err) + return common.FailResponse(utils.Fail), nil + } + return common.OkResponse(nil), nil +} diff --git a/services/analysis/internal/logic/analysisadmin/graphDeleteLogic.go b/services/analysis/internal/logic/analysisadmin/graphDeleteLogic.go new file mode 100644 index 0000000..272246f --- /dev/null +++ b/services/analysis/internal/logic/analysisadmin/graphDeleteLogic.go @@ -0,0 +1,55 @@ +package analysisadminlogic + +import ( + "context" + "strconv" + + "lone-services/pkg/modelbase" + "lone-services/pkg/utils" + "lone-services/pkg/validate" + analysis "lone-services/rpc/analysis/pb" + "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 GraphDeleteLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewGraphDeleteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GraphDeleteLogic { + return &GraphDeleteLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *GraphDeleteLogic) GraphDelete(in *analysis.AdminGraphDeleteReq) (*analysis.Response, error) { + var req validator.AdminGraphDeleteValidator + if msg := validate.ValidateFromProto(in, &req); msg != utils.StringEmpty { + return outParams(msg), nil + } + if _, fail := common.RequireAdmin(l.ctx); fail != nil { + return fail, nil + } + + _, err := model.GraphModel{}.Init().Edit(modelbase.Params{ + Eq: map[string]string{ + "id": strconv.FormatInt(req.Id, utils.NumberTen), + }, + }, map[string]interface{}{ + "status": utils.NumberTwo, + "updated_at": utils.Now(), + }) + if err != nil { + l.Errorf("admin graph delete: %v", err) + return common.FailResponse(utils.Fail), nil + } + return common.OkResponse(nil), nil +} diff --git a/services/analysis/internal/logic/analysisadmin/graphListLogic.go b/services/analysis/internal/logic/analysisadmin/graphListLogic.go new file mode 100644 index 0000000..2ef2efa --- /dev/null +++ b/services/analysis/internal/logic/analysisadmin/graphListLogic.go @@ -0,0 +1,105 @@ +package analysisadminlogic + +import ( + "context" + "strconv" + + "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" + + jsoniter "github.com/json-iterator/go" + "github.com/zeromicro/go-zero/core/logx" +) + +type GraphListLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewGraphListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GraphListLogic { + return &GraphListLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *GraphListLogic) GraphList(in *analysis.AdminGraphListReq) (*analysis.Response, error) { + var req validator.AdminGraphListValidator + if msg := validate.ValidateFromProto(in, &req); msg != utils.StringEmpty { + return outParams(msg), nil + } + if _, fail := common.RequireAdmin(l.ctx); fail != nil { + return fail, nil + } + + params := modelbase.Params{ + Eq: map[string]string{ + "status": strconv.Itoa(utils.StatusOk), + }, + Order: "id desc", + Page: int(req.Page), + Size: int(req.Size), + } + if req.Type > utils.NumberZero { + params.Eq["type"] = strconv.Itoa(int(req.Type)) + } + if req.Name != utils.StringEmpty { + params.Like = map[string]string{ + "name LIKE ?": "%" + req.Name + "%", + } + } + + var rows []dao.UserGraph + page, err := model.GraphModel{}.Init().Page(params, &rows) + if err != nil { + l.Errorf("admin graph list: %v", err) + return common.FailResponse(utils.Fail), nil + } + if len(rows) == utils.NumberZero { + page.Items = []dao.GraphResource{} + return common.OkResponse(page), nil + } + + var types []dao.UserGraphType + err = model.GraphTypeModel{}.Init().Items(modelbase.Params{ + Eq: map[string]string{ + "status": strconv.Itoa(utils.StatusOk), + }, + }, &types) + if err != nil { + l.Errorf("admin graph list types: %v", err) + return common.FailResponse(utils.Fail), nil + } + typeMap := make(map[int]string, len(types)) + for _, t := range types { + typeMap[int(t.Id)] = t.Name + } + + list := make([]dao.GraphResource, 0, len(rows)) + for _, row := range rows { + var title []dao.GraphTitleItem + var images []dao.GraphImageItem + _ = jsoniter.UnmarshalFromString(row.Title, &title) + _ = jsoniter.UnmarshalFromString(row.Images, &images) + list = append(list, dao.GraphResource{ + Id: row.Id, + Type: row.Type, + TypeName: typeMap[row.Type], + Name: row.Name, + Title: title, + Images: images, + CreateAt: row.CreateAt, + }) + } + page.Items = list + return common.OkResponse(page), nil +} diff --git a/services/analysis/internal/logic/analysisadmin/graphTypesLogic.go b/services/analysis/internal/logic/analysisadmin/graphTypesLogic.go new file mode 100644 index 0000000..d900adf --- /dev/null +++ b/services/analysis/internal/logic/analysisadmin/graphTypesLogic.go @@ -0,0 +1,57 @@ +package analysisadminlogic + +import ( + "context" + "strconv" + + "lone-services/pkg/modelbase" + "lone-services/pkg/utils" + 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" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GraphTypesLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewGraphTypesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GraphTypesLogic { + return &GraphTypesLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *GraphTypesLogic) GraphTypes(_ *analysis.AdminGraphTypesReq) (*analysis.Response, error) { + if _, fail := common.RequireAdmin(l.ctx); fail != nil { + return fail, nil + } + + var rows []dao.UserGraphType + err := model.GraphTypeModel{}.Init().Items(modelbase.Params{ + Eq: map[string]string{ + "status": strconv.Itoa(utils.StatusOk), + }, + Order: "sort desc", + }, &rows) + if err != nil { + l.Errorf("admin graph types: %v", err) + return common.FailResponse(utils.Fail), nil + } + + list := make([]dao.UserGraphTypeResource, 0, len(rows)) + for _, row := range rows { + list = append(list, dao.UserGraphTypeResource{ + Id: row.Id, + Name: row.Name, + }) + } + return common.OkResponse(list), nil +} diff --git a/services/analysis/internal/logic/analysisadmin/graphUpdateLogic.go b/services/analysis/internal/logic/analysisadmin/graphUpdateLogic.go new file mode 100644 index 0000000..80e192b --- /dev/null +++ b/services/analysis/internal/logic/analysisadmin/graphUpdateLogic.go @@ -0,0 +1,67 @@ +package analysisadminlogic + +import ( + "context" + "strconv" + + "lone-services/pkg/modelbase" + "lone-services/pkg/utils" + "lone-services/pkg/validate" + analysis "lone-services/rpc/analysis/pb" + "lone-services/services/analysis/internal/logic/common" + "lone-services/services/analysis/internal/model" + "lone-services/services/analysis/internal/svc" + "lone-services/services/analysis/validator" + + jsoniter "github.com/json-iterator/go" + "github.com/zeromicro/go-zero/core/logx" +) + +type GraphUpdateLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewGraphUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GraphUpdateLogic { + return &GraphUpdateLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *GraphUpdateLogic) GraphUpdate(in *analysis.AdminGraphUpdateReq) (*analysis.Response, error) { + req := validator.AdminGraphUpdateValidator{ + Id: in.GetId(), + Type: int(in.GetType()), + Name: in.GetName(), + Title: toAdminGraphTitles(in.GetTitle()), + Images: toAdminGraphImages(in.GetImages()), + } + if msg := validate.ValidateStruct(&req); msg != utils.StringEmpty { + return outParams(msg), nil + } + if _, fail := common.RequireAdmin(l.ctx); fail != nil { + return fail, nil + } + + titleJson, _ := jsoniter.MarshalToString(toDaoGraphTitles(req.Title)) + imagesJson, _ := jsoniter.MarshalToString(toDaoGraphImages(req.Images)) + _, err := model.GraphModel{}.Init().Edit(modelbase.Params{ + Eq: map[string]string{ + "id": strconv.FormatInt(req.Id, utils.NumberTen), + }, + }, map[string]interface{}{ + "type": req.Type, + "name": req.Name, + "title": titleJson, + "images": imagesJson, + "updated_at": utils.Now(), + }) + if err != nil { + l.Errorf("admin graph update: %v", err) + return common.FailResponse(utils.Fail), nil + } + return common.OkResponse(nil), nil +} diff --git a/services/analysis/internal/logic/analysisadmin/helpers.go b/services/analysis/internal/logic/analysisadmin/helpers.go index c4a9a10..b07c7bc 100644 --- a/services/analysis/internal/logic/analysisadmin/helpers.go +++ b/services/analysis/internal/logic/analysisadmin/helpers.go @@ -1,17 +1,24 @@ package analysisadminlogic import ( + "context" "strconv" "strings" "lone-services/pkg/modelbase" "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/model" + "lone-services/services/analysis/internal/svc" + "lone-services/services/analysis/validator" jsoniter "github.com/json-iterator/go" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" ) const adminImageTimeLayout = "2006-01-02 15:04" @@ -119,6 +126,125 @@ func buildImageDetail(detail *dao.Image) dao.ImageDetailResource { } } +func outgoingWithIncomingMD(ctx context.Context) context.Context { + md, ok := metadata.FromIncomingContext(ctx) + if !ok { + return ctx + } + return metadata.NewOutgoingContext(ctx, md.Copy()) +} + +type storePageRow struct { + Id int64 `json:"id"` + Name string `json:"name"` + UserName string `json:"user_name"` + UserMobile string `json:"user_mobile"` + District string `json:"district"` + Address string `json:"address"` + ProvinceName string `json:"province_name"` + CityName string `json:"city_name"` + CountyName string `json:"county_name"` +} + +type storePageData struct { + Count int64 `json:"count"` + Items []storePageRow `json:"items"` +} + +func loadStorePage(ctx context.Context, name string, page, size, storeStatus int32) (storePageData, error) { + out := storePageData{Items: []storePageRow{}} + svcName := utils.GetConfigString("services.store") + if svcName == utils.StringEmpty { + return out, status.Error(codes.FailedPrecondition, "store service empty") + } + cli, err := svc.GetRpcClient(svcName) + if err != nil { + return out, err + } + res, err := storepb.NewStoreClient(cli.Conn()).Items(outgoingWithIncomingMD(ctx), &storepb.ItemsRequest{ + Name: name, + Page: page, + Size: size, + Status: storeStatus, + }) + if err != nil { + return out, err + } + if res.GetCode() != utils.Ok.Code { + return out, status.Error(codes.Internal, res.GetMsg()) + } + if res.GetData() == utils.StringEmpty { + return out, nil + } + if err = jsoniter.UnmarshalFromString(res.GetData(), &out); err != nil { + return storePageData{}, err + } + if out.Items == nil { + out.Items = []storePageRow{} + } + return out, nil +} + +func loadStoresByIds(ctx context.Context, ids []int64) (map[int64]*storepb.InfoResponse, error) { + out := make(map[int64]*storepb.InfoResponse, len(ids)) + if len(ids) == utils.NumberZero { + return out, nil + } + svcName := utils.GetConfigString("services.store") + if svcName == utils.StringEmpty { + return nil, status.Error(codes.FailedPrecondition, "store service empty") + } + cli, err := svc.GetRpcClient(svcName) + if err != nil { + return nil, err + } + res, err := storepb.NewStoreClient(cli.Conn()).GetInfoByIds(ctx, &storepb.IdsRequest{Ids: ids}) + if err != nil { + if st, ok := status.FromError(err); ok && st.Message() == utils.ErrorNotFund.Msg { + return out, nil + } + return nil, err + } + for _, item := range res.GetItems() { + out[item.GetId()] = item + } + return out, nil +} + +func storeDistrictTextFromInfo(info *storepb.InfoResponse) string { + if info == nil { + return utils.StringEmpty + } + parts := make([]string, 0, 3) + for _, name := range []string{info.GetProvinceName(), info.GetCityName(), info.GetCountyName()} { + if name != utils.StringEmpty { + parts = append(parts, name) + } + } + return strings.Join(parts, "") +} + +func pageSlice[T any](items []T, page, size int32) (int64, []T) { + total := int64(len(items)) + p := int(page) + s := int(size) + if p < modelbase.DefaultPage { + p = modelbase.DefaultPage + } + if s < utils.NumberOne { + s = modelbase.DefaultSize + } + start := (p - 1) * s + if start >= len(items) { + return total, []T{} + } + end := start + s + if end > len(items) { + end = len(items) + } + return total, items[start:end] +} + func queryAdminImageLogs(userId int64, page, size int32) ([]dao.ImageLogResource, error) { var rows []dao.Image _, err := model.ImageModel{}.Init().Page(modelbase.Params{ @@ -158,3 +284,47 @@ func queryAdminImageLogs(userId int64, page, size int32) ([]dao.ImageLogResource } return list, nil } + +func toAdminGraphTitles(items []*analysis.AdminGraphTitleItem) []validator.AdminGraphTitleItem { + out := make([]validator.AdminGraphTitleItem, 0, len(items)) + for _, item := range items { + if item == nil { + continue + } + out = append(out, validator.AdminGraphTitleItem{ + Name: item.GetName(), + Content: item.GetContent(), + }) + } + return out +} + +func toAdminGraphImages(items []*analysis.AdminGraphImageItem) []validator.AdminGraphImageItem { + out := make([]validator.AdminGraphImageItem, 0, len(items)) + for _, item := range items { + if item == nil { + continue + } + out = append(out, validator.AdminGraphImageItem{ + Url: item.GetUrl(), + Text: item.GetText(), + }) + } + return out +} + +func toDaoGraphTitles(items []validator.AdminGraphTitleItem) []dao.GraphTitleItem { + out := make([]dao.GraphTitleItem, 0, len(items)) + for _, item := range items { + out = append(out, dao.GraphTitleItem{Name: item.Name, Content: item.Content}) + } + return out +} + +func toDaoGraphImages(items []validator.AdminGraphImageItem) []dao.GraphImageItem { + out := make([]dao.GraphImageItem, 0, len(items)) + for _, item := range items { + out = append(out, dao.GraphImageItem{Url: item.Url, Text: item.Text}) + } + return out +} diff --git a/services/analysis/internal/logic/analysisadmin/scanDetailLogic.go b/services/analysis/internal/logic/analysisadmin/scanDetailLogic.go new file mode 100644 index 0000000..67ffea5 --- /dev/null +++ b/services/analysis/internal/logic/analysisadmin/scanDetailLogic.go @@ -0,0 +1,67 @@ +package analysisadminlogic + +import ( + "context" + "strconv" + + "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 ScanDetailLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewScanDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ScanDetailLogic { + return &ScanDetailLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *ScanDetailLogic) ScanDetail(in *analysis.AdminScanDetailReq) (*analysis.Response, error) { + var req validator.AdminScanDetailValidator + if msg := validate.ValidateFromProto(in, &req); msg != utils.StringEmpty { + return outParams(msg), nil + } + if _, fail := common.RequireAdmin(l.ctx); fail != nil { + return fail, nil + } + + var rows []dao.Image + _, err := model.ImageModel{}.Init().Page(modelbase.Params{ + Eq: map[string]string{ + "user_id": strconv.FormatInt(req.UserId, utils.NumberTen), + }, + Order: "id asc", + Size: utils.NumberTwo, + }, &rows) + if err != nil { + l.Errorf("admin scan detail: %v", err) + return common.FailResponse(utils.Fail), nil + } + if len(rows) == utils.NumberZero { + return common.OkResponse(nil), nil + } + + out := dao.AdminScanDetailResource{} + first := buildImageDetail(&rows[0]) + out.First = &first + if len(rows) > utils.NumberOne { + second := buildImageDetail(&rows[1]) + out.Second = &second + } + return common.OkResponse(out), nil +} diff --git a/services/analysis/internal/logic/analysisadmin/scanListLogic.go b/services/analysis/internal/logic/analysisadmin/scanListLogic.go new file mode 100644 index 0000000..3638fb8 --- /dev/null +++ b/services/analysis/internal/logic/analysisadmin/scanListLogic.go @@ -0,0 +1,200 @@ +package analysisadminlogic + +import ( + "context" + "strconv" + + "lone-services/pkg/modelbase" + "lone-services/pkg/utils" + "lone-services/pkg/validate" + analysis "lone-services/rpc/analysis/pb" + userpb "lone-services/rpc/user/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" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +type ScanListLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewScanListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ScanListLogic { + return &ScanListLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *ScanListLogic) ScanList(in *analysis.AdminScanListReq) (*analysis.Response, error) { + var req validator.AdminScanListValidator + if msg := validate.ValidateFromProto(in, &req); msg != utils.StringEmpty { + return outParams(msg), nil + } + if _, fail := common.RequireAdmin(l.ctx); fail != nil { + return fail, nil + } + + params := modelbase.Params{ + Eq: map[string]string{ + "status": strconv.Itoa(utils.StatusOk), + }, + Order: "id desc", + Page: int(req.Page), + Size: int(req.Size), + } + if req.State > utils.NumberZero { + params.Eq["state"] = strconv.Itoa(int(req.State)) + } + + if req.Keyword != utils.StringEmpty { + bizIds, err := l.filterBizIds(req.Keyword) + if err != nil { + l.Errorf("admin scan list filter: %v", err) + return common.FailResponse(utils.Fail), nil + } + if len(bizIds) == utils.NumberZero { + return common.OkResponse(modelbase.PageResult{Items: []dao.AdminScanListItem{}}), nil + } + params.In = map[string][]string{"user_id": idStrings(bizIds)} + } + + var logs []dao.UserImageLog + page, err := model.UserImageLogModel{}.Init().Page(params, &logs) + if err != nil { + l.Errorf("admin scan list page: %v", err) + return common.FailResponse(utils.Fail), nil + } + if len(logs) == utils.NumberZero { + page.Items = []dao.AdminScanListItem{} + return common.OkResponse(page), nil + } + + userIds := make([]int64, 0, len(logs)) + seen := make(map[int64]struct{}, len(logs)) + for _, row := range logs { + if row.UserId < utils.NumberOne { + continue + } + if _, ok := seen[row.UserId]; ok { + continue + } + seen[row.UserId] = struct{}{} + userIds = append(userIds, row.UserId) + } + + profiles, err := l.loadProfiles(userIds) + if err != nil { + l.Errorf("admin scan list profiles: %v", err) + return common.FailResponse(utils.Fail), nil + } + users, err := loadAnalysisUsers(userIds) + if err != nil { + l.Errorf("admin scan list users: %v", err) + return common.FailResponse(utils.Fail), nil + } + + items := make([]dao.AdminScanListItem, 0, len(logs)) + for _, row := range logs { + item := dao.AdminScanListItem{ + Id: row.Id, + UserId: row.UserId, + DetectionNumber: row.DetectionNumber, + DetectionTime: row.DetectionTime.String(), + State: int(row.State), + GenderText: formatGender(utils.NumberZero), + } + if user, ok := users[row.UserId]; ok { + item.CreatedAt = user.CreatedAt.String() + } + if profile, ok := profiles[row.UserId]; ok { + name := profile.GetName() + item.Username = name + item.Nickname = name + mobile, _ := utils.DecryptPhone(profile.GetMobile()) + item.Mobile = mobile + item.Gender = int(profile.GetGender()) + item.GenderText = formatGender(profile.GetGender()) + item.BirthdayText = utils.CalcAgeStr(profile.GetBirthday()) + } + items = append(items, item) + } + + page.Items = items + return common.OkResponse(page), nil +} + +func (l *ScanListLogic) filterBizIds(keyword 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, + }) + if err != nil { + return nil, err + } + ids := make([]int64, 0, len(res.GetItems())) + for _, item := range res.GetItems() { + if item.GetBizId() > utils.NumberZero { + ids = append(ids, item.GetBizId()) + } + } + return ids, nil +} + +func (l *ScanListLogic) loadProfiles(bizIds []int64) (map[int64]*userpb.BizUserItem, error) { + out := make(map[int64]*userpb.BizUserItem, len(bizIds)) + if len(bizIds) == utils.NumberZero { + return out, nil + } + 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 + } + for _, item := range res.GetItems() { + out[item.GetBizId()] = item + } + return out, nil +} + +func loadAnalysisUsers(ids []int64) (map[int64]dao.User, error) { + out := make(map[int64]dao.User, len(ids)) + if len(ids) == utils.NumberZero { + return out, nil + } + var rows []dao.User + err := model.UserModel{}.Init().Items(modelbase.Params{ + In: map[string][]string{"id": idStrings(ids)}, + }, &rows) + if err != nil { + return nil, err + } + for _, row := range rows { + out[row.Id] = row + } + return out, nil +} diff --git a/services/analysis/internal/logic/analysisadmin/scanStateLogic.go b/services/analysis/internal/logic/analysisadmin/scanStateLogic.go new file mode 100644 index 0000000..e9d8aca --- /dev/null +++ b/services/analysis/internal/logic/analysisadmin/scanStateLogic.go @@ -0,0 +1,54 @@ +package analysisadminlogic + +import ( + "context" + "strconv" + + "lone-services/pkg/modelbase" + "lone-services/pkg/utils" + "lone-services/pkg/validate" + analysis "lone-services/rpc/analysis/pb" + "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 ScanStateLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewScanStateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ScanStateLogic { + return &ScanStateLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *ScanStateLogic) ScanState(in *analysis.AdminScanStateReq) (*analysis.Response, error) { + var req validator.AdminScanStateValidator + if msg := validate.ValidateFromProto(in, &req); msg != utils.StringEmpty { + return outParams(msg), nil + } + if _, fail := common.RequireAdmin(l.ctx); fail != nil { + return fail, nil + } + + _, err := model.UserImageLogModel{}.Init().Edit(modelbase.Params{ + Eq: map[string]string{ + "id": strconv.FormatInt(req.Id, utils.NumberTen), + }, + }, map[string]interface{}{ + "state": req.State, + }) + if err != nil { + l.Errorf("admin scan state: %v", err) + return common.FailResponse(utils.Fail), nil + } + return common.OkResponse(nil), nil +} diff --git a/services/analysis/internal/logic/analysisadmin/storeListLogic.go b/services/analysis/internal/logic/analysisadmin/storeListLogic.go new file mode 100644 index 0000000..f6e4c07 --- /dev/null +++ b/services/analysis/internal/logic/analysisadmin/storeListLogic.go @@ -0,0 +1,171 @@ +package analysisadminlogic + +import ( + "context" + "strings" + + "lone-services/pkg/modelbase" + "lone-services/pkg/utils" + "lone-services/pkg/validate" + analysis "lone-services/rpc/analysis/pb" + userpb "lone-services/rpc/user/pb" + "lone-services/services/analysis/internal/dao" + "lone-services/services/analysis/internal/logic/common" + "lone-services/services/analysis/internal/svc" + "lone-services/services/analysis/validator" + + "github.com/zeromicro/go-zero/core/logx" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +type StoreListLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewStoreListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *StoreListLogic { + return &StoreListLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *StoreListLogic) StoreList(in *analysis.AdminStoreListReq) (*analysis.Response, error) { + var req validator.AdminStoreListValidator + if msg := validate.ValidateFromProto(in, &req); msg != utils.StringEmpty { + return outParams(msg), nil + } + if _, fail := common.RequireAdmin(l.ctx); fail != nil { + return fail, nil + } + + keyword := strings.TrimSpace(req.Keyword) + var storeBizIds []int64 + filterByStore := false + if keyword != utils.StringEmpty { + pageData, err := loadStorePage(l.ctx, keyword, 1, 1000, 0) + if err != nil { + l.Errorf("admin store list search store: %v", err) + return common.FailResponse(utils.Fail), nil + } + if len(pageData.Items) > utils.NumberZero { + filterByStore = true + storeBizIds = make([]int64, 0, len(pageData.Items)) + for _, row := range pageData.Items { + if row.Id > utils.NumberZero { + storeBizIds = append(storeBizIds, row.Id) + } + } + } + } + + var accounts []*userpb.BizUserItem + var err error + if filterByStore { + accounts, err = l.loadStoreAccounts(storeBizIds) + } else { + accounts, err = l.loadStoreAccounts(nil) + if err == nil && keyword != utils.StringEmpty { + accounts = filterStoreAccountsByKeyword(accounts, keyword) + } + } + if err != nil { + l.Errorf("admin store list accounts: %v", err) + return common.FailResponse(utils.Fail), nil + } + if len(accounts) == utils.NumberZero { + return common.OkResponse(modelbase.PageResult{Items: []dao.AdminStoreListItem{}}), nil + } + + storeIds := make([]int64, 0, len(accounts)) + seen := make(map[int64]struct{}, len(accounts)) + for _, acc := range accounts { + if acc.GetBizId() < utils.NumberOne { + continue + } + if _, ok := seen[acc.GetBizId()]; ok { + continue + } + seen[acc.GetBizId()] = struct{}{} + storeIds = append(storeIds, acc.GetBizId()) + } + storeMap, err := loadStoresByIds(l.ctx, storeIds) + if err != nil { + l.Errorf("admin store list stores: %v", err) + return common.FailResponse(utils.Fail), nil + } + + all := make([]dao.AdminStoreListItem, 0, len(accounts)) + for _, acc := range accounts { + store, ok := storeMap[acc.GetBizId()] + if !ok { + continue + } + mobile, _ := utils.DecryptPhone(acc.GetMobile()) + if mobile == utils.StringEmpty { + mobile = acc.GetMobile() + } + storeMobile := store.GetUserMobile() + if plain, dErr := utils.DecryptPhone(storeMobile); dErr == nil && plain != utils.StringEmpty { + storeMobile = plain + } + all = append(all, dao.AdminStoreListItem{ + Id: acc.GetUserId(), + StoreId: store.GetId(), + Account: utils.DecryptPhoneReplace(mobile), + StoreName: store.GetName(), + StoreUserName: store.GetUserName(), + StoreUserMobile: utils.DecryptPhoneReplace(storeMobile), + District: store.GetDistrictIds(), + DistrictText: storeDistrictTextFromInfo(store), + Address: store.GetAddress(), + }) + } + + count, pageItems := pageSlice(all, req.Page, req.Size) + return common.OkResponse(modelbase.PageResult{ + Count: count, + Items: pageItems, + }), nil +} + +func filterStoreAccountsByKeyword(accounts []*userpb.BizUserItem, keyword string) []*userpb.BizUserItem { + if keyword == utils.StringEmpty || len(accounts) == utils.NumberZero { + return accounts + } + enc := utils.GetSearchPhone(keyword) + out := make([]*userpb.BizUserItem, 0, len(accounts)) + for _, acc := range accounts { + mobile := acc.GetMobile() + if enc != utils.StringEmpty && strings.Contains(mobile, enc) { + out = append(out, acc) + continue + } + plain, _ := utils.DecryptPhone(mobile) + if plain != utils.StringEmpty && strings.Contains(plain, keyword) { + out = append(out, acc) + } + } + return out +} + +func (l *StoreListLogic) loadStoreAccounts(bizIds []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.ClientCodeStoreSkin, + BizIds: bizIds, + }) + if err != nil { + return nil, err + } + return res.GetItems(), nil +} diff --git a/services/analysis/internal/logic/analysisdevice/faceLoginLogic.go b/services/analysis/internal/logic/analysisdevice/faceLoginLogic.go index 519b917..4260552 100644 --- a/services/analysis/internal/logic/analysisdevice/faceLoginLogic.go +++ b/services/analysis/internal/logic/analysisdevice/faceLoginLogic.go @@ -64,12 +64,9 @@ func (l *FaceLoginLogic) FaceLogin(in *analysis.FaceLoginReq) (*analysis.Respons l.Infof("face login user_id=%d score=%v err=%v", userID, score, err) if err != nil || userID < utils.NumberOne { - - l.Infof("XXXXXX", utils.GetConfigString("base.mode")) if utils.GetConfigString("base.mode") == "dev" { userID = 1 } else { - l.Infof("AAAAAAAAAA") return common.FailResponse(utils.ErrorFaceNotMatch), nil } } diff --git a/services/analysis/internal/server/analysisadmin/analysisAdminServer.go b/services/analysis/internal/server/analysisadmin/analysisAdminServer.go index 57663df..b336ec9 100644 --- a/services/analysis/internal/server/analysisadmin/analysisAdminServer.go +++ b/services/analysis/internal/server/analysisadmin/analysisAdminServer.go @@ -37,3 +37,58 @@ func (s *AnalysisAdminServer) UserDetail(ctx context.Context, in *analysis.Admin l := analysisadminlogic.NewUserDetailLogic(ctx, s.svcCtx) return l.UserDetail(in) } + +func (s *AnalysisAdminServer) BindStore(ctx context.Context, in *analysis.AdminBindStoreReq) (*analysis.Response, error) { + l := analysisadminlogic.NewBindStoreLogic(ctx, s.svcCtx) + return l.BindStore(in) +} + +func (s *AnalysisAdminServer) BindUser(ctx context.Context, in *analysis.AdminBindUserReq) (*analysis.Response, error) { + l := analysisadminlogic.NewBindUserLogic(ctx, s.svcCtx) + return l.BindUser(in) +} + +func (s *AnalysisAdminServer) StoreList(ctx context.Context, in *analysis.AdminStoreListReq) (*analysis.Response, error) { + l := analysisadminlogic.NewStoreListLogic(ctx, s.svcCtx) + return l.StoreList(in) +} + +func (s *AnalysisAdminServer) ScanList(ctx context.Context, in *analysis.AdminScanListReq) (*analysis.Response, error) { + l := analysisadminlogic.NewScanListLogic(ctx, s.svcCtx) + return l.ScanList(in) +} + +func (s *AnalysisAdminServer) ScanDetail(ctx context.Context, in *analysis.AdminScanDetailReq) (*analysis.Response, error) { + l := analysisadminlogic.NewScanDetailLogic(ctx, s.svcCtx) + return l.ScanDetail(in) +} + +func (s *AnalysisAdminServer) ScanState(ctx context.Context, in *analysis.AdminScanStateReq) (*analysis.Response, error) { + l := analysisadminlogic.NewScanStateLogic(ctx, s.svcCtx) + return l.ScanState(in) +} + +func (s *AnalysisAdminServer) GraphTypes(ctx context.Context, in *analysis.AdminGraphTypesReq) (*analysis.Response, error) { + l := analysisadminlogic.NewGraphTypesLogic(ctx, s.svcCtx) + return l.GraphTypes(in) +} + +func (s *AnalysisAdminServer) GraphCreate(ctx context.Context, in *analysis.AdminGraphCreateReq) (*analysis.Response, error) { + l := analysisadminlogic.NewGraphCreateLogic(ctx, s.svcCtx) + return l.GraphCreate(in) +} + +func (s *AnalysisAdminServer) GraphDelete(ctx context.Context, in *analysis.AdminGraphDeleteReq) (*analysis.Response, error) { + l := analysisadminlogic.NewGraphDeleteLogic(ctx, s.svcCtx) + return l.GraphDelete(in) +} + +func (s *AnalysisAdminServer) GraphUpdate(ctx context.Context, in *analysis.AdminGraphUpdateReq) (*analysis.Response, error) { + l := analysisadminlogic.NewGraphUpdateLogic(ctx, s.svcCtx) + return l.GraphUpdate(in) +} + +func (s *AnalysisAdminServer) GraphList(ctx context.Context, in *analysis.AdminGraphListReq) (*analysis.Response, error) { + l := analysisadminlogic.NewGraphListLogic(ctx, s.svcCtx) + return l.GraphList(in) +} diff --git a/services/analysis/internal/server/analysisuser/analysisUserServer.go b/services/analysis/internal/server/analysisuser/analysisUserServer.go index 13d4850..9553939 100644 --- a/services/analysis/internal/server/analysisuser/analysisUserServer.go +++ b/services/analysis/internal/server/analysisuser/analysisUserServer.go @@ -33,7 +33,6 @@ func (s *AnalysisUserServer) UserImprove(ctx context.Context, in *analysis.UserI return l.UserImprove(in) } -// UserDelete 按平台 users.id 级联删除:analysis.users、人脸向量、以及 user 侧关联表。 func (s *AnalysisUserServer) UserDelete(ctx context.Context, in *analysis.UserDeleteReq) (*analysis.Response, error) { l := analysisuserlogic.NewUserDeleteLogic(ctx, s.svcCtx) return l.UserDelete(in) diff --git a/services/analysis/validator/view.go b/services/analysis/validator/view.go index 7ff6ecf..cdc6271 100644 --- a/services/analysis/validator/view.go +++ b/services/analysis/validator/view.go @@ -186,3 +186,155 @@ func (p AdminUserDetailValidator) GetMessage() validate.ValidatorMessages { "Id.gt": "id必传", } } + +type AdminBindStoreValidator struct { + UserId int64 `validate:"required,gt=0"` +} + +func (p AdminBindStoreValidator) GetMessage() validate.ValidatorMessages { + return validate.ValidatorMessages{ + "UserId.required": "user id 必传", + "UserId.gt": "user id 必传", + } +} + +type AdminBindUserValidator struct { + StoreId int64 `validate:"required,gt=0"` + Page int32 `validate:"omitempty,gte=0"` + Size int32 `validate:"omitempty,gte=0"` + Keyword string `validate:"omitempty,max=64"` +} + +func (p AdminBindUserValidator) GetMessage() validate.ValidatorMessages { + return validate.ValidatorMessages{ + "StoreId.required": "store id 必传", + "StoreId.gt": "store id 必传", + "Keyword.max": "keyword 过长", + } +} + +type AdminStoreListValidator struct { + Page int32 `validate:"omitempty,gte=0"` + Size int32 `validate:"omitempty,gte=0"` + Keyword string `validate:"omitempty,max=64"` +} + +func (p AdminStoreListValidator) GetMessage() validate.ValidatorMessages { + return validate.ValidatorMessages{ + "Keyword.max": "keyword 过长", + } +} + +type AdminScanListValidator struct { + State int32 `validate:"omitempty,oneof=0 1 2 3 4 5"` + Page int32 `validate:"omitempty,gte=0"` + Size int32 `validate:"omitempty,gte=0"` + Keyword string `validate:"omitempty,max=64"` +} + +func (p AdminScanListValidator) GetMessage() validate.ValidatorMessages { + return validate.ValidatorMessages{ + "State.oneof": "state 不合法", + "Keyword.max": "keyword 过长", + } +} + +type AdminScanDetailValidator struct { + UserId int64 `validate:"required,gt=0"` +} + +func (p AdminScanDetailValidator) GetMessage() validate.ValidatorMessages { + return validate.ValidatorMessages{ + "UserId.required": "用户ID必传", + "UserId.gt": "用户ID必传", + } +} + +type AdminScanStateValidator struct { + Id int64 `validate:"required,gt=0"` + State int32 `validate:"required,oneof=1 2 3 4 5"` +} + +func (p AdminScanStateValidator) GetMessage() validate.ValidatorMessages { + return validate.ValidatorMessages{ + "Id.required": "ID必传", + "Id.gt": "ID必传", + "State.required": "状态必传", + "State.oneof": "状态不合法", + } +} + +type AdminGraphTitleItem struct { + Name string `validate:"required"` + Content string `validate:"required"` +} + +type AdminGraphImageItem struct { + Url string `validate:"required"` + Text string `validate:"omitempty"` +} + +type AdminGraphCreateValidator struct { + Type int `validate:"required,gt=0"` + Name string `validate:"required"` + Title []AdminGraphTitleItem `validate:"required,min=1,dive"` + Images []AdminGraphImageItem `validate:"required,min=1,dive"` +} + +func (p AdminGraphCreateValidator) GetMessage() validate.ValidatorMessages { + return validate.ValidatorMessages{ + "Type.required": "type 必传", + "Type.gt": "type 必传", + "Name.required": "Name 必传", + "Title.required": "Title 必传", + "Title.min": "Title 必传", + "Images.required": "Images 必传", + "Images.min": "Images 必传", + } +} + +type AdminGraphDeleteValidator struct { + Id int64 `validate:"required,gt=0"` +} + +func (p AdminGraphDeleteValidator) GetMessage() validate.ValidatorMessages { + return validate.ValidatorMessages{ + "Id.required": "id 必传", + "Id.gt": "id 必传", + } +} + +type AdminGraphUpdateValidator struct { + Id int64 `validate:"required,gt=0"` + Type int `validate:"required,gt=0"` + Name string `validate:"required"` + Title []AdminGraphTitleItem `validate:"required,min=1,dive"` + Images []AdminGraphImageItem `validate:"required,min=1,dive"` +} + +func (p AdminGraphUpdateValidator) GetMessage() validate.ValidatorMessages { + return validate.ValidatorMessages{ + "Id.required": "id 必传", + "Id.gt": "id 必传", + "Type.required": "type 必传", + "Type.gt": "type 必传", + "Name.required": "Name 必传", + "Title.required": "Title 必传", + "Title.min": "Title 必传", + "Images.required": "Images 必传", + "Images.min": "Images 必传", + } +} + +type AdminGraphListValidator struct { + Type int32 `validate:"omitempty,gte=0"` + Name string `validate:"omitempty,max=64"` + Page int32 `validate:"omitempty,gte=0"` + Size int32 `validate:"omitempty,gte=0"` +} + +func (p AdminGraphListValidator) GetMessage() validate.ValidatorMessages { + return validate.ValidatorMessages{ + "Name.max": "name 过长", + } +} diff --git a/services/store/internal/logic/itemsLogic.go b/services/store/internal/logic/itemsLogic.go index fc143e7..8e6529d 100644 --- a/services/store/internal/logic/itemsLogic.go +++ b/services/store/internal/logic/itemsLogic.go @@ -55,7 +55,7 @@ func (l *ItemsLogic) Items(in *store.ItemsRequest) (*store.Response, error) { w.Eq["sale_id"] = strconv.FormatInt(in.SaleId, utils.NumberTen) } if in.Status > utils.NumberZero { - w.Eq["status"] = string(in.Status) + w.Eq["status"] = strconv.Itoa(int(in.Status)) } items, err := model.StoreModel{}.Init().Page(w, &info) diff --git a/services/store/validator/store.go b/services/store/validator/store.go index c14b7bb..70e5e38 100644 --- a/services/store/validator/store.go +++ b/services/store/validator/store.go @@ -10,7 +10,7 @@ type StoreCreateValidator struct { DistrictIds string `form:"district_ids" json:"district_ids" validate:"required"` Address string `form:"address" json:"address" validate:"required"` UserName string `form:"user_name" json:"user_name" validate:"required"` - Password string `form:"password" json:"password" validate:"required,len=8"` + Password string `form:"password" json:"password" validate:"required"` BusinessLicense string `form:"business_license" json:"business_license" validate:"required"` BankInfo string `form:"bank_info" json:"bank_info"` Images string `form:"images" json:"images" validate:"required"` @@ -44,7 +44,6 @@ func (p StoreCreateValidator) GetMessage() validate.ValidatorMessages { "BusinessLicense.required": "营业执照不能为空", "Images.required": "门店照片不能为空", "SaleId.required": "销售ID不能为空", - "Password.len": "必须是8位", "IdCard.required": "身份证正反面不能为空", "ConsigneeMobile.required": "收货人手机号不能为空", "ConsigneeName.required": "收货人姓名不能为空", diff --git a/services/user/internal/logic/internalUpdateLogic.go b/services/user/internal/logic/internalUpdateLogic.go index 19859b5..ab32daa 100644 --- a/services/user/internal/logic/internalUpdateLogic.go +++ b/services/user/internal/logic/internalUpdateLogic.go @@ -40,10 +40,14 @@ func (l *InternalUpdateLogic) InternalUpdate(in *user.InternalUpdateReq) (*user. return nil, status.Error(codes.InvalidArgument, msg) } - userId, findErr := findUserIdByBiz(l.svcCtx.DB, req.BizId, req.SubjectType) - if findErr != nil { - l.Errorf("internal update find by biz: %v", findErr) - return nil, status.Error(codes.Internal, utils.Fail.Msg) + userId := req.UserId + if userId < utils.NumberOne { + var findErr error + userId, findErr = findUserIdByBiz(l.svcCtx.DB, req.BizId, req.SubjectType) + if findErr != nil { + l.Errorf("internal update find by biz: %v", findErr) + return nil, status.Error(codes.Internal, utils.Fail.Msg) + } } if userId < utils.NumberOne { return nil, status.Error(codes.NotFound, utils.ErrorNotFund.Msg) diff --git a/services/user/internal/logic/internalUsersByBizLogic.go b/services/user/internal/logic/internalUsersByBizLogic.go index 1aae3f3..a6b7236 100644 --- a/services/user/internal/logic/internalUsersByBizLogic.go +++ b/services/user/internal/logic/internalUsersByBizLogic.go @@ -38,11 +38,6 @@ func (l *InternalUsersByBizLogic) InternalUsersByBiz(in *user.InternalUsersByBiz 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 { diff --git a/services/user/validator/user.go b/services/user/validator/user.go index cb979c1..a358836 100644 --- a/services/user/validator/user.go +++ b/services/user/validator/user.go @@ -325,6 +325,7 @@ type InternalUpdateValidator struct { Secret string `validate:"omitempty,max=255"` BizId int64 `validate:"required,gt=0"` SubjectType string `validate:"required,oneof=sale store user"` + UserId int64 `validate:"omitempty,gte=0"` } type InternalVerifyPasswordValidator struct {