diff --git a/bff/internal/request/user.go b/bff/internal/request/user.go index b04f3ea..f4a498c 100644 --- a/bff/internal/request/user.go +++ b/bff/internal/request/user.go @@ -33,12 +33,17 @@ const ( CtxGroupId ctxKey = "X-Group-Id" CtxGroupName ctxKey = "X-Group-Name" CtxUserType ctxKey = "X-User-Type" - CtxBizId ctxKey = "X-Biz-Id" - CtxRawBody ctxKey = "X-Raw-Body" + CtxBizId ctxKey = "X-Biz-Id" + CtxRawBody ctxKey = "X-Raw-Body" + CtxOssAuth ctxKey = "X-Oss-Authorization" + CtxOssPubKeyURL ctxKey = "X-Oss-Pub-Key-Url" + CtxRequestPath ctxKey = "X-Request-Path" + CtxRequestQuery ctxKey = "X-Request-Query" ) var callbackPrefixes = []string{ "/api/v3/express/", + "/api/v1/oss/callback", "/api/v3/other1/", "/api/v3/other2/", } @@ -60,9 +65,13 @@ type UserInfo struct { StoreName string GroupId string GroupName string - BizId string - RawBody string - Valid bool + BizId string + RawBody string + OssAuth string + OssPubKeyURL string + RequestPath string + RequestQuery string + Valid bool } func GetUserInfo(ctx context.Context) UserInfo { @@ -83,6 +92,10 @@ func GetUserInfo(ctx context.Context) UserInfo { groupName, _ := ctx.Value(CtxGroupName).(string) bizId, _ := ctx.Value(CtxBizId).(string) rawBody, _ := ctx.Value(CtxRawBody).(string) + ossAuth, _ := ctx.Value(CtxOssAuth).(string) + ossPubKeyURL, _ := ctx.Value(CtxOssPubKeyURL).(string) + requestPath, _ := ctx.Value(CtxRequestPath).(string) + requestQuery, _ := ctx.Value(CtxRequestQuery).(string) info := UserInfo{ RawUID: rawUID, @@ -102,6 +115,10 @@ func GetUserInfo(ctx context.Context) UserInfo { GroupName: groupName, BizId: bizId, RawBody: rawBody, + OssAuth: ossAuth, + OssPubKeyURL: ossPubKeyURL, + RequestPath: requestPath, + RequestQuery: requestQuery, } if rawUID == "" { return info @@ -156,6 +173,12 @@ func UserReadMiddleware(next http.HandlerFunc) http.HandlerFunc { newCtx = context.WithValue(newCtx, CtxGroupId, r.Header.Get("X-Group-Id")) newCtx = context.WithValue(newCtx, CtxGroupName, r.Header.Get("X-Group-Name")) newCtx = context.WithValue(newCtx, CtxBizId, r.Header.Get("X-Biz-Id")) + if isCallbackPath(r.URL.Path) { + newCtx = context.WithValue(newCtx, CtxOssAuth, r.Header.Get("Authorization")) + newCtx = context.WithValue(newCtx, CtxOssPubKeyURL, r.Header.Get("X-Oss-Pub-Key-Url")) + newCtx = context.WithValue(newCtx, CtxRequestPath, r.URL.Path) + newCtx = context.WithValue(newCtx, CtxRequestQuery, r.URL.RawQuery) + } next(w, r.WithContext(newCtx)) } } @@ -207,6 +230,10 @@ func UserClientInterceptor(ctx context.Context, method string, req, reply any, c md.Set("x-group-name", url.QueryEscape(user.GroupName)) } setMDIfNotEmpty(md, "x-biz-id", user.BizId) + setMDIfNotEmpty(md, "x-oss-authorization", user.OssAuth) + setMDIfNotEmpty(md, "x-oss-pub-key-url", user.OssPubKeyURL) + setMDIfNotEmpty(md, "x-request-path", user.RequestPath) + setMDIfNotEmpty(md, "x-request-query", user.RequestQuery) ctx = metadata.NewOutgoingContext(ctx, md) return invoker(ctx, method, req, reply, cc, opts...) @@ -245,6 +272,10 @@ func UserStreamInterceptor(ctx context.Context, desc *grpc.StreamDesc, cc *grpc. md.Set("x-group-name", url.QueryEscape(user.GroupName)) } setMDIfNotEmpty(md, "x-biz-id", user.BizId) + setMDIfNotEmpty(md, "x-oss-authorization", user.OssAuth) + setMDIfNotEmpty(md, "x-oss-pub-key-url", user.OssPubKeyURL) + setMDIfNotEmpty(md, "x-request-path", user.RequestPath) + setMDIfNotEmpty(md, "x-request-query", user.RequestQuery) newCtx := metadata.NewOutgoingContext(ctx, md) return streamer(newCtx, desc, cc, method, opts...) diff --git a/bff/internal/response/middleware.go b/bff/internal/response/middleware.go index 0fe93a5..c220700 100644 --- a/bff/internal/response/middleware.go +++ b/bff/internal/response/middleware.go @@ -93,6 +93,11 @@ func Wrap(next http.HandlerFunc) http.HandlerFunc { } data.Data = string(excelBin) ctrl.OutPutDown(w, data) + } else if _, ok := res["Status"]; ok { + // OSS / 第三方回调:原样透传,例如 {"Status":"OK"} + w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.WriteHeader(http.StatusOK) + _, _ = w.Write(raw) } } } diff --git a/deploy/apisix/apisix.yaml b/deploy/apisix/apisix.yaml index 73c63f1..5ec890b 100644 --- a/deploy/apisix/apisix.yaml +++ b/deploy/apisix/apisix.yaml @@ -15,6 +15,7 @@ routes: uris: - /admin/* - /api/* + - /device/* methods: - GET - POST diff --git a/deploy/apisix/lua/auth.lua b/deploy/apisix/lua/auth.lua index 01ab588..38ece88 100644 --- a/deploy/apisix/lua/auth.lua +++ b/deploy/apisix/lua/auth.lua @@ -23,12 +23,14 @@ function _M.access(conf, ctx) ["/api/v3/express/jd"] = true, ["/api/v3/chore/oss/upload"] = true, + ["/api/v1/oss/callback"] = true, ["/api/v3/user/qrcode/generate"] = true, ["/api/v3/user/qrcode/scan"] = true, ["/api/v2/analysis/agreement/info"] = true, ["/api/v2/analysis/switch"] = true, + ["/api/v2/analysis/qrcode/info"] = true, ["/api/v2/analysis/user/delete"] = true, ["/api/v2/analysis/store/info"] = true, diff --git a/pkg/sms/sms.go b/pkg/sms/sms.go index 159d6d7..35baf07 100644 --- a/pkg/sms/sms.go +++ b/pkg/sms/sms.go @@ -9,8 +9,9 @@ import ( type TemplateKind string const ( - TemplateCode TemplateKind = "code" - TemplatePassword TemplateKind = "password" + TemplateCode TemplateKind = "code" + TemplatePassword TemplateKind = "password" + TemplateRebindMobile TemplateKind = "rebind_mobile" ) type SMS interface { @@ -51,8 +52,9 @@ func New(cfg Config) (SMS, error) { return &client{ sender: sender, templates: map[TemplateKind]string{ - TemplateCode: cfg.TemplateCode, - TemplatePassword: cfg.TemplatePwd, + TemplateCode: cfg.TemplateCode, + TemplatePassword: cfg.TemplatePwd, + TemplateRebindMobile: cfg.TemplateCode, }, timeout: cfg.Timeout, }, nil diff --git a/pkg/ws/types.go b/pkg/ws/types.go index a7f3718..e99db1f 100644 --- a/pkg/ws/types.go +++ b/pkg/ws/types.go @@ -7,6 +7,9 @@ import ( const ( RedisKeyQRSession = "qr:session:" + RedisKeyQRShare = "qr:share:" + RedisKeyOssUpload = "oss:upload:task:" + RedisKeyTaskLights = "task:lights:" RedisChannelQRPush = "ws:qr:push" StatusPending = 1 // 待扫码 diff --git a/rpc/analysis/analysis.pb b/rpc/analysis/analysis.pb index c8c1767..f25940d 100644 Binary files a/rpc/analysis/analysis.pb and b/rpc/analysis/analysis.pb differ diff --git a/rpc/analysis/analysis.proto b/rpc/analysis/analysis.proto index 478c3c0..a7ca872 100644 --- a/rpc/analysis/analysis.proto +++ b/rpc/analysis/analysis.proto @@ -22,6 +22,13 @@ service Analysis { body: "*" }; } + + rpc QrcodeInfo(QrcodeInfoReq) returns (Response) { + option (google.api.http) = { + post: "/api/v2/analysis/qrcode/info" + body: "*" + }; + } } service AnalysisUser { @@ -133,7 +140,28 @@ service AnalysisStore { } } -service AnalysisDevice {} +service AnalysisDevice { + rpc Policy(DevicePolicyReq) returns (Response) { + option (google.api.http) = { + post: "/device/v1/analysis/policy" + body: "*" + }; + } + + rpc Display(DeviceDisplayReq) returns (Response) { + option (google.api.http) = { + post: "/device/v1/analysis/display" + body: "*" + }; + } + + rpc OssCallback(OssCallbackReq) returns (OssCallbackResp) { + option (google.api.http) = { + post: "/api/v1/oss/callback" + body: "*" + }; + } +} message Response { int32 code = 1; @@ -182,6 +210,10 @@ message SwitchReq { int32 type = 1; } +message QrcodeInfoReq { + int64 id = 1; +} + message StoreAuthReq { string username = 1; string password = 2; @@ -241,3 +273,24 @@ message DeviceBindReq { } message DeviceInfoReq {} + +message DevicePolicyReq { + string serial_no = 1; +} + +message DeviceDisplayReq { + string task_id = 1; +} + +message OssCallbackReq { + string bucket = 1; + string object = 2; + string etag = 3; + int64 size = 4; + string mimeType = 5; + string task_id = 6; +} + +message OssCallbackResp { + string Status = 1 [json_name = "Status"]; +} diff --git a/rpc/analysis/pb/analysis.pb.go b/rpc/analysis/pb/analysis.pb.go index 3838a74..460ad60 100644 --- a/rpc/analysis/pb/analysis.pb.go +++ b/rpc/analysis/pb/analysis.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.11 +// protoc-gen-go v1.36.12 // protoc v3.19.4 // source: analysis/analysis.proto @@ -526,6 +526,50 @@ func (x *SwitchReq) GetType() int32 { return 0 } +type QrcodeInfoReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *QrcodeInfoReq) Reset() { + *x = QrcodeInfoReq{} + mi := &file_analysis_analysis_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *QrcodeInfoReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*QrcodeInfoReq) ProtoMessage() {} + +func (x *QrcodeInfoReq) ProtoReflect() protoreflect.Message { + mi := &file_analysis_analysis_proto_msgTypes[10] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use QrcodeInfoReq.ProtoReflect.Descriptor instead. +func (*QrcodeInfoReq) Descriptor() ([]byte, []int) { + return file_analysis_analysis_proto_rawDescGZIP(), []int{10} +} + +func (x *QrcodeInfoReq) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + type StoreAuthReq struct { state protoimpl.MessageState `protogen:"open.v1"` Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` @@ -537,7 +581,7 @@ type StoreAuthReq struct { func (x *StoreAuthReq) Reset() { *x = StoreAuthReq{} - mi := &file_analysis_analysis_proto_msgTypes[10] + mi := &file_analysis_analysis_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -549,7 +593,7 @@ func (x *StoreAuthReq) String() string { func (*StoreAuthReq) ProtoMessage() {} func (x *StoreAuthReq) ProtoReflect() protoreflect.Message { - mi := &file_analysis_analysis_proto_msgTypes[10] + mi := &file_analysis_analysis_proto_msgTypes[11] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -562,7 +606,7 @@ func (x *StoreAuthReq) ProtoReflect() protoreflect.Message { // Deprecated: Use StoreAuthReq.ProtoReflect.Descriptor instead. func (*StoreAuthReq) Descriptor() ([]byte, []int) { - return file_analysis_analysis_proto_rawDescGZIP(), []int{10} + return file_analysis_analysis_proto_rawDescGZIP(), []int{11} } func (x *StoreAuthReq) GetUsername() string { @@ -594,7 +638,7 @@ type StoreAuthQrcodeReq struct { func (x *StoreAuthQrcodeReq) Reset() { *x = StoreAuthQrcodeReq{} - mi := &file_analysis_analysis_proto_msgTypes[11] + mi := &file_analysis_analysis_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -606,7 +650,7 @@ func (x *StoreAuthQrcodeReq) String() string { func (*StoreAuthQrcodeReq) ProtoMessage() {} func (x *StoreAuthQrcodeReq) ProtoReflect() protoreflect.Message { - mi := &file_analysis_analysis_proto_msgTypes[11] + mi := &file_analysis_analysis_proto_msgTypes[12] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -619,7 +663,7 @@ func (x *StoreAuthQrcodeReq) ProtoReflect() protoreflect.Message { // Deprecated: Use StoreAuthQrcodeReq.ProtoReflect.Descriptor instead. func (*StoreAuthQrcodeReq) Descriptor() ([]byte, []int) { - return file_analysis_analysis_proto_rawDescGZIP(), []int{11} + return file_analysis_analysis_proto_rawDescGZIP(), []int{12} } type StoreInfoReq struct { @@ -631,7 +675,7 @@ type StoreInfoReq struct { func (x *StoreInfoReq) Reset() { *x = StoreInfoReq{} - mi := &file_analysis_analysis_proto_msgTypes[12] + mi := &file_analysis_analysis_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -643,7 +687,7 @@ func (x *StoreInfoReq) String() string { func (*StoreInfoReq) ProtoMessage() {} func (x *StoreInfoReq) ProtoReflect() protoreflect.Message { - mi := &file_analysis_analysis_proto_msgTypes[12] + mi := &file_analysis_analysis_proto_msgTypes[13] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -656,7 +700,7 @@ func (x *StoreInfoReq) ProtoReflect() protoreflect.Message { // Deprecated: Use StoreInfoReq.ProtoReflect.Descriptor instead. func (*StoreInfoReq) Descriptor() ([]byte, []int) { - return file_analysis_analysis_proto_rawDescGZIP(), []int{12} + return file_analysis_analysis_proto_rawDescGZIP(), []int{13} } func (x *StoreInfoReq) GetId() int64 { @@ -674,7 +718,7 @@ type StoreDetailReq struct { func (x *StoreDetailReq) Reset() { *x = StoreDetailReq{} - mi := &file_analysis_analysis_proto_msgTypes[13] + mi := &file_analysis_analysis_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -686,7 +730,7 @@ func (x *StoreDetailReq) String() string { func (*StoreDetailReq) ProtoMessage() {} func (x *StoreDetailReq) ProtoReflect() protoreflect.Message { - mi := &file_analysis_analysis_proto_msgTypes[13] + mi := &file_analysis_analysis_proto_msgTypes[14] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -699,7 +743,7 @@ func (x *StoreDetailReq) ProtoReflect() protoreflect.Message { // Deprecated: Use StoreDetailReq.ProtoReflect.Descriptor instead. func (*StoreDetailReq) Descriptor() ([]byte, []int) { - return file_analysis_analysis_proto_rawDescGZIP(), []int{13} + return file_analysis_analysis_proto_rawDescGZIP(), []int{14} } type StoreUserListReq struct { @@ -718,7 +762,7 @@ type StoreUserListReq struct { func (x *StoreUserListReq) Reset() { *x = StoreUserListReq{} - mi := &file_analysis_analysis_proto_msgTypes[14] + mi := &file_analysis_analysis_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -730,7 +774,7 @@ func (x *StoreUserListReq) String() string { func (*StoreUserListReq) ProtoMessage() {} func (x *StoreUserListReq) ProtoReflect() protoreflect.Message { - mi := &file_analysis_analysis_proto_msgTypes[14] + mi := &file_analysis_analysis_proto_msgTypes[15] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -743,7 +787,7 @@ func (x *StoreUserListReq) ProtoReflect() protoreflect.Message { // Deprecated: Use StoreUserListReq.ProtoReflect.Descriptor instead. func (*StoreUserListReq) Descriptor() ([]byte, []int) { - return file_analysis_analysis_proto_rawDescGZIP(), []int{14} + return file_analysis_analysis_proto_rawDescGZIP(), []int{15} } func (x *StoreUserListReq) GetDate() []string { @@ -815,7 +859,7 @@ type StoreUserUpdateReq struct { func (x *StoreUserUpdateReq) Reset() { *x = StoreUserUpdateReq{} - mi := &file_analysis_analysis_proto_msgTypes[15] + mi := &file_analysis_analysis_proto_msgTypes[16] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -827,7 +871,7 @@ func (x *StoreUserUpdateReq) String() string { func (*StoreUserUpdateReq) ProtoMessage() {} func (x *StoreUserUpdateReq) ProtoReflect() protoreflect.Message { - mi := &file_analysis_analysis_proto_msgTypes[15] + mi := &file_analysis_analysis_proto_msgTypes[16] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -840,7 +884,7 @@ func (x *StoreUserUpdateReq) ProtoReflect() protoreflect.Message { // Deprecated: Use StoreUserUpdateReq.ProtoReflect.Descriptor instead. func (*StoreUserUpdateReq) Descriptor() ([]byte, []int) { - return file_analysis_analysis_proto_rawDescGZIP(), []int{15} + return file_analysis_analysis_proto_rawDescGZIP(), []int{16} } func (x *StoreUserUpdateReq) GetUserId() int64 { @@ -887,7 +931,7 @@ type StoreUserInfoReq struct { func (x *StoreUserInfoReq) Reset() { *x = StoreUserInfoReq{} - mi := &file_analysis_analysis_proto_msgTypes[16] + mi := &file_analysis_analysis_proto_msgTypes[17] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -899,7 +943,7 @@ func (x *StoreUserInfoReq) String() string { func (*StoreUserInfoReq) ProtoMessage() {} func (x *StoreUserInfoReq) ProtoReflect() protoreflect.Message { - mi := &file_analysis_analysis_proto_msgTypes[16] + mi := &file_analysis_analysis_proto_msgTypes[17] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -912,7 +956,7 @@ func (x *StoreUserInfoReq) ProtoReflect() protoreflect.Message { // Deprecated: Use StoreUserInfoReq.ProtoReflect.Descriptor instead. func (*StoreUserInfoReq) Descriptor() ([]byte, []int) { - return file_analysis_analysis_proto_rawDescGZIP(), []int{16} + return file_analysis_analysis_proto_rawDescGZIP(), []int{17} } func (x *StoreUserInfoReq) GetUserId() int64 { @@ -933,7 +977,7 @@ type UserAuthReq struct { func (x *UserAuthReq) Reset() { *x = UserAuthReq{} - mi := &file_analysis_analysis_proto_msgTypes[17] + mi := &file_analysis_analysis_proto_msgTypes[18] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -945,7 +989,7 @@ func (x *UserAuthReq) String() string { func (*UserAuthReq) ProtoMessage() {} func (x *UserAuthReq) ProtoReflect() protoreflect.Message { - mi := &file_analysis_analysis_proto_msgTypes[17] + mi := &file_analysis_analysis_proto_msgTypes[18] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -958,7 +1002,7 @@ func (x *UserAuthReq) ProtoReflect() protoreflect.Message { // Deprecated: Use UserAuthReq.ProtoReflect.Descriptor instead. func (*UserAuthReq) Descriptor() ([]byte, []int) { - return file_analysis_analysis_proto_rawDescGZIP(), []int{17} + return file_analysis_analysis_proto_rawDescGZIP(), []int{18} } func (x *UserAuthReq) GetType() int32 { @@ -990,7 +1034,7 @@ type UserAuthListReq struct { func (x *UserAuthListReq) Reset() { *x = UserAuthListReq{} - mi := &file_analysis_analysis_proto_msgTypes[18] + mi := &file_analysis_analysis_proto_msgTypes[19] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1002,7 +1046,7 @@ func (x *UserAuthListReq) String() string { func (*UserAuthListReq) ProtoMessage() {} func (x *UserAuthListReq) ProtoReflect() protoreflect.Message { - mi := &file_analysis_analysis_proto_msgTypes[18] + mi := &file_analysis_analysis_proto_msgTypes[19] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1015,7 +1059,7 @@ func (x *UserAuthListReq) ProtoReflect() protoreflect.Message { // Deprecated: Use UserAuthListReq.ProtoReflect.Descriptor instead. func (*UserAuthListReq) Descriptor() ([]byte, []int) { - return file_analysis_analysis_proto_rawDescGZIP(), []int{18} + return file_analysis_analysis_proto_rawDescGZIP(), []int{19} } type UserAuthDeleteReq struct { @@ -1027,7 +1071,7 @@ type UserAuthDeleteReq struct { func (x *UserAuthDeleteReq) Reset() { *x = UserAuthDeleteReq{} - mi := &file_analysis_analysis_proto_msgTypes[19] + mi := &file_analysis_analysis_proto_msgTypes[20] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1039,7 +1083,7 @@ func (x *UserAuthDeleteReq) String() string { func (*UserAuthDeleteReq) ProtoMessage() {} func (x *UserAuthDeleteReq) ProtoReflect() protoreflect.Message { - mi := &file_analysis_analysis_proto_msgTypes[19] + mi := &file_analysis_analysis_proto_msgTypes[20] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1052,7 +1096,7 @@ func (x *UserAuthDeleteReq) ProtoReflect() protoreflect.Message { // Deprecated: Use UserAuthDeleteReq.ProtoReflect.Descriptor instead. func (*UserAuthDeleteReq) Descriptor() ([]byte, []int) { - return file_analysis_analysis_proto_rawDescGZIP(), []int{19} + return file_analysis_analysis_proto_rawDescGZIP(), []int{20} } func (x *UserAuthDeleteReq) GetId() int64 { @@ -1072,7 +1116,7 @@ type UserAuthUpdateReq struct { func (x *UserAuthUpdateReq) Reset() { *x = UserAuthUpdateReq{} - mi := &file_analysis_analysis_proto_msgTypes[20] + mi := &file_analysis_analysis_proto_msgTypes[21] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1084,7 +1128,7 @@ func (x *UserAuthUpdateReq) String() string { func (*UserAuthUpdateReq) ProtoMessage() {} func (x *UserAuthUpdateReq) ProtoReflect() protoreflect.Message { - mi := &file_analysis_analysis_proto_msgTypes[20] + mi := &file_analysis_analysis_proto_msgTypes[21] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1097,7 +1141,7 @@ func (x *UserAuthUpdateReq) ProtoReflect() protoreflect.Message { // Deprecated: Use UserAuthUpdateReq.ProtoReflect.Descriptor instead. func (*UserAuthUpdateReq) Descriptor() ([]byte, []int) { - return file_analysis_analysis_proto_rawDescGZIP(), []int{20} + return file_analysis_analysis_proto_rawDescGZIP(), []int{21} } func (x *UserAuthUpdateReq) GetId() int64 { @@ -1123,7 +1167,7 @@ type DeviceBindReq struct { func (x *DeviceBindReq) Reset() { *x = DeviceBindReq{} - mi := &file_analysis_analysis_proto_msgTypes[21] + mi := &file_analysis_analysis_proto_msgTypes[22] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1135,7 +1179,7 @@ func (x *DeviceBindReq) String() string { func (*DeviceBindReq) ProtoMessage() {} func (x *DeviceBindReq) ProtoReflect() protoreflect.Message { - mi := &file_analysis_analysis_proto_msgTypes[21] + mi := &file_analysis_analysis_proto_msgTypes[22] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1148,7 +1192,7 @@ func (x *DeviceBindReq) ProtoReflect() protoreflect.Message { // Deprecated: Use DeviceBindReq.ProtoReflect.Descriptor instead. func (*DeviceBindReq) Descriptor() ([]byte, []int) { - return file_analysis_analysis_proto_rawDescGZIP(), []int{21} + return file_analysis_analysis_proto_rawDescGZIP(), []int{22} } func (x *DeviceBindReq) GetDeviceNo() string { @@ -1166,7 +1210,7 @@ type DeviceInfoReq struct { func (x *DeviceInfoReq) Reset() { *x = DeviceInfoReq{} - mi := &file_analysis_analysis_proto_msgTypes[22] + mi := &file_analysis_analysis_proto_msgTypes[23] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1178,7 +1222,7 @@ func (x *DeviceInfoReq) String() string { func (*DeviceInfoReq) ProtoMessage() {} func (x *DeviceInfoReq) ProtoReflect() protoreflect.Message { - mi := &file_analysis_analysis_proto_msgTypes[22] + mi := &file_analysis_analysis_proto_msgTypes[23] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1191,7 +1235,223 @@ func (x *DeviceInfoReq) ProtoReflect() protoreflect.Message { // Deprecated: Use DeviceInfoReq.ProtoReflect.Descriptor instead. func (*DeviceInfoReq) Descriptor() ([]byte, []int) { - return file_analysis_analysis_proto_rawDescGZIP(), []int{22} + return file_analysis_analysis_proto_rawDescGZIP(), []int{23} +} + +type DevicePolicyReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + SerialNo string `protobuf:"bytes,1,opt,name=serial_no,json=serialNo,proto3" json:"serial_no,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DevicePolicyReq) Reset() { + *x = DevicePolicyReq{} + mi := &file_analysis_analysis_proto_msgTypes[24] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DevicePolicyReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DevicePolicyReq) ProtoMessage() {} + +func (x *DevicePolicyReq) ProtoReflect() protoreflect.Message { + mi := &file_analysis_analysis_proto_msgTypes[24] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DevicePolicyReq.ProtoReflect.Descriptor instead. +func (*DevicePolicyReq) Descriptor() ([]byte, []int) { + return file_analysis_analysis_proto_rawDescGZIP(), []int{24} +} + +func (x *DevicePolicyReq) GetSerialNo() string { + if x != nil { + return x.SerialNo + } + return "" +} + +type DeviceDisplayReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + TaskId string `protobuf:"bytes,1,opt,name=task_id,json=taskId,proto3" json:"task_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeviceDisplayReq) Reset() { + *x = DeviceDisplayReq{} + mi := &file_analysis_analysis_proto_msgTypes[25] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DeviceDisplayReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeviceDisplayReq) ProtoMessage() {} + +func (x *DeviceDisplayReq) ProtoReflect() protoreflect.Message { + mi := &file_analysis_analysis_proto_msgTypes[25] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeviceDisplayReq.ProtoReflect.Descriptor instead. +func (*DeviceDisplayReq) Descriptor() ([]byte, []int) { + return file_analysis_analysis_proto_rawDescGZIP(), []int{25} +} + +func (x *DeviceDisplayReq) GetTaskId() string { + if x != nil { + return x.TaskId + } + return "" +} + +type OssCallbackReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + Bucket string `protobuf:"bytes,1,opt,name=bucket,proto3" json:"bucket,omitempty"` + Object string `protobuf:"bytes,2,opt,name=object,proto3" json:"object,omitempty"` + Etag string `protobuf:"bytes,3,opt,name=etag,proto3" json:"etag,omitempty"` + Size int64 `protobuf:"varint,4,opt,name=size,proto3" json:"size,omitempty"` + MimeType string `protobuf:"bytes,5,opt,name=mimeType,proto3" json:"mimeType,omitempty"` + TaskId string `protobuf:"bytes,6,opt,name=task_id,json=taskId,proto3" json:"task_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *OssCallbackReq) Reset() { + *x = OssCallbackReq{} + mi := &file_analysis_analysis_proto_msgTypes[26] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *OssCallbackReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*OssCallbackReq) ProtoMessage() {} + +func (x *OssCallbackReq) ProtoReflect() protoreflect.Message { + mi := &file_analysis_analysis_proto_msgTypes[26] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use OssCallbackReq.ProtoReflect.Descriptor instead. +func (*OssCallbackReq) Descriptor() ([]byte, []int) { + return file_analysis_analysis_proto_rawDescGZIP(), []int{26} +} + +func (x *OssCallbackReq) GetBucket() string { + if x != nil { + return x.Bucket + } + return "" +} + +func (x *OssCallbackReq) GetObject() string { + if x != nil { + return x.Object + } + return "" +} + +func (x *OssCallbackReq) GetEtag() string { + if x != nil { + return x.Etag + } + return "" +} + +func (x *OssCallbackReq) GetSize() int64 { + if x != nil { + return x.Size + } + return 0 +} + +func (x *OssCallbackReq) GetMimeType() string { + if x != nil { + return x.MimeType + } + return "" +} + +func (x *OssCallbackReq) GetTaskId() string { + if x != nil { + return x.TaskId + } + return "" +} + +type OssCallbackResp struct { + state protoimpl.MessageState `protogen:"open.v1"` + Status string `protobuf:"bytes,1,opt,name=Status,proto3" json:"Status,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *OssCallbackResp) Reset() { + *x = OssCallbackResp{} + mi := &file_analysis_analysis_proto_msgTypes[27] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *OssCallbackResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*OssCallbackResp) ProtoMessage() {} + +func (x *OssCallbackResp) ProtoReflect() protoreflect.Message { + mi := &file_analysis_analysis_proto_msgTypes[27] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use OssCallbackResp.ProtoReflect.Descriptor instead. +func (*OssCallbackResp) Descriptor() ([]byte, []int) { + return file_analysis_analysis_proto_rawDescGZIP(), []int{27} +} + +func (x *OssCallbackResp) GetStatus() string { + if x != nil { + return x.Status + } + return "" } var File_analysis_analysis_proto protoreflect.FileDescriptor @@ -1226,7 +1486,9 @@ const file_analysis_analysis_proto_rawDesc = "" + "\rUserDeleteReq\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\"\x1f\n" + "\tSwitchReq\x12\x12\n" + - "\x04type\x18\x01 \x01(\x05R\x04type\"k\n" + + "\x04type\x18\x01 \x01(\x05R\x04type\"\x1f\n" + + "\rQrcodeInfoReq\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"k\n" + "\fStoreAuthReq\x12\x1a\n" + "\busername\x18\x01 \x01(\tR\busername\x12\x1a\n" + "\bpassword\x18\x02 \x01(\tR\bpassword\x12#\n" + @@ -1267,12 +1529,27 @@ const file_analysis_analysis_proto_rawDesc = "" + "\rvalidity_time\x18\x02 \x01(\tR\fvalidityTime\",\n" + "\rDeviceBindReq\x12\x1b\n" + "\tdevice_no\x18\x01 \x01(\tR\bdeviceNo\"\x0f\n" + - "\rDeviceInfoReq2\x89\x03\n" + + "\rDeviceInfoReq\".\n" + + "\x0fDevicePolicyReq\x12\x1b\n" + + "\tserial_no\x18\x01 \x01(\tR\bserialNo\"+\n" + + "\x10DeviceDisplayReq\x12\x17\n" + + "\atask_id\x18\x01 \x01(\tR\x06taskId\"\x9d\x01\n" + + "\x0eOssCallbackReq\x12\x16\n" + + "\x06bucket\x18\x01 \x01(\tR\x06bucket\x12\x16\n" + + "\x06object\x18\x02 \x01(\tR\x06object\x12\x12\n" + + "\x04etag\x18\x03 \x01(\tR\x04etag\x12\x12\n" + + "\x04size\x18\x04 \x01(\x03R\x04size\x12\x1a\n" + + "\bmimeType\x18\x05 \x01(\tR\bmimeType\x12\x17\n" + + "\atask_id\x18\x06 \x01(\tR\x06taskId\")\n" + + "\x0fOssCallbackResp\x12\x16\n" + + "\x06Status\x18\x01 \x01(\tR\x06Status2\xed\x03\n" + "\bAnalysis\x12W\n" + "\x12InternalCreateUser\x12\x1f.analysis.InternalCreateUserReq\x1a .analysis.InternalCreateUserData\x12`\n" + "\x15InternalSetRegistered\x12\".analysis.InternalSetRegisteredReq\x1a#.analysis.InternalSetRegisteredData\x12k\n" + "\rAgreementInfo\x12\x1a.analysis.AgreementInfoReq\x1a\x12.analysis.Response\"*\x82\xd3\xe4\x93\x02$:\x01*\"\x1f/api/v2/analysis/agreement/info\x12U\n" + - "\x06Switch\x12\x13.analysis.SwitchReq\x1a\x12.analysis.Response\"\"\x82\xd3\xe4\x93\x02\x1c:\x01*\"\x17/api/v2/analysis/switch2\xaa\a\n" + + "\x06Switch\x12\x13.analysis.SwitchReq\x1a\x12.analysis.Response\"\"\x82\xd3\xe4\x93\x02\x1c:\x01*\"\x17/api/v2/analysis/switch\x12b\n" + + "\n" + + "QrcodeInfo\x12\x17.analysis.QrcodeInfoReq\x1a\x12.analysis.Response\"'\x82\xd3\xe4\x93\x02!:\x01*\"\x1c/api/v2/analysis/qrcode/info2\xaa\a\n" + "\fAnalysisUser\x12\\\n" + "\bFaceBind\x12\x15.analysis.FaceBindReq\x1a\x12.analysis.Response\"%\x82\xd3\xe4\x93\x02\x1f:\x01*\"\x1a/api/v2/analysis/face/bind\x12e\n" + "\vUserImprove\x12\x18.analysis.UserImproveReq\x1a\x12.analysis.Response\"(\x82\xd3\xe4\x93\x02\":\x01*\"\x1d/api/v2/analysis/user/improve\x12b\n" + @@ -1292,8 +1569,11 @@ const file_analysis_analysis_proto_rawDesc = "" + "\tStoreInfo\x12\x16.analysis.StoreInfoReq\x1a\x12.analysis.Response\"&\x82\xd3\xe4\x93\x02 :\x01*\"\x1b/api/v2/analysis/store/info\x12g\n" + "\rStoreUserList\x12\x1a.analysis.StoreUserListReq\x1a\x12.analysis.Response\"&\x82\xd3\xe4\x93\x02 :\x01*\"\x1b/api/v2/analysis/store/list\x12r\n" + "\x0fStoreUserUpdate\x12\x1c.analysis.StoreUserUpdateReq\x1a\x12.analysis.Response\"-\x82\xd3\xe4\x93\x02':\x01*\"\"/api/v2/analysis/store/user/update\x12l\n" + - "\rStoreUserInfo\x12\x1a.analysis.StoreUserInfoReq\x1a\x12.analysis.Response\"+\x82\xd3\xe4\x93\x02%:\x01*\" /api/v2/analysis/store/user/info2\x10\n" + - "\x0eAnalysisDeviceB\x1cZ\x1alone-services/rpc/analysisb\x06proto3" + "\rStoreUserInfo\x12\x1a.analysis.StoreUserInfoReq\x1a\x12.analysis.Response\"+\x82\xd3\xe4\x93\x02%:\x01*\" /api/v2/analysis/store/user/info2\xb8\x02\n" + + "\x0eAnalysisDevice\x12^\n" + + "\x06Policy\x12\x19.analysis.DevicePolicyReq\x1a\x12.analysis.Response\"%\x82\xd3\xe4\x93\x02\x1f:\x01*\"\x1a/device/v1/analysis/policy\x12a\n" + + "\aDisplay\x12\x1a.analysis.DeviceDisplayReq\x1a\x12.analysis.Response\"&\x82\xd3\xe4\x93\x02 :\x01*\"\x1b/device/v1/analysis/display\x12c\n" + + "\vOssCallback\x12\x18.analysis.OssCallbackReq\x1a\x19.analysis.OssCallbackResp\"\x1f\x82\xd3\xe4\x93\x02\x19:\x01*\"\x14/api/v1/oss/callbackB\x1cZ\x1alone-services/rpc/analysisb\x06proto3" var ( file_analysis_analysis_proto_rawDescOnce sync.Once @@ -1307,7 +1587,7 @@ func file_analysis_analysis_proto_rawDescGZIP() []byte { return file_analysis_analysis_proto_rawDescData } -var file_analysis_analysis_proto_msgTypes = make([]protoimpl.MessageInfo, 23) +var file_analysis_analysis_proto_msgTypes = make([]protoimpl.MessageInfo, 28) var file_analysis_analysis_proto_goTypes = []any{ (*Response)(nil), // 0: analysis.Response (*InternalCreateUserReq)(nil), // 1: analysis.InternalCreateUserReq @@ -1319,61 +1599,74 @@ var file_analysis_analysis_proto_goTypes = []any{ (*AgreementInfoReq)(nil), // 7: analysis.AgreementInfoReq (*UserDeleteReq)(nil), // 8: analysis.UserDeleteReq (*SwitchReq)(nil), // 9: analysis.SwitchReq - (*StoreAuthReq)(nil), // 10: analysis.StoreAuthReq - (*StoreAuthQrcodeReq)(nil), // 11: analysis.StoreAuthQrcodeReq - (*StoreInfoReq)(nil), // 12: analysis.StoreInfoReq - (*StoreDetailReq)(nil), // 13: analysis.StoreDetailReq - (*StoreUserListReq)(nil), // 14: analysis.StoreUserListReq - (*StoreUserUpdateReq)(nil), // 15: analysis.StoreUserUpdateReq - (*StoreUserInfoReq)(nil), // 16: analysis.StoreUserInfoReq - (*UserAuthReq)(nil), // 17: analysis.UserAuthReq - (*UserAuthListReq)(nil), // 18: analysis.UserAuthListReq - (*UserAuthDeleteReq)(nil), // 19: analysis.UserAuthDeleteReq - (*UserAuthUpdateReq)(nil), // 20: analysis.UserAuthUpdateReq - (*DeviceBindReq)(nil), // 21: analysis.DeviceBindReq - (*DeviceInfoReq)(nil), // 22: analysis.DeviceInfoReq + (*QrcodeInfoReq)(nil), // 10: analysis.QrcodeInfoReq + (*StoreAuthReq)(nil), // 11: analysis.StoreAuthReq + (*StoreAuthQrcodeReq)(nil), // 12: analysis.StoreAuthQrcodeReq + (*StoreInfoReq)(nil), // 13: analysis.StoreInfoReq + (*StoreDetailReq)(nil), // 14: analysis.StoreDetailReq + (*StoreUserListReq)(nil), // 15: analysis.StoreUserListReq + (*StoreUserUpdateReq)(nil), // 16: analysis.StoreUserUpdateReq + (*StoreUserInfoReq)(nil), // 17: analysis.StoreUserInfoReq + (*UserAuthReq)(nil), // 18: analysis.UserAuthReq + (*UserAuthListReq)(nil), // 19: analysis.UserAuthListReq + (*UserAuthDeleteReq)(nil), // 20: analysis.UserAuthDeleteReq + (*UserAuthUpdateReq)(nil), // 21: analysis.UserAuthUpdateReq + (*DeviceBindReq)(nil), // 22: analysis.DeviceBindReq + (*DeviceInfoReq)(nil), // 23: analysis.DeviceInfoReq + (*DevicePolicyReq)(nil), // 24: analysis.DevicePolicyReq + (*DeviceDisplayReq)(nil), // 25: analysis.DeviceDisplayReq + (*OssCallbackReq)(nil), // 26: analysis.OssCallbackReq + (*OssCallbackResp)(nil), // 27: analysis.OssCallbackResp } var file_analysis_analysis_proto_depIdxs = []int32{ 1, // 0: analysis.Analysis.InternalCreateUser:input_type -> 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 - 6, // 4: analysis.AnalysisUser.FaceBind:input_type -> analysis.FaceBindReq - 5, // 5: analysis.AnalysisUser.UserImprove:input_type -> analysis.UserImproveReq - 8, // 6: analysis.AnalysisUser.UserDelete:input_type -> analysis.UserDeleteReq - 17, // 7: analysis.AnalysisUser.UserAuth:input_type -> analysis.UserAuthReq - 18, // 8: analysis.AnalysisUser.UserAuthList:input_type -> analysis.UserAuthListReq - 19, // 9: analysis.AnalysisUser.UserAuthDelete:input_type -> analysis.UserAuthDeleteReq - 20, // 10: analysis.AnalysisUser.UserAuthUpdate:input_type -> analysis.UserAuthUpdateReq - 21, // 11: analysis.AnalysisUser.DeviceBind:input_type -> analysis.DeviceBindReq - 22, // 12: analysis.AnalysisUser.DeviceInfo:input_type -> analysis.DeviceInfoReq - 10, // 13: analysis.AnalysisStore.StoreAuth:input_type -> analysis.StoreAuthReq - 11, // 14: analysis.AnalysisStore.StoreAuthQrcode:input_type -> analysis.StoreAuthQrcodeReq - 12, // 15: analysis.AnalysisStore.StoreInfo:input_type -> analysis.StoreInfoReq - 14, // 16: analysis.AnalysisStore.StoreUserList:input_type -> analysis.StoreUserListReq - 15, // 17: analysis.AnalysisStore.StoreUserUpdate:input_type -> analysis.StoreUserUpdateReq - 16, // 18: analysis.AnalysisStore.StoreUserInfo:input_type -> analysis.StoreUserInfoReq - 2, // 19: analysis.Analysis.InternalCreateUser:output_type -> analysis.InternalCreateUserData - 4, // 20: analysis.Analysis.InternalSetRegistered:output_type -> analysis.InternalSetRegisteredData - 0, // 21: analysis.Analysis.AgreementInfo:output_type -> analysis.Response - 0, // 22: analysis.Analysis.Switch:output_type -> analysis.Response - 0, // 23: analysis.AnalysisUser.FaceBind:output_type -> analysis.Response - 0, // 24: analysis.AnalysisUser.UserImprove:output_type -> analysis.Response - 0, // 25: analysis.AnalysisUser.UserDelete:output_type -> analysis.Response - 0, // 26: analysis.AnalysisUser.UserAuth:output_type -> analysis.Response - 0, // 27: analysis.AnalysisUser.UserAuthList:output_type -> analysis.Response - 0, // 28: analysis.AnalysisUser.UserAuthDelete:output_type -> analysis.Response - 0, // 29: analysis.AnalysisUser.UserAuthUpdate:output_type -> analysis.Response - 0, // 30: analysis.AnalysisUser.DeviceBind:output_type -> analysis.Response - 0, // 31: analysis.AnalysisUser.DeviceInfo:output_type -> analysis.Response - 0, // 32: analysis.AnalysisStore.StoreAuth:output_type -> analysis.Response - 0, // 33: analysis.AnalysisStore.StoreAuthQrcode:output_type -> analysis.Response - 0, // 34: analysis.AnalysisStore.StoreInfo:output_type -> analysis.Response - 0, // 35: analysis.AnalysisStore.StoreUserList:output_type -> analysis.Response - 0, // 36: analysis.AnalysisStore.StoreUserUpdate:output_type -> analysis.Response - 0, // 37: analysis.AnalysisStore.StoreUserInfo:output_type -> analysis.Response - 19, // [19:38] is the sub-list for method output_type - 0, // [0:19] is the sub-list for method input_type + 10, // 4: analysis.Analysis.QrcodeInfo:input_type -> analysis.QrcodeInfoReq + 6, // 5: analysis.AnalysisUser.FaceBind:input_type -> analysis.FaceBindReq + 5, // 6: analysis.AnalysisUser.UserImprove:input_type -> analysis.UserImproveReq + 8, // 7: analysis.AnalysisUser.UserDelete:input_type -> analysis.UserDeleteReq + 18, // 8: analysis.AnalysisUser.UserAuth:input_type -> analysis.UserAuthReq + 19, // 9: analysis.AnalysisUser.UserAuthList:input_type -> analysis.UserAuthListReq + 20, // 10: analysis.AnalysisUser.UserAuthDelete:input_type -> analysis.UserAuthDeleteReq + 21, // 11: analysis.AnalysisUser.UserAuthUpdate:input_type -> analysis.UserAuthUpdateReq + 22, // 12: analysis.AnalysisUser.DeviceBind:input_type -> analysis.DeviceBindReq + 23, // 13: analysis.AnalysisUser.DeviceInfo:input_type -> analysis.DeviceInfoReq + 11, // 14: analysis.AnalysisStore.StoreAuth:input_type -> analysis.StoreAuthReq + 12, // 15: analysis.AnalysisStore.StoreAuthQrcode:input_type -> analysis.StoreAuthQrcodeReq + 13, // 16: analysis.AnalysisStore.StoreInfo:input_type -> analysis.StoreInfoReq + 15, // 17: analysis.AnalysisStore.StoreUserList:input_type -> analysis.StoreUserListReq + 16, // 18: analysis.AnalysisStore.StoreUserUpdate:input_type -> analysis.StoreUserUpdateReq + 17, // 19: analysis.AnalysisStore.StoreUserInfo:input_type -> analysis.StoreUserInfoReq + 24, // 20: analysis.AnalysisDevice.Policy:input_type -> analysis.DevicePolicyReq + 25, // 21: analysis.AnalysisDevice.Display:input_type -> analysis.DeviceDisplayReq + 26, // 22: analysis.AnalysisDevice.OssCallback:input_type -> analysis.OssCallbackReq + 2, // 23: analysis.Analysis.InternalCreateUser:output_type -> analysis.InternalCreateUserData + 4, // 24: analysis.Analysis.InternalSetRegistered:output_type -> analysis.InternalSetRegisteredData + 0, // 25: analysis.Analysis.AgreementInfo:output_type -> analysis.Response + 0, // 26: analysis.Analysis.Switch:output_type -> analysis.Response + 0, // 27: analysis.Analysis.QrcodeInfo:output_type -> analysis.Response + 0, // 28: analysis.AnalysisUser.FaceBind:output_type -> analysis.Response + 0, // 29: analysis.AnalysisUser.UserImprove:output_type -> analysis.Response + 0, // 30: analysis.AnalysisUser.UserDelete:output_type -> analysis.Response + 0, // 31: analysis.AnalysisUser.UserAuth:output_type -> analysis.Response + 0, // 32: analysis.AnalysisUser.UserAuthList:output_type -> analysis.Response + 0, // 33: analysis.AnalysisUser.UserAuthDelete:output_type -> analysis.Response + 0, // 34: analysis.AnalysisUser.UserAuthUpdate:output_type -> analysis.Response + 0, // 35: analysis.AnalysisUser.DeviceBind:output_type -> analysis.Response + 0, // 36: analysis.AnalysisUser.DeviceInfo:output_type -> analysis.Response + 0, // 37: analysis.AnalysisStore.StoreAuth:output_type -> analysis.Response + 0, // 38: analysis.AnalysisStore.StoreAuthQrcode:output_type -> analysis.Response + 0, // 39: analysis.AnalysisStore.StoreInfo:output_type -> analysis.Response + 0, // 40: analysis.AnalysisStore.StoreUserList:output_type -> analysis.Response + 0, // 41: analysis.AnalysisStore.StoreUserUpdate:output_type -> analysis.Response + 0, // 42: analysis.AnalysisStore.StoreUserInfo:output_type -> analysis.Response + 0, // 43: analysis.AnalysisDevice.Policy:output_type -> analysis.Response + 0, // 44: analysis.AnalysisDevice.Display:output_type -> analysis.Response + 27, // 45: analysis.AnalysisDevice.OssCallback:output_type -> analysis.OssCallbackResp + 23, // [23:46] is the sub-list for method output_type + 0, // [0:23] 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 @@ -1384,14 +1677,14 @@ func file_analysis_analysis_proto_init() { if File_analysis_analysis_proto != nil { return } - file_analysis_analysis_proto_msgTypes[15].OneofWrappers = []any{} + file_analysis_analysis_proto_msgTypes[16].OneofWrappers = []any{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_analysis_analysis_proto_rawDesc), len(file_analysis_analysis_proto_rawDesc)), NumEnums: 0, - NumMessages: 23, + NumMessages: 28, NumExtensions: 0, NumServices: 4, }, diff --git a/rpc/analysis/pb/analysis_grpc.pb.go b/rpc/analysis/pb/analysis_grpc.pb.go index d180506..0642f9d 100644 --- a/rpc/analysis/pb/analysis_grpc.pb.go +++ b/rpc/analysis/pb/analysis_grpc.pb.go @@ -23,6 +23,7 @@ const ( Analysis_InternalSetRegistered_FullMethodName = "/analysis.Analysis/InternalSetRegistered" Analysis_AgreementInfo_FullMethodName = "/analysis.Analysis/AgreementInfo" Analysis_Switch_FullMethodName = "/analysis.Analysis/Switch" + Analysis_QrcodeInfo_FullMethodName = "/analysis.Analysis/QrcodeInfo" ) // AnalysisClient is the client API for Analysis service. @@ -33,6 +34,7 @@ type AnalysisClient interface { InternalSetRegistered(ctx context.Context, in *InternalSetRegisteredReq, opts ...grpc.CallOption) (*InternalSetRegisteredData, error) AgreementInfo(ctx context.Context, in *AgreementInfoReq, opts ...grpc.CallOption) (*Response, error) Switch(ctx context.Context, in *SwitchReq, opts ...grpc.CallOption) (*Response, error) + QrcodeInfo(ctx context.Context, in *QrcodeInfoReq, opts ...grpc.CallOption) (*Response, error) } type analysisClient struct { @@ -83,6 +85,16 @@ func (c *analysisClient) Switch(ctx context.Context, in *SwitchReq, opts ...grpc return out, nil } +func (c *analysisClient) QrcodeInfo(ctx context.Context, in *QrcodeInfoReq, opts ...grpc.CallOption) (*Response, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Response) + err := c.cc.Invoke(ctx, Analysis_QrcodeInfo_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + // AnalysisServer is the server API for Analysis service. // All implementations must embed UnimplementedAnalysisServer // for forward compatibility. @@ -91,6 +103,7 @@ type AnalysisServer interface { InternalSetRegistered(context.Context, *InternalSetRegisteredReq) (*InternalSetRegisteredData, error) AgreementInfo(context.Context, *AgreementInfoReq) (*Response, error) Switch(context.Context, *SwitchReq) (*Response, error) + QrcodeInfo(context.Context, *QrcodeInfoReq) (*Response, error) mustEmbedUnimplementedAnalysisServer() } @@ -113,6 +126,9 @@ func (UnimplementedAnalysisServer) AgreementInfo(context.Context, *AgreementInfo func (UnimplementedAnalysisServer) Switch(context.Context, *SwitchReq) (*Response, error) { return nil, status.Error(codes.Unimplemented, "method Switch not implemented") } +func (UnimplementedAnalysisServer) QrcodeInfo(context.Context, *QrcodeInfoReq) (*Response, error) { + return nil, status.Error(codes.Unimplemented, "method QrcodeInfo not implemented") +} func (UnimplementedAnalysisServer) mustEmbedUnimplementedAnalysisServer() {} func (UnimplementedAnalysisServer) testEmbeddedByValue() {} @@ -206,6 +222,24 @@ func _Analysis_Switch_Handler(srv interface{}, ctx context.Context, dec func(int return interceptor(ctx, in, info, handler) } +func _Analysis_QrcodeInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QrcodeInfoReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AnalysisServer).QrcodeInfo(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Analysis_QrcodeInfo_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AnalysisServer).QrcodeInfo(ctx, req.(*QrcodeInfoReq)) + } + return interceptor(ctx, in, info, handler) +} + // Analysis_ServiceDesc is the grpc.ServiceDesc for Analysis service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -229,6 +263,10 @@ var Analysis_ServiceDesc = grpc.ServiceDesc{ MethodName: "Switch", Handler: _Analysis_Switch_Handler, }, + { + MethodName: "QrcodeInfo", + Handler: _Analysis_QrcodeInfo_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "analysis/analysis.proto", @@ -932,10 +970,19 @@ var AnalysisStore_ServiceDesc = grpc.ServiceDesc{ Metadata: "analysis/analysis.proto", } +const ( + AnalysisDevice_Policy_FullMethodName = "/analysis.AnalysisDevice/Policy" + AnalysisDevice_Display_FullMethodName = "/analysis.AnalysisDevice/Display" + AnalysisDevice_OssCallback_FullMethodName = "/analysis.AnalysisDevice/OssCallback" +) + // AnalysisDeviceClient is the client API for AnalysisDevice service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type AnalysisDeviceClient interface { + Policy(ctx context.Context, in *DevicePolicyReq, opts ...grpc.CallOption) (*Response, error) + Display(ctx context.Context, in *DeviceDisplayReq, opts ...grpc.CallOption) (*Response, error) + OssCallback(ctx context.Context, in *OssCallbackReq, opts ...grpc.CallOption) (*OssCallbackResp, error) } type analysisDeviceClient struct { @@ -946,10 +993,43 @@ func NewAnalysisDeviceClient(cc grpc.ClientConnInterface) AnalysisDeviceClient { return &analysisDeviceClient{cc} } +func (c *analysisDeviceClient) Policy(ctx context.Context, in *DevicePolicyReq, opts ...grpc.CallOption) (*Response, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Response) + err := c.cc.Invoke(ctx, AnalysisDevice_Policy_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *analysisDeviceClient) Display(ctx context.Context, in *DeviceDisplayReq, opts ...grpc.CallOption) (*Response, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Response) + err := c.cc.Invoke(ctx, AnalysisDevice_Display_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *analysisDeviceClient) OssCallback(ctx context.Context, in *OssCallbackReq, opts ...grpc.CallOption) (*OssCallbackResp, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(OssCallbackResp) + err := c.cc.Invoke(ctx, AnalysisDevice_OssCallback_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + // AnalysisDeviceServer is the server API for AnalysisDevice service. // All implementations must embed UnimplementedAnalysisDeviceServer // for forward compatibility. type AnalysisDeviceServer interface { + Policy(context.Context, *DevicePolicyReq) (*Response, error) + Display(context.Context, *DeviceDisplayReq) (*Response, error) + OssCallback(context.Context, *OssCallbackReq) (*OssCallbackResp, error) mustEmbedUnimplementedAnalysisDeviceServer() } @@ -960,6 +1040,15 @@ type AnalysisDeviceServer interface { // pointer dereference when methods are called. type UnimplementedAnalysisDeviceServer struct{} +func (UnimplementedAnalysisDeviceServer) Policy(context.Context, *DevicePolicyReq) (*Response, error) { + return nil, status.Error(codes.Unimplemented, "method Policy not implemented") +} +func (UnimplementedAnalysisDeviceServer) Display(context.Context, *DeviceDisplayReq) (*Response, error) { + return nil, status.Error(codes.Unimplemented, "method Display not implemented") +} +func (UnimplementedAnalysisDeviceServer) OssCallback(context.Context, *OssCallbackReq) (*OssCallbackResp, error) { + return nil, status.Error(codes.Unimplemented, "method OssCallback not implemented") +} func (UnimplementedAnalysisDeviceServer) mustEmbedUnimplementedAnalysisDeviceServer() {} func (UnimplementedAnalysisDeviceServer) testEmbeddedByValue() {} @@ -981,13 +1070,80 @@ func RegisterAnalysisDeviceServer(s grpc.ServiceRegistrar, srv AnalysisDeviceSer s.RegisterService(&AnalysisDevice_ServiceDesc, srv) } +func _AnalysisDevice_Policy_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DevicePolicyReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AnalysisDeviceServer).Policy(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: AnalysisDevice_Policy_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AnalysisDeviceServer).Policy(ctx, req.(*DevicePolicyReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _AnalysisDevice_Display_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeviceDisplayReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AnalysisDeviceServer).Display(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: AnalysisDevice_Display_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AnalysisDeviceServer).Display(ctx, req.(*DeviceDisplayReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _AnalysisDevice_OssCallback_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(OssCallbackReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AnalysisDeviceServer).OssCallback(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: AnalysisDevice_OssCallback_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AnalysisDeviceServer).OssCallback(ctx, req.(*OssCallbackReq)) + } + return interceptor(ctx, in, info, handler) +} + // AnalysisDevice_ServiceDesc is the grpc.ServiceDesc for AnalysisDevice service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var AnalysisDevice_ServiceDesc = grpc.ServiceDesc{ ServiceName: "analysis.AnalysisDevice", HandlerType: (*AnalysisDeviceServer)(nil), - Methods: []grpc.MethodDesc{}, - Streams: []grpc.StreamDesc{}, - Metadata: "analysis/analysis.proto", + Methods: []grpc.MethodDesc{ + { + MethodName: "Policy", + Handler: _AnalysisDevice_Policy_Handler, + }, + { + MethodName: "Display", + Handler: _AnalysisDevice_Display_Handler, + }, + { + MethodName: "OssCallback", + Handler: _AnalysisDevice_OssCallback_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "analysis/analysis.proto", } diff --git a/rpc/chore/chore.pb b/rpc/chore/chore.pb index df9ea19..64e7a6b 100644 Binary files a/rpc/chore/chore.pb and b/rpc/chore/chore.pb differ diff --git a/rpc/chore/pb/chore.pb.go b/rpc/chore/pb/chore.pb.go index ecb76f3..10cc818 100644 --- a/rpc/chore/pb/chore.pb.go +++ b/rpc/chore/pb/chore.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.11 -// protoc v4.25.8 +// protoc-gen-go v1.36.12 +// protoc v3.19.4 // source: chore/chore.proto package chore @@ -490,7 +490,7 @@ type OssSignatureReq struct { func (x *OssSignatureReq) Reset() { *x = OssSignatureReq{} - mi := &file_chore_chore_proto_msgTypes[8] + mi := &file_chore_chore_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -502,7 +502,7 @@ func (x *OssSignatureReq) String() string { func (*OssSignatureReq) ProtoMessage() {} func (x *OssSignatureReq) ProtoReflect() protoreflect.Message { - mi := &file_chore_chore_proto_msgTypes[8] + mi := &file_chore_chore_proto_msgTypes[9] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -515,7 +515,7 @@ func (x *OssSignatureReq) ProtoReflect() protoreflect.Message { // Deprecated: Use OssSignatureReq.ProtoReflect.Descriptor instead. func (*OssSignatureReq) Descriptor() ([]byte, []int) { - return file_chore_chore_proto_rawDescGZIP(), []int{8} + return file_chore_chore_proto_rawDescGZIP(), []int{9} } type UploadReq struct { @@ -528,7 +528,7 @@ type UploadReq struct { func (x *UploadReq) Reset() { *x = UploadReq{} - mi := &file_chore_chore_proto_msgTypes[9] + mi := &file_chore_chore_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -540,7 +540,7 @@ func (x *UploadReq) String() string { func (*UploadReq) ProtoMessage() {} func (x *UploadReq) ProtoReflect() protoreflect.Message { - mi := &file_chore_chore_proto_msgTypes[9] + mi := &file_chore_chore_proto_msgTypes[10] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -553,7 +553,7 @@ func (x *UploadReq) ProtoReflect() protoreflect.Message { // Deprecated: Use UploadReq.ProtoReflect.Descriptor instead. func (*UploadReq) Descriptor() ([]byte, []int) { - return file_chore_chore_proto_rawDescGZIP(), []int{9} + return file_chore_chore_proto_rawDescGZIP(), []int{10} } func (x *UploadReq) GetFilename() string { @@ -580,7 +580,7 @@ type InternalUploadReq struct { func (x *InternalUploadReq) Reset() { *x = InternalUploadReq{} - mi := &file_chore_chore_proto_msgTypes[10] + mi := &file_chore_chore_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -592,7 +592,7 @@ func (x *InternalUploadReq) String() string { func (*InternalUploadReq) ProtoMessage() {} func (x *InternalUploadReq) ProtoReflect() protoreflect.Message { - mi := &file_chore_chore_proto_msgTypes[10] + mi := &file_chore_chore_proto_msgTypes[11] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -605,7 +605,7 @@ func (x *InternalUploadReq) ProtoReflect() protoreflect.Message { // Deprecated: Use InternalUploadReq.ProtoReflect.Descriptor instead. func (*InternalUploadReq) Descriptor() ([]byte, []int) { - return file_chore_chore_proto_rawDescGZIP(), []int{10} + return file_chore_chore_proto_rawDescGZIP(), []int{11} } func (x *InternalUploadReq) GetFilename() string { @@ -633,7 +633,7 @@ type InternalUploadData struct { func (x *InternalUploadData) Reset() { *x = InternalUploadData{} - mi := &file_chore_chore_proto_msgTypes[11] + mi := &file_chore_chore_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -645,7 +645,7 @@ func (x *InternalUploadData) String() string { func (*InternalUploadData) ProtoMessage() {} func (x *InternalUploadData) ProtoReflect() protoreflect.Message { - mi := &file_chore_chore_proto_msgTypes[11] + mi := &file_chore_chore_proto_msgTypes[12] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -658,7 +658,7 @@ func (x *InternalUploadData) ProtoReflect() protoreflect.Message { // Deprecated: Use InternalUploadData.ProtoReflect.Descriptor instead. func (*InternalUploadData) Descriptor() ([]byte, []int) { - return file_chore_chore_proto_rawDescGZIP(), []int{11} + return file_chore_chore_proto_rawDescGZIP(), []int{12} } func (x *InternalUploadData) GetUrl() string { @@ -694,7 +694,7 @@ type TestReq struct { func (x *TestReq) Reset() { *x = TestReq{} - mi := &file_chore_chore_proto_msgTypes[12] + mi := &file_chore_chore_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -706,7 +706,7 @@ func (x *TestReq) String() string { func (*TestReq) ProtoMessage() {} func (x *TestReq) ProtoReflect() protoreflect.Message { - mi := &file_chore_chore_proto_msgTypes[12] + mi := &file_chore_chore_proto_msgTypes[13] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -719,7 +719,7 @@ func (x *TestReq) ProtoReflect() protoreflect.Message { // Deprecated: Use TestReq.ProtoReflect.Descriptor instead. func (*TestReq) Descriptor() ([]byte, []int) { - return file_chore_chore_proto_rawDescGZIP(), []int{12} + return file_chore_chore_proto_rawDescGZIP(), []int{13} } func (x *TestReq) GetId() int32 { @@ -759,7 +759,7 @@ type DecryptMobileReq struct { func (x *DecryptMobileReq) Reset() { *x = DecryptMobileReq{} - mi := &file_chore_chore_proto_msgTypes[13] + mi := &file_chore_chore_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -771,7 +771,7 @@ func (x *DecryptMobileReq) String() string { func (*DecryptMobileReq) ProtoMessage() {} func (x *DecryptMobileReq) ProtoReflect() protoreflect.Message { - mi := &file_chore_chore_proto_msgTypes[13] + mi := &file_chore_chore_proto_msgTypes[14] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -784,7 +784,7 @@ func (x *DecryptMobileReq) ProtoReflect() protoreflect.Message { // Deprecated: Use DecryptMobileReq.ProtoReflect.Descriptor instead. func (*DecryptMobileReq) Descriptor() ([]byte, []int) { - return file_chore_chore_proto_rawDescGZIP(), []int{13} + return file_chore_chore_proto_rawDescGZIP(), []int{14} } func (x *DecryptMobileReq) GetOriginMobile() string { @@ -803,7 +803,7 @@ type RegionsReq struct { func (x *RegionsReq) Reset() { *x = RegionsReq{} - mi := &file_chore_chore_proto_msgTypes[14] + mi := &file_chore_chore_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -815,7 +815,7 @@ func (x *RegionsReq) String() string { func (*RegionsReq) ProtoMessage() {} func (x *RegionsReq) ProtoReflect() protoreflect.Message { - mi := &file_chore_chore_proto_msgTypes[14] + mi := &file_chore_chore_proto_msgTypes[15] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -828,7 +828,7 @@ func (x *RegionsReq) ProtoReflect() protoreflect.Message { // Deprecated: Use RegionsReq.ProtoReflect.Descriptor instead. func (*RegionsReq) Descriptor() ([]byte, []int) { - return file_chore_chore_proto_rawDescGZIP(), []int{14} + return file_chore_chore_proto_rawDescGZIP(), []int{15} } func (x *RegionsReq) GetParentId() int32 { @@ -847,7 +847,7 @@ type RegionsByIdsReq struct { func (x *RegionsByIdsReq) Reset() { *x = RegionsByIdsReq{} - mi := &file_chore_chore_proto_msgTypes[15] + mi := &file_chore_chore_proto_msgTypes[16] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -859,7 +859,7 @@ func (x *RegionsByIdsReq) String() string { func (*RegionsByIdsReq) ProtoMessage() {} func (x *RegionsByIdsReq) ProtoReflect() protoreflect.Message { - mi := &file_chore_chore_proto_msgTypes[15] + mi := &file_chore_chore_proto_msgTypes[16] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -872,7 +872,7 @@ func (x *RegionsByIdsReq) ProtoReflect() protoreflect.Message { // Deprecated: Use RegionsByIdsReq.ProtoReflect.Descriptor instead. func (*RegionsByIdsReq) Descriptor() ([]byte, []int) { - return file_chore_chore_proto_rawDescGZIP(), []int{15} + return file_chore_chore_proto_rawDescGZIP(), []int{16} } func (x *RegionsByIdsReq) GetIds() []int64 { @@ -892,7 +892,7 @@ type RegionItem struct { func (x *RegionItem) Reset() { *x = RegionItem{} - mi := &file_chore_chore_proto_msgTypes[16] + mi := &file_chore_chore_proto_msgTypes[17] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -904,7 +904,7 @@ func (x *RegionItem) String() string { func (*RegionItem) ProtoMessage() {} func (x *RegionItem) ProtoReflect() protoreflect.Message { - mi := &file_chore_chore_proto_msgTypes[16] + mi := &file_chore_chore_proto_msgTypes[17] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -917,7 +917,7 @@ func (x *RegionItem) ProtoReflect() protoreflect.Message { // Deprecated: Use RegionItem.ProtoReflect.Descriptor instead. func (*RegionItem) Descriptor() ([]byte, []int) { - return file_chore_chore_proto_rawDescGZIP(), []int{16} + return file_chore_chore_proto_rawDescGZIP(), []int{17} } func (x *RegionItem) GetId() int64 { @@ -943,7 +943,7 @@ type RegionsByIdsData struct { func (x *RegionsByIdsData) Reset() { *x = RegionsByIdsData{} - mi := &file_chore_chore_proto_msgTypes[17] + mi := &file_chore_chore_proto_msgTypes[18] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -955,7 +955,7 @@ func (x *RegionsByIdsData) String() string { func (*RegionsByIdsData) ProtoMessage() {} func (x *RegionsByIdsData) ProtoReflect() protoreflect.Message { - mi := &file_chore_chore_proto_msgTypes[17] + mi := &file_chore_chore_proto_msgTypes[18] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -968,7 +968,7 @@ func (x *RegionsByIdsData) ProtoReflect() protoreflect.Message { // Deprecated: Use RegionsByIdsData.ProtoReflect.Descriptor instead. func (*RegionsByIdsData) Descriptor() ([]byte, []int) { - return file_chore_chore_proto_rawDescGZIP(), []int{17} + return file_chore_chore_proto_rawDescGZIP(), []int{18} } func (x *RegionsByIdsData) GetItems() []*RegionItem { @@ -988,7 +988,7 @@ type SendSmsReq struct { func (x *SendSmsReq) Reset() { *x = SendSmsReq{} - mi := &file_chore_chore_proto_msgTypes[18] + mi := &file_chore_chore_proto_msgTypes[19] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1000,7 +1000,7 @@ func (x *SendSmsReq) String() string { func (*SendSmsReq) ProtoMessage() {} func (x *SendSmsReq) ProtoReflect() protoreflect.Message { - mi := &file_chore_chore_proto_msgTypes[18] + mi := &file_chore_chore_proto_msgTypes[19] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1013,7 +1013,7 @@ func (x *SendSmsReq) ProtoReflect() protoreflect.Message { // Deprecated: Use SendSmsReq.ProtoReflect.Descriptor instead. func (*SendSmsReq) Descriptor() ([]byte, []int) { - return file_chore_chore_proto_rawDescGZIP(), []int{18} + return file_chore_chore_proto_rawDescGZIP(), []int{19} } func (x *SendSmsReq) GetMobile() string { @@ -1043,7 +1043,7 @@ type InternalActionApplyLogCreateReq struct { func (x *InternalActionApplyLogCreateReq) Reset() { *x = InternalActionApplyLogCreateReq{} - mi := &file_chore_chore_proto_msgTypes[19] + mi := &file_chore_chore_proto_msgTypes[20] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1055,7 +1055,7 @@ func (x *InternalActionApplyLogCreateReq) String() string { func (*InternalActionApplyLogCreateReq) ProtoMessage() {} func (x *InternalActionApplyLogCreateReq) ProtoReflect() protoreflect.Message { - mi := &file_chore_chore_proto_msgTypes[19] + mi := &file_chore_chore_proto_msgTypes[20] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1068,7 +1068,7 @@ func (x *InternalActionApplyLogCreateReq) ProtoReflect() protoreflect.Message { // Deprecated: Use InternalActionApplyLogCreateReq.ProtoReflect.Descriptor instead. func (*InternalActionApplyLogCreateReq) Descriptor() ([]byte, []int) { - return file_chore_chore_proto_rawDescGZIP(), []int{19} + return file_chore_chore_proto_rawDescGZIP(), []int{20} } func (x *InternalActionApplyLogCreateReq) GetAdminId() int64 { @@ -1115,7 +1115,7 @@ type InternalActionApplyLogCreateData struct { func (x *InternalActionApplyLogCreateData) Reset() { *x = InternalActionApplyLogCreateData{} - mi := &file_chore_chore_proto_msgTypes[20] + mi := &file_chore_chore_proto_msgTypes[21] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1127,7 +1127,7 @@ func (x *InternalActionApplyLogCreateData) String() string { func (*InternalActionApplyLogCreateData) ProtoMessage() {} func (x *InternalActionApplyLogCreateData) ProtoReflect() protoreflect.Message { - mi := &file_chore_chore_proto_msgTypes[20] + mi := &file_chore_chore_proto_msgTypes[21] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1140,7 +1140,7 @@ func (x *InternalActionApplyLogCreateData) ProtoReflect() protoreflect.Message { // Deprecated: Use InternalActionApplyLogCreateData.ProtoReflect.Descriptor instead. func (*InternalActionApplyLogCreateData) Descriptor() ([]byte, []int) { - return file_chore_chore_proto_rawDescGZIP(), []int{20} + return file_chore_chore_proto_rawDescGZIP(), []int{21} } func (x *InternalActionApplyLogCreateData) GetId() int64 { @@ -1163,7 +1163,7 @@ type SendPasswordReq struct { func (x *SendPasswordReq) Reset() { *x = SendPasswordReq{} - mi := &file_chore_chore_proto_msgTypes[21] + mi := &file_chore_chore_proto_msgTypes[22] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1175,7 +1175,7 @@ func (x *SendPasswordReq) String() string { func (*SendPasswordReq) ProtoMessage() {} func (x *SendPasswordReq) ProtoReflect() protoreflect.Message { - mi := &file_chore_chore_proto_msgTypes[21] + mi := &file_chore_chore_proto_msgTypes[22] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1188,7 +1188,7 @@ func (x *SendPasswordReq) ProtoReflect() protoreflect.Message { // Deprecated: Use SendPasswordReq.ProtoReflect.Descriptor instead. func (*SendPasswordReq) Descriptor() ([]byte, []int) { - return file_chore_chore_proto_rawDescGZIP(), []int{21} + return file_chore_chore_proto_rawDescGZIP(), []int{22} } func (x *SendPasswordReq) GetMobile() string { @@ -1235,7 +1235,7 @@ type SendPasswordResp struct { func (x *SendPasswordResp) Reset() { *x = SendPasswordResp{} - mi := &file_chore_chore_proto_msgTypes[22] + mi := &file_chore_chore_proto_msgTypes[23] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1247,7 +1247,7 @@ func (x *SendPasswordResp) String() string { func (*SendPasswordResp) ProtoMessage() {} func (x *SendPasswordResp) ProtoReflect() protoreflect.Message { - mi := &file_chore_chore_proto_msgTypes[22] + mi := &file_chore_chore_proto_msgTypes[23] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1260,7 +1260,7 @@ func (x *SendPasswordResp) ProtoReflect() protoreflect.Message { // Deprecated: Use SendPasswordResp.ProtoReflect.Descriptor instead. func (*SendPasswordResp) Descriptor() ([]byte, []int) { - return file_chore_chore_proto_rawDescGZIP(), []int{22} + return file_chore_chore_proto_rawDescGZIP(), []int{23} } func (x *SendPasswordResp) GetCode() int32 { @@ -1350,11 +1350,7 @@ const file_chore_chore_proto_rawDesc = "" + "\x02ip\x18\x04 \x01(\tR\x02ip\x12!\n" + "\fbrowser_name\x18\x05 \x01(\tR\vbrowserName\"&\n" + "\x10SendPasswordResp\x12\x12\n" + -<<<<<<< HEAD - "\x04code\x18\x01 \x01(\x05R\x04code2\x8c\x10\n" + -======= - "\x04code\x18\x01 \x01(\x05R\x04code2\x9b\r\n" + ->>>>>>> 5a3d66df250ad0fd3567ed512701f43a521951c6 + "\x04code\x18\x01 \x01(\x05R\x04code2\xed\x10\n" + "\x05Chore\x12P\n" + "\x06Policy\x12\x10.chore.PolicyReq\x1a\x0f.chore.Response\"#\x82\xd3\xe4\x93\x02\x1d:\x01*\x12\x18/api/v3/chore/oss/policy\x12P\n" + "\x06Upload\x12\x10.chore.UploadReq\x1a\x0f.chore.Response\"#\x82\xd3\xe4\x93\x02\x1d:\x01*\"\x18/api/v3/chore/oss/upload\x12_\n" + @@ -1398,7 +1394,7 @@ func file_chore_chore_proto_rawDescGZIP() []byte { return file_chore_chore_proto_rawDescData } -var file_chore_chore_proto_msgTypes = make([]protoimpl.MessageInfo, 23) +var file_chore_chore_proto_msgTypes = make([]protoimpl.MessageInfo, 24) var file_chore_chore_proto_goTypes = []any{ (*Response)(nil), // 0: chore.Response (*EmptyReq)(nil), // 1: chore.EmptyReq @@ -1406,127 +1402,79 @@ var file_chore_chore_proto_goTypes = []any{ (*StatusReq)(nil), // 3: chore.StatusReq (*EditReq)(nil), // 4: chore.EditReq (*SystemEditReq)(nil), // 5: chore.SystemEditReq -<<<<<<< HEAD (*ApiSystemReq)(nil), // 6: chore.ApiSystemReq (*DocumentReq)(nil), // 7: chore.DocumentReq (*PolicyReq)(nil), // 8: chore.PolicyReq -======= - (*DocumentReq)(nil), // 6: chore.DocumentReq - (*PolicyReq)(nil), // 7: chore.PolicyReq - (*OssSignatureReq)(nil), // 8: chore.OssSignatureReq ->>>>>>> 5a3d66df250ad0fd3567ed512701f43a521951c6 - (*UploadReq)(nil), // 9: chore.UploadReq - (*InternalUploadReq)(nil), // 10: chore.InternalUploadReq - (*InternalUploadData)(nil), // 11: chore.InternalUploadData - (*TestReq)(nil), // 12: chore.TestReq - (*DecryptMobileReq)(nil), // 13: chore.DecryptMobileReq - (*RegionsReq)(nil), // 14: chore.RegionsReq - (*RegionsByIdsReq)(nil), // 15: chore.RegionsByIdsReq - (*RegionItem)(nil), // 16: chore.RegionItem - (*RegionsByIdsData)(nil), // 17: chore.RegionsByIdsData - (*SendSmsReq)(nil), // 18: chore.SendSmsReq - (*InternalActionApplyLogCreateReq)(nil), // 19: chore.InternalActionApplyLogCreateReq - (*InternalActionApplyLogCreateData)(nil), // 20: chore.InternalActionApplyLogCreateData - (*SendPasswordReq)(nil), // 21: chore.SendPasswordReq - (*SendPasswordResp)(nil), // 22: chore.SendPasswordResp + (*OssSignatureReq)(nil), // 9: chore.OssSignatureReq + (*UploadReq)(nil), // 10: chore.UploadReq + (*InternalUploadReq)(nil), // 11: chore.InternalUploadReq + (*InternalUploadData)(nil), // 12: chore.InternalUploadData + (*TestReq)(nil), // 13: chore.TestReq + (*DecryptMobileReq)(nil), // 14: chore.DecryptMobileReq + (*RegionsReq)(nil), // 15: chore.RegionsReq + (*RegionsByIdsReq)(nil), // 16: chore.RegionsByIdsReq + (*RegionItem)(nil), // 17: chore.RegionItem + (*RegionsByIdsData)(nil), // 18: chore.RegionsByIdsData + (*SendSmsReq)(nil), // 19: chore.SendSmsReq + (*InternalActionApplyLogCreateReq)(nil), // 20: chore.InternalActionApplyLogCreateReq + (*InternalActionApplyLogCreateData)(nil), // 21: chore.InternalActionApplyLogCreateData + (*SendPasswordReq)(nil), // 22: chore.SendPasswordReq + (*SendPasswordResp)(nil), // 23: chore.SendPasswordResp } var file_chore_chore_proto_depIdxs = []int32{ - 16, // 0: chore.RegionsByIdsData.items:type_name -> chore.RegionItem -<<<<<<< HEAD + 17, // 0: chore.RegionsByIdsData.items:type_name -> chore.RegionItem 8, // 1: chore.Chore.Policy:input_type -> chore.PolicyReq - 9, // 2: chore.Chore.Upload:input_type -> chore.UploadReq - 12, // 3: chore.Chore.Test:input_type -> chore.TestReq - 13, // 4: chore.Chore.DecryptMobile:input_type -> chore.DecryptMobileReq - 14, // 5: chore.Chore.Regions:input_type -> chore.RegionsReq - 18, // 6: chore.Chore.SendSms:input_type -> chore.SendSmsReq - 6, // 7: chore.Chore.ApiSystemItems:input_type -> chore.ApiSystemReq - 6, // 8: chore.Chore.ApiSystemInfo:input_type -> chore.ApiSystemReq - 1, // 9: chore.Chore.ApiAnswerItems:input_type -> chore.EmptyReq - 1, // 10: chore.Chore.ApiAnswerIProgress:input_type -> chore.EmptyReq - 1, // 11: chore.Chore.ApiAnswerSave:input_type -> chore.EmptyReq - 1, // 12: chore.Chore.AnswerItems:input_type -> chore.EmptyReq - 3, // 13: chore.Chore.AnswerStatus:input_type -> chore.StatusReq - 2, // 14: chore.Chore.AnswerInfo:input_type -> chore.IdReq - 4, // 15: chore.Chore.AnswerCreate:input_type -> chore.EditReq - 4, // 16: chore.Chore.AnswerEdit:input_type -> chore.EditReq - 5, // 17: chore.Chore.SystemEdit:input_type -> chore.SystemEditReq - 3, // 18: chore.Chore.SystemStatus:input_type -> chore.StatusReq - 2, // 19: chore.Chore.SystemInfo:input_type -> chore.IdReq - 1, // 20: chore.Chore.SystemItems:input_type -> chore.EmptyReq - 10, // 21: chore.Chore.InternalUpload:input_type -> chore.InternalUploadReq - 15, // 22: chore.Chore.RegionsByIds:input_type -> chore.RegionsByIdsReq - 19, // 23: chore.Chore.InternalActionApplyLogCreate:input_type -> chore.InternalActionApplyLogCreateReq - 21, // 24: chore.Chore.SendPassword:input_type -> chore.SendPasswordReq - 0, // 25: chore.Chore.Policy:output_type -> chore.Response - 0, // 26: chore.Chore.Upload:output_type -> chore.Response - 0, // 27: chore.Chore.Test:output_type -> chore.Response - 0, // 28: chore.Chore.DecryptMobile:output_type -> chore.Response - 0, // 29: chore.Chore.Regions:output_type -> chore.Response - 0, // 30: chore.Chore.SendSms:output_type -> chore.Response - 0, // 31: chore.Chore.ApiSystemItems:output_type -> chore.Response - 0, // 32: chore.Chore.ApiSystemInfo:output_type -> chore.Response - 0, // 33: chore.Chore.ApiAnswerItems:output_type -> chore.Response - 0, // 34: chore.Chore.ApiAnswerIProgress:output_type -> chore.Response - 0, // 35: chore.Chore.ApiAnswerSave:output_type -> chore.Response - 0, // 36: chore.Chore.AnswerItems:output_type -> chore.Response - 0, // 37: chore.Chore.AnswerStatus:output_type -> chore.Response - 0, // 38: chore.Chore.AnswerInfo:output_type -> chore.Response - 0, // 39: chore.Chore.AnswerCreate:output_type -> chore.Response - 0, // 40: chore.Chore.AnswerEdit:output_type -> chore.Response - 0, // 41: chore.Chore.SystemEdit:output_type -> chore.Response - 0, // 42: chore.Chore.SystemStatus:output_type -> chore.Response - 0, // 43: chore.Chore.SystemInfo:output_type -> chore.Response - 0, // 44: chore.Chore.SystemItems:output_type -> chore.Response - 11, // 45: chore.Chore.InternalUpload:output_type -> chore.InternalUploadData - 17, // 46: chore.Chore.RegionsByIds:output_type -> chore.RegionsByIdsData - 20, // 47: chore.Chore.InternalActionApplyLogCreate:output_type -> chore.InternalActionApplyLogCreateData - 22, // 48: chore.Chore.SendPassword:output_type -> chore.SendPasswordResp - 25, // [25:49] is the sub-list for method output_type - 1, // [1:25] is the sub-list for method input_type -======= - 7, // 1: chore.Chore.Policy:input_type -> chore.PolicyReq - 9, // 2: chore.Chore.Upload:input_type -> chore.UploadReq - 8, // 3: chore.Chore.OssSignature:input_type -> chore.OssSignatureReq - 12, // 4: chore.Chore.Test:input_type -> chore.TestReq - 13, // 5: chore.Chore.DecryptMobile:input_type -> chore.DecryptMobileReq - 14, // 6: chore.Chore.Regions:input_type -> chore.RegionsReq - 18, // 7: chore.Chore.SendSms:input_type -> chore.SendSmsReq - 1, // 8: chore.Chore.AnswerItems:input_type -> chore.EmptyReq - 3, // 9: chore.Chore.AnswerStatus:input_type -> chore.StatusReq - 2, // 10: chore.Chore.AnswerInfo:input_type -> chore.IdReq - 4, // 11: chore.Chore.AnswerCreate:input_type -> chore.EditReq - 4, // 12: chore.Chore.AnswerEdit:input_type -> chore.EditReq - 5, // 13: chore.Chore.SystemEdit:input_type -> chore.SystemEditReq - 3, // 14: chore.Chore.SystemStatus:input_type -> chore.StatusReq - 2, // 15: chore.Chore.SystemInfo:input_type -> chore.IdReq - 1, // 16: chore.Chore.SystemItems:input_type -> chore.EmptyReq - 10, // 17: chore.Chore.InternalUpload:input_type -> chore.InternalUploadReq - 15, // 18: chore.Chore.RegionsByIds:input_type -> chore.RegionsByIdsReq - 19, // 19: chore.Chore.InternalActionApplyLogCreate:input_type -> chore.InternalActionApplyLogCreateReq - 21, // 20: chore.Chore.SendPassword:input_type -> chore.SendPasswordReq - 0, // 21: chore.Chore.Policy:output_type -> chore.Response - 0, // 22: chore.Chore.Upload:output_type -> chore.Response - 0, // 23: chore.Chore.OssSignature:output_type -> chore.Response - 0, // 24: chore.Chore.Test:output_type -> chore.Response - 0, // 25: chore.Chore.DecryptMobile:output_type -> chore.Response - 0, // 26: chore.Chore.Regions:output_type -> chore.Response - 0, // 27: chore.Chore.SendSms:output_type -> chore.Response - 0, // 28: chore.Chore.AnswerItems:output_type -> chore.Response - 0, // 29: chore.Chore.AnswerStatus:output_type -> chore.Response - 0, // 30: chore.Chore.AnswerInfo:output_type -> chore.Response - 0, // 31: chore.Chore.AnswerCreate:output_type -> chore.Response - 0, // 32: chore.Chore.AnswerEdit:output_type -> chore.Response - 0, // 33: chore.Chore.SystemEdit:output_type -> chore.Response - 0, // 34: chore.Chore.SystemStatus:output_type -> chore.Response - 0, // 35: chore.Chore.SystemInfo:output_type -> chore.Response - 0, // 36: chore.Chore.SystemItems:output_type -> chore.Response - 11, // 37: chore.Chore.InternalUpload:output_type -> chore.InternalUploadData - 17, // 38: chore.Chore.RegionsByIds:output_type -> chore.RegionsByIdsData - 20, // 39: chore.Chore.InternalActionApplyLogCreate:output_type -> chore.InternalActionApplyLogCreateData - 22, // 40: chore.Chore.SendPassword:output_type -> chore.SendPasswordResp - 21, // [21:41] is the sub-list for method output_type - 1, // [1:21] is the sub-list for method input_type ->>>>>>> 5a3d66df250ad0fd3567ed512701f43a521951c6 + 10, // 2: chore.Chore.Upload:input_type -> chore.UploadReq + 9, // 3: chore.Chore.OssSignature:input_type -> chore.OssSignatureReq + 13, // 4: chore.Chore.Test:input_type -> chore.TestReq + 14, // 5: chore.Chore.DecryptMobile:input_type -> chore.DecryptMobileReq + 15, // 6: chore.Chore.Regions:input_type -> chore.RegionsReq + 19, // 7: chore.Chore.SendSms:input_type -> chore.SendSmsReq + 6, // 8: chore.Chore.ApiSystemItems:input_type -> chore.ApiSystemReq + 6, // 9: chore.Chore.ApiSystemInfo:input_type -> chore.ApiSystemReq + 1, // 10: chore.Chore.ApiAnswerItems:input_type -> chore.EmptyReq + 1, // 11: chore.Chore.ApiAnswerIProgress:input_type -> chore.EmptyReq + 1, // 12: chore.Chore.ApiAnswerSave:input_type -> chore.EmptyReq + 1, // 13: chore.Chore.AnswerItems:input_type -> chore.EmptyReq + 3, // 14: chore.Chore.AnswerStatus:input_type -> chore.StatusReq + 2, // 15: chore.Chore.AnswerInfo:input_type -> chore.IdReq + 4, // 16: chore.Chore.AnswerCreate:input_type -> chore.EditReq + 4, // 17: chore.Chore.AnswerEdit:input_type -> chore.EditReq + 5, // 18: chore.Chore.SystemEdit:input_type -> chore.SystemEditReq + 3, // 19: chore.Chore.SystemStatus:input_type -> chore.StatusReq + 2, // 20: chore.Chore.SystemInfo:input_type -> chore.IdReq + 1, // 21: chore.Chore.SystemItems:input_type -> chore.EmptyReq + 11, // 22: chore.Chore.InternalUpload:input_type -> chore.InternalUploadReq + 16, // 23: chore.Chore.RegionsByIds:input_type -> chore.RegionsByIdsReq + 20, // 24: chore.Chore.InternalActionApplyLogCreate:input_type -> chore.InternalActionApplyLogCreateReq + 22, // 25: chore.Chore.SendPassword:input_type -> chore.SendPasswordReq + 0, // 26: chore.Chore.Policy:output_type -> chore.Response + 0, // 27: chore.Chore.Upload:output_type -> chore.Response + 0, // 28: chore.Chore.OssSignature:output_type -> chore.Response + 0, // 29: chore.Chore.Test:output_type -> chore.Response + 0, // 30: chore.Chore.DecryptMobile:output_type -> chore.Response + 0, // 31: chore.Chore.Regions:output_type -> chore.Response + 0, // 32: chore.Chore.SendSms:output_type -> chore.Response + 0, // 33: chore.Chore.ApiSystemItems:output_type -> chore.Response + 0, // 34: chore.Chore.ApiSystemInfo:output_type -> chore.Response + 0, // 35: chore.Chore.ApiAnswerItems:output_type -> chore.Response + 0, // 36: chore.Chore.ApiAnswerIProgress:output_type -> chore.Response + 0, // 37: chore.Chore.ApiAnswerSave:output_type -> chore.Response + 0, // 38: chore.Chore.AnswerItems:output_type -> chore.Response + 0, // 39: chore.Chore.AnswerStatus:output_type -> chore.Response + 0, // 40: chore.Chore.AnswerInfo:output_type -> chore.Response + 0, // 41: chore.Chore.AnswerCreate:output_type -> chore.Response + 0, // 42: chore.Chore.AnswerEdit:output_type -> chore.Response + 0, // 43: chore.Chore.SystemEdit:output_type -> chore.Response + 0, // 44: chore.Chore.SystemStatus:output_type -> chore.Response + 0, // 45: chore.Chore.SystemInfo:output_type -> chore.Response + 0, // 46: chore.Chore.SystemItems:output_type -> chore.Response + 12, // 47: chore.Chore.InternalUpload:output_type -> chore.InternalUploadData + 18, // 48: chore.Chore.RegionsByIds:output_type -> chore.RegionsByIdsData + 21, // 49: chore.Chore.InternalActionApplyLogCreate:output_type -> chore.InternalActionApplyLogCreateData + 23, // 50: chore.Chore.SendPassword:output_type -> chore.SendPasswordResp + 26, // [26:51] is the sub-list for method output_type + 1, // [1:26] is the sub-list for method input_type 1, // [1:1] is the sub-list for extension type_name 1, // [1:1] is the sub-list for extension extendee 0, // [0:1] is the sub-list for field type_name @@ -1543,7 +1491,7 @@ func file_chore_chore_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_chore_chore_proto_rawDesc), len(file_chore_chore_proto_rawDesc)), NumEnums: 0, - NumMessages: 23, + NumMessages: 24, NumExtensions: 0, NumServices: 1, }, diff --git a/rpc/chore/pb/chore_grpc.pb.go b/rpc/chore/pb/chore_grpc.pb.go index c760382..536a9d2 100644 --- a/rpc/chore/pb/chore_grpc.pb.go +++ b/rpc/chore/pb/chore_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.6.2 -// - protoc v4.25.8 +// - protoc v3.19.4 // source: chore/chore.proto package chore @@ -52,7 +52,6 @@ const ( type ChoreClient interface { Policy(ctx context.Context, in *PolicyReq, opts ...grpc.CallOption) (*Response, error) Upload(ctx context.Context, in *UploadReq, opts ...grpc.CallOption) (*Response, error) - // 微信小程序直传 OSS 所需的 PostObject V4 签名参数 OssSignature(ctx context.Context, in *OssSignatureReq, opts ...grpc.CallOption) (*Response, error) Test(ctx context.Context, in *TestReq, opts ...grpc.CallOption) (*Response, error) DecryptMobile(ctx context.Context, in *DecryptMobileReq, opts ...grpc.CallOption) (*Response, error) @@ -343,7 +342,6 @@ func (c *choreClient) SendPassword(ctx context.Context, in *SendPasswordReq, opt type ChoreServer interface { Policy(context.Context, *PolicyReq) (*Response, error) Upload(context.Context, *UploadReq) (*Response, error) - // 微信小程序直传 OSS 所需的 PostObject V4 签名参数 OssSignature(context.Context, *OssSignatureReq) (*Response, error) Test(context.Context, *TestReq) (*Response, error) DecryptMobile(context.Context, *DecryptMobileReq) (*Response, error) diff --git a/services/analysis/client/analysis/analysis.go b/services/analysis/client/analysis/analysis.go index 3f36c75..2f6514c 100644 --- a/services/analysis/client/analysis/analysis.go +++ b/services/analysis/client/analysis/analysis.go @@ -19,6 +19,7 @@ type ( InternalCreateUserReq = analysis.InternalCreateUserReq InternalSetRegisteredData = analysis.InternalSetRegisteredData InternalSetRegisteredReq = analysis.InternalSetRegisteredReq + QrcodeInfoReq = analysis.QrcodeInfoReq Response = analysis.Response SwitchReq = analysis.SwitchReq @@ -27,6 +28,7 @@ type ( InternalSetRegistered(ctx context.Context, in *InternalSetRegisteredReq, opts ...grpc.CallOption) (*InternalSetRegisteredData, error) AgreementInfo(ctx context.Context, in *AgreementInfoReq, opts ...grpc.CallOption) (*Response, error) Switch(ctx context.Context, in *SwitchReq, opts ...grpc.CallOption) (*Response, error) + QrcodeInfo(ctx context.Context, in *QrcodeInfoReq, opts ...grpc.CallOption) (*Response, error) } defaultAnalysis struct { @@ -59,3 +61,8 @@ func (m *defaultAnalysis) Switch(ctx context.Context, in *SwitchReq, opts ...grp client := analysis.NewAnalysisClient(m.cli.Conn()) return client.Switch(ctx, in, opts...) } + +func (m *defaultAnalysis) QrcodeInfo(ctx context.Context, in *QrcodeInfoReq, opts ...grpc.CallOption) (*Response, error) { + client := analysis.NewAnalysisClient(m.cli.Conn()) + return client.QrcodeInfo(ctx, in, opts...) +} diff --git a/services/analysis/client/analysisdevice/analysisDevice.go b/services/analysis/client/analysisdevice/analysisDevice.go index eb8a0bf..3e660ef 100644 --- a/services/analysis/client/analysisdevice/analysisDevice.go +++ b/services/analysis/client/analysisdevice/analysisDevice.go @@ -5,11 +5,25 @@ package analysisdevice import ( + "context" + + "lone-services/rpc/analysis/pb" + "github.com/zeromicro/go-zero/zrpc" + "google.golang.org/grpc" ) type ( + DeviceDisplayReq = analysis.DeviceDisplayReq + DevicePolicyReq = analysis.DevicePolicyReq + OssCallbackReq = analysis.OssCallbackReq + OssCallbackResp = analysis.OssCallbackResp + Response = analysis.Response + AnalysisDevice interface { + Policy(ctx context.Context, in *DevicePolicyReq, opts ...grpc.CallOption) (*Response, error) + Display(ctx context.Context, in *DeviceDisplayReq, opts ...grpc.CallOption) (*Response, error) + OssCallback(ctx context.Context, in *OssCallbackReq, opts ...grpc.CallOption) (*OssCallbackResp, error) } defaultAnalysisDevice struct { @@ -22,3 +36,18 @@ func NewAnalysisDevice(cli zrpc.Client) AnalysisDevice { cli: cli, } } + +func (m *defaultAnalysisDevice) Policy(ctx context.Context, in *DevicePolicyReq, opts ...grpc.CallOption) (*Response, error) { + client := analysis.NewAnalysisDeviceClient(m.cli.Conn()) + return client.Policy(ctx, in, opts...) +} + +func (m *defaultAnalysisDevice) Display(ctx context.Context, in *DeviceDisplayReq, opts ...grpc.CallOption) (*Response, error) { + client := analysis.NewAnalysisDeviceClient(m.cli.Conn()) + return client.Display(ctx, in, opts...) +} + +func (m *defaultAnalysisDevice) OssCallback(ctx context.Context, in *OssCallbackReq, opts ...grpc.CallOption) (*OssCallbackResp, error) { + client := analysis.NewAnalysisDeviceClient(m.cli.Conn()) + return client.OssCallback(ctx, in, opts...) +} diff --git a/services/analysis/internal/callback/download.go b/services/analysis/internal/callback/download.go new file mode 100644 index 0000000..eb083d2 --- /dev/null +++ b/services/analysis/internal/callback/download.go @@ -0,0 +1,56 @@ +package callback + +import ( + "fmt" + "io" + "net/http" + "net/url" + "os" + + "lone-services/pkg/utils" +) + +func BuildDownloadURL(object string) (string, error) { + endpoint := utils.GetConfigString("oss.internalEndpoint") + if endpoint == utils.StringEmpty { + endpoint = utils.GetConfigString("oss.endpoint") + } + if endpoint == utils.StringEmpty { + return utils.StringEmpty, fmt.Errorf("oss endpoint empty") + } + return url.JoinPath(endpoint, object) +} + +func DownloadFile(fileURL, destPath string) error { + resp, err := http.Get(fileURL) + if err != nil { + return err + } + defer resp.Body.Close() + + if resp.StatusCode != http.StatusOK { + return fmt.Errorf("http status %d", resp.StatusCode) + } + + tmpPath := destPath + ".tmp" + out, err := os.Create(tmpPath) + if err != nil { + return err + } + + _, copyErr := io.Copy(out, resp.Body) + closeErr := out.Close() + if copyErr != nil { + _ = os.Remove(tmpPath) + return copyErr + } + if closeErr != nil { + _ = os.Remove(tmpPath) + return closeErr + } + if err = os.Rename(tmpPath, destPath); err != nil { + _ = os.Remove(tmpPath) + return err + } + return nil +} diff --git a/services/analysis/internal/callback/lights.go b/services/analysis/internal/callback/lights.go new file mode 100644 index 0000000..98f183f --- /dev/null +++ b/services/analysis/internal/callback/lights.go @@ -0,0 +1,60 @@ +package callback + +import ( + "context" + "os" + "path/filepath" + "strings" + "time" + + "lone-services/pkg/redis" + "lone-services/pkg/utils" + pkgws "lone-services/pkg/ws" +) + +func CacheUploadedLights(taskID, finalDir string) error { + files, err := os.ReadDir(finalDir) + if err != nil { + return err + } + + seen := make(map[string]struct{}) + lights := make([]interface{}, 0) + for _, file := range files { + if file.IsDir() { + continue + } + light := lightingTypeFromFileName(file.Name()) + if light == utils.StringEmpty { + continue + } + if _, ok := seen[light]; ok { + continue + } + seen[light] = struct{}{} + lights = append(lights, light) + } + if len(lights) == 0 { + return nil + } + + ctx := context.Background() + key := pkgws.RedisKeyTaskLights + taskID + if err = redis.Client.SAdd(ctx, key, lights...).Err(); err != nil { + return err + } + return redis.Client.Expire(ctx, key, time.Hour).Err() +} + +func lightingTypeFromFileName(fileName string) string { + ext := strings.ToLower(filepath.Ext(fileName)) + if !isImageExt(ext) { + return utils.StringEmpty + } + base := strings.TrimSuffix(fileName, filepath.Ext(fileName)) + parts := strings.Split(base, "_") + if len(parts) < 2 { + return utils.StringEmpty + } + return strings.ToLower(parts[0]) +} diff --git a/services/analysis/internal/callback/notify.go b/services/analysis/internal/callback/notify.go new file mode 100644 index 0000000..b340222 --- /dev/null +++ b/services/analysis/internal/callback/notify.go @@ -0,0 +1,40 @@ +package callback + +import ( + "bytes" + "fmt" + "net/http" + "strings" + + "lone-services/pkg/utils" + + jsoniter "github.com/json-iterator/go" +) + +func NotifyPythonService(taskId, subTaskId, folderPath string) error { + if err := MarkTaskProcessing(taskId); err != nil { + return err + } + + host := utils.GetConfigString("services.skin_py_analysis_host") + apiPath := utils.GetConfigString("services.skin_py_analysis_path") + if host == utils.StringEmpty || apiPath == utils.StringEmpty { + return fmt.Errorf("python analysis service config empty") + } + + url := strings.TrimRight(host, "/") + apiPath + body, _ := jsoniter.Marshal(map[string]interface{}{ + "task_id": subTaskId, + "folder_name": folderPath, + }) + + resp, err := http.Post(url, "application/json", bytes.NewBuffer(body)) + if err != nil { + return err + } + defer resp.Body.Close() + if resp.StatusCode != http.StatusOK { + return fmt.Errorf("python service error: %s", resp.Status) + } + return nil +} diff --git a/services/analysis/internal/callback/persist.go b/services/analysis/internal/callback/persist.go new file mode 100644 index 0000000..e3f9ee7 --- /dev/null +++ b/services/analysis/internal/callback/persist.go @@ -0,0 +1,74 @@ +package callback + +import ( + "strconv" + + "lone-services/pkg/modelbase" + "lone-services/pkg/utils" + "lone-services/services/analysis/internal/dao" + "lone-services/services/analysis/internal/model" + + "gorm.io/gorm" +) + +func SaveTask(ts dao.TaskTimeStamp, userId int64, path *dao.HandleZipResource, coverPath string) error { + m := model.ImageAnalysisModel{}.Init() + var task dao.ImageAnalysis + w := modelbase.Params{Eq: map[string]string{"task_id": ts.TaskId}} + if err := m.GetOne(w, &task); err != nil { + return err + } + + now := utils.Now() + if task.Id < utils.NumberOne { + return m.Create(&dao.ImageAnalysis{ + TaskId: ts.TaskId, + UserId: userId, + FolderPath: path.TargetDir, + Status: dao.AnalysisStatusPending, + UploadCount: 1, + Cover: coverPath, + CreatedAt: now, + UpdatedAt: now, + }) + } + + updateData := map[string]interface{}{ + "upload_count": gorm.Expr("upload_count + ?", 1), + "folder_path": path.TargetDir, + "updated_at": now, + } + if coverPath != utils.StringEmpty { + updateData["cover"] = coverPath + } + _, err := m.Edit(w, updateData) + return err +} + +func SaveSubTask(ts dao.TaskTimeStamp, path *dao.HandleZipResource) error { + now := utils.Now() + return model.ImageAnalysisSubModel{}.Init().Create(&dao.ImageAnalysisSub{ + TaskId: ts.TaskId, + SubTaskId: ts.SubTaskId, + Status: dao.AnalysisStatusProcessing, + FilePath: path.FilePath, + ImageDir: path.FinalDir, + UploadStartTs: ts.UploadStartTs, + UploadEndTs: ts.UploadEndTs, + ProcessStartTs: ts.ProcessStartTs, + CreatedAt: now, + UpdatedAt: now, + }) +} + +func MarkTaskProcessing(taskId string) error { + _, err := model.ImageAnalysisModel{}.Init().Edit(modelbase.Params{ + Eq: map[string]string{ + "task_id": taskId, + "status": strconv.Itoa(int(dao.AnalysisStatusPending)), + }, + }, map[string]interface{}{ + "status": dao.AnalysisStatusProcessing, + }) + return err +} diff --git a/services/analysis/internal/callback/process.go b/services/analysis/internal/callback/process.go new file mode 100644 index 0000000..ab15bc7 --- /dev/null +++ b/services/analysis/internal/callback/process.go @@ -0,0 +1,81 @@ +package callback + +import ( + "context" + "fmt" + "os" + "path/filepath" + "strconv" + "time" + + "lone-services/pkg/utils" + "lone-services/services/analysis/internal/dao" + analysisoss "lone-services/services/analysis/internal/oss" + + "github.com/google/uuid" + "github.com/zeromicro/go-zero/core/logx" +) + +func ProcessUpload(ctx context.Context, payload analysisoss.CallbackPayload) error { + if payload.TaskId == utils.StringEmpty || payload.Object == utils.StringEmpty { + return fmt.Errorf("callback missing task_id or object") + } + + sess, err := analysisoss.LoadUploadSession(ctx, payload.TaskId) + if err != nil { + return fmt.Errorf("load upload session: %w", err) + } + if sess.DateDir == utils.StringEmpty { + return fmt.Errorf("upload session date_dir empty") + } + + downloadURL, err := BuildDownloadURL(payload.Object) + if err != nil { + return err + } + + subTaskId := uuid.New().String() + subDirName := strconv.FormatInt(time.Now().UnixMilli(), 10) + targetDir := filepath.Join(utils.GetConfigString("file.analysis_path"), sess.DateDir, payload.TaskId) + if err = os.MkdirAll(targetDir, os.ModePerm); err != nil { + return fmt.Errorf("mkdir analysis path: %w", err) + } + zipPath := filepath.Join(targetDir, subDirName+".zip") + + if err = DownloadFile(downloadURL, zipPath); err != nil { + return fmt.Errorf("download zip: %w", err) + } + + pathRes, coverPath, err := HandleTaskZip(zipPath) + if err != nil { + return fmt.Errorf("handle zip: %w", err) + } + + if err = CacheUploadedLights(payload.TaskId, pathRes.FinalDir); err != nil { + logx.WithContext(ctx).Errorf("cache uploaded lights failed: %v", err) + } + + if utils.GetConfigInt("switch.facepp") == utils.NumberOne { + logx.WithContext(ctx).Infof("facepp switch on but not migrated yet, skip task_id=%s", payload.TaskId) + } + + if utils.GetConfigInt("switch.analysis") == utils.NumberOne { + if err = NotifyPythonService(payload.TaskId, subTaskId, pathRes.FinalDir); err != nil { + logx.WithContext(ctx).Errorf("notify python failed: %v", err) + } + } + + ts := dao.TaskTimeStamp{ + TaskId: payload.TaskId, + SubTaskId: subTaskId, + ProcessStartTs: strconv.FormatInt(time.Now().UnixMilli(), 10), + } + userId := sess.SkinUserId() + if userId < utils.NumberOne { + userId = sess.UserId + } + if err = SaveTask(ts, userId, pathRes, coverPath); err != nil { + return err + } + return SaveSubTask(ts, pathRes) +} diff --git a/services/analysis/internal/callback/zip.go b/services/analysis/internal/callback/zip.go new file mode 100644 index 0000000..12ee7d7 --- /dev/null +++ b/services/analysis/internal/callback/zip.go @@ -0,0 +1,88 @@ +package callback + +import ( + "archive/zip" + "io" + "os" + "path/filepath" + "strings" + + "lone-services/pkg/utils" + "lone-services/services/analysis/internal/dao" +) + +func HandleTaskZip(zipPath string) (*dao.HandleZipResource, string, error) { + targetDir := filepath.Dir(zipPath) + subDirName := strings.TrimSuffix(filepath.Base(zipPath), filepath.Ext(zipPath)) + finalDir := filepath.Join(targetDir, subDirName) + + coverPath, err := unzipImages(zipPath, finalDir) + if err != nil { + return nil, utils.StringEmpty, err + } + + return &dao.HandleZipResource{ + FilePath: zipPath, + FinalDir: finalDir, + TargetDir: targetDir, + }, coverPath, nil +} + +func unzipImages(zipPath, targetDir string) (string, error) { + if err := os.MkdirAll(targetDir, os.ModePerm); err != nil { + return utils.StringEmpty, err + } + + r, err := zip.OpenReader(zipPath) + if err != nil { + return utils.StringEmpty, err + } + defer r.Close() + + var crossMidPath string + for _, f := range r.File { + ext := strings.ToLower(filepath.Ext(f.Name)) + if !isImageExt(ext) { + continue + } + + rc, err := f.Open() + if err != nil { + continue + } + + filename := filepath.Base(f.Name) + if filename == utils.StringEmpty { + _ = rc.Close() + continue + } + + fullPath := filepath.Join(targetDir, filename) + dst, err := os.Create(fullPath) + if err != nil { + _ = rc.Close() + continue + } + + _, copyErr := io.Copy(dst, rc) + _ = dst.Close() + _ = rc.Close() + if copyErr != nil { + continue + } + + if strings.EqualFold(filename, "cross_mid.jpg") { + crossMidPath = fullPath + } + } + return crossMidPath, nil +} + +func isImageExt(ext string) bool { + switch ext { + case ".jpg", ".jpeg", ".png", ".gif": + return true + default: + return false + } +} diff --git a/services/analysis/internal/dao/analysis.go b/services/analysis/internal/dao/analysis.go new file mode 100644 index 0000000..fa93deb --- /dev/null +++ b/services/analysis/internal/dao/analysis.go @@ -0,0 +1,22 @@ +package dao + +import "lone-services/pkg/utils" + +type ImageAnalysis struct { + Id int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"` + TaskId string `gorm:"column:task_id" json:"task_id"` + UserId int64 `gorm:"column:user_id" json:"user_id"` + FolderPath string `gorm:"column:folder_path" json:"folder_path"` + Status int8 `gorm:"column:status" json:"status"` + Message string `gorm:"column:message" json:"message"` + UploadCount int8 `gorm:"column:upload_count" json:"upload_count"` + Cover string `gorm:"column:cover" json:"cover"` + Qrcode string `gorm:"column:qrcode" json:"qrcode"` + CreatedAt utils.CustomTime `gorm:"column:created_at" json:"created_at"` + UpdatedAt utils.CustomTime `gorm:"column:updated_at" json:"updated_at"` +} + +type ReportDisplayResource struct { + Status int8 `json:"status"` + Qrcode string `json:"qrcode"` +} diff --git a/services/analysis/internal/dao/analysis_sub.go b/services/analysis/internal/dao/analysis_sub.go new file mode 100644 index 0000000..730f567 --- /dev/null +++ b/services/analysis/internal/dao/analysis_sub.go @@ -0,0 +1,33 @@ +package dao + +import "lone-services/pkg/utils" + +type ImageAnalysisSub struct { + Id int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"` + TaskId string `gorm:"column:task_id" json:"task_id"` + SubTaskId string `gorm:"column:sub_task_id" json:"sub_task_id"` + Status int8 `gorm:"column:status" json:"status"` + FilePath string `gorm:"column:file_path" json:"file_path"` + ImageDir string `gorm:"column:image_dir" json:"image_dir"` + Scene string `gorm:"column:scene" json:"scene"` + UploadStartTs string `gorm:"column:upload_start_ts" json:"upload_start_ts"` + UploadEndTs string `gorm:"column:upload_end_ts" json:"upload_end_ts"` + ProcessStartTs string `gorm:"column:process_start_ts" json:"process_start_ts"` + ProcessEndTs string `gorm:"column:process_end_ts" json:"process_end_ts"` + CreatedAt utils.CustomTime `gorm:"column:created_at" json:"created_at"` + UpdatedAt utils.CustomTime `gorm:"column:updated_at" json:"updated_at"` +} + +type HandleZipResource struct { + FilePath string `json:"file_path"` + FinalDir string `json:"final_dir"` + TargetDir string `json:"target_dir"` +} + +type TaskTimeStamp struct { + TaskId string + SubTaskId string + UploadStartTs string + UploadEndTs string + ProcessStartTs string +} diff --git a/services/analysis/internal/dao/const.go b/services/analysis/internal/dao/const.go index 9bbf324..2b2f824 100644 --- a/services/analysis/internal/dao/const.go +++ b/services/analysis/internal/dao/const.go @@ -13,4 +13,12 @@ const ( SkinTypeUser int32 = 1 SkinTypeStore int32 = 2 + + AnalysisStatusPending int8 = 1 + AnalysisStatusProcessing int8 = 2 + AnalysisStatusDone int8 = 3 + AnalysisStatusFailed int8 = 4 + + DisplayStatusReady int8 = 1 + DisplayStatusWaiting int8 = 2 ) diff --git a/services/analysis/internal/dao/image.go b/services/analysis/internal/dao/image.go new file mode 100644 index 0000000..363cf20 --- /dev/null +++ b/services/analysis/internal/dao/image.go @@ -0,0 +1,25 @@ +package dao + +import "lone-services/pkg/utils" + +type Image struct { + Id int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"` + UserId int64 `gorm:"column:user_id" json:"user_id"` + TaskId string `gorm:"column:task_id" json:"task_id"` + Tag string `gorm:"column:tag" json:"tag"` + Images string `gorm:"column:images" json:"images"` + Contents string `gorm:"column:contents" json:"contents"` + Cover string `gorm:"column:cover" json:"cover"` + Status int8 `gorm:"column:status" json:"status"` + CreateTime utils.CustomTime `gorm:"column:create_time" json:"create_time"` +} + +type ImageDetailResource struct { + Id int64 `json:"id"` + UserId int64 `json:"user_id"` + TaskId string `json:"task_id"` + Images map[string]interface{} `json:"images"` + Contents interface{} `json:"contents"` + Cover string `json:"cover"` + CreateTime string `json:"create_time"` +} diff --git a/services/analysis/internal/logic/analysis/qrcodeInfoLogic.go b/services/analysis/internal/logic/analysis/qrcodeInfoLogic.go new file mode 100644 index 0000000..606f5b4 --- /dev/null +++ b/services/analysis/internal/logic/analysis/qrcodeInfoLogic.go @@ -0,0 +1,111 @@ +package analysislogic + +import ( + "context" + "strconv" + "strings" + + "lone-services/pkg/modelbase" + "lone-services/pkg/redis" + "lone-services/pkg/utils" + "lone-services/pkg/validate" + pkgws "lone-services/pkg/ws" + 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" +) + +const imageTimeLayout = "2006-01-02 15:04" + +type QrcodeInfoLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewQrcodeInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *QrcodeInfoLogic { + return &QrcodeInfoLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *QrcodeInfoLogic) QrcodeInfo(in *analysis.QrcodeInfoReq) (*analysis.Response, error) { + var req validator.QrcodeInfoValidator + if msg := validate.ValidateFromProto(in, &req); msg != utils.StringEmpty { + return common.OutResponse(utils.ErrorParams, msg), nil + } + + idStr := strconv.FormatInt(req.Id, utils.NumberTen) + key := pkgws.RedisKeyQRShare + utils.MD5Encrypt(idStr) + exists, err := redis.Client.Exists(l.ctx, key).Result() + if err != nil { + l.Errorf("qrcode info redis exists: %v", err) + return common.FailResponse(utils.Fail), nil + } + if exists == 0 { + return common.FailResponse(utils.ErrorNotFund), nil + } + + var detail dao.Image + err = model.ImageModel{}.Init().GetOne(modelbase.Params{ + Eq: map[string]string{"id": idStr}, + }, &detail) + if err != nil { + l.Errorf("qrcode info get image: %v", err) + return common.FailResponse(utils.Fail), nil + } + if detail.Id < utils.NumberOne { + return common.FailResponse(utils.ErrorNotFund), nil + } + + return common.OkResponse(buildImageDetail(&detail)), nil +} + +func buildImageDetail(detail *dao.Image) dao.ImageDetailResource { + var images map[string]interface{} + if detail.Images != utils.StringEmpty { + _ = jsoniter.UnmarshalFromString(detail.Images, &images) + } + + var contents map[string]string + if detail.Contents != utils.StringEmpty { + var raw map[string]string + if err := jsoniter.UnmarshalFromString(detail.Contents, &raw); err == nil { + contents = formatImageContents(raw) + } else { + contents = map[string]string{} + } + } + + return dao.ImageDetailResource{ + Id: detail.Id, + UserId: detail.UserId, + TaskId: detail.TaskId, + Images: images, + Contents: contents, + Cover: detail.Cover, + CreateTime: detail.CreateTime.Format(imageTimeLayout), + } +} + +func formatImageContents(data map[string]string) map[string]string { + result := make(map[string]string, len(data)) + for k, v := range data { + switch k { + case "health_score": + parts := strings.Split(v, "/") + result[k] = strings.TrimSpace(parts[0]) + default: + result[k] = strings.TrimSuffix(v, "%") + } + } + return result +} diff --git a/services/analysis/internal/logic/analysisdevice/displayLogic.go b/services/analysis/internal/logic/analysisdevice/displayLogic.go new file mode 100644 index 0000000..ca49776 --- /dev/null +++ b/services/analysis/internal/logic/analysisdevice/displayLogic.go @@ -0,0 +1,64 @@ +package analysisdevicelogic + +import ( + "context" + + "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 DisplayLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewDisplayLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DisplayLogic { + return &DisplayLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *DisplayLogic) Display(in *analysis.DeviceDisplayReq) (*analysis.Response, error) { + var req validator.DeviceDisplayValidator + if msg := validate.ValidateFromProto(in, &req); msg != utils.StringEmpty { + return common.OutResponse(utils.ErrorParams, msg), nil + } + + loginUser := utils.GetUserFromCtx(l.ctx) + if !loginUser.Valid || loginUser.ID < utils.NumberOne { + return common.FailResponse(utils.ErrorNoLogin), nil + } + + var task dao.ImageAnalysis + err := model.ImageAnalysisModel{}.Init().GetOne(modelbase.Params{ + Eq: map[string]string{"task_id": req.TaskId}, + }, &task) + if err != nil { + l.Errorf("device display get analysis: %v", err) + return common.FailResponse(utils.Fail), nil + } + + if task.Status == dao.AnalysisStatusDone && task.Qrcode != utils.StringEmpty { + return common.OkResponse(dao.ReportDisplayResource{ + Status: dao.DisplayStatusReady, + Qrcode: task.Qrcode, + }), nil + } + + return common.OkResponse(dao.ReportDisplayResource{ + Status: dao.DisplayStatusWaiting, + Qrcode: utils.StringEmpty, + }), nil +} diff --git a/services/analysis/internal/logic/analysisdevice/doc.go b/services/analysis/internal/logic/analysisdevice/doc.go deleted file mode 100644 index 71202ca..0000000 --- a/services/analysis/internal/logic/analysisdevice/doc.go +++ /dev/null @@ -1 +0,0 @@ -package analysisdevicelogic diff --git a/services/analysis/internal/logic/analysisdevice/ossCallbackLogic.go b/services/analysis/internal/logic/analysisdevice/ossCallbackLogic.go new file mode 100644 index 0000000..1ada39d --- /dev/null +++ b/services/analysis/internal/logic/analysisdevice/ossCallbackLogic.go @@ -0,0 +1,104 @@ +package analysisdevicelogic + +import ( + "context" + + "lone-services/pkg/utils" + analysis "lone-services/rpc/analysis/pb" + "lone-services/services/analysis/internal/callback" + analysisoss "lone-services/services/analysis/internal/oss" + "lone-services/services/analysis/internal/svc" + + "github.com/zeromicro/go-zero/core/logx" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +const ossCallbackPath = "/api/v1/oss/callback" + +type OssCallbackLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewOssCallbackLogic(ctx context.Context, svcCtx *svc.ServiceContext) *OssCallbackLogic { + return &OssCallbackLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *OssCallbackLogic) OssCallback(in *analysis.OssCallbackReq) (*analysis.OssCallbackResp, error) { + rawBody := utils.GetBody(l.ctx) + if rawBody == utils.StringEmpty { + l.Error("oss callback empty raw body") + return nil, status.Error(codes.InvalidArgument, "read body failed") + } + + path, query, auth, pubKeyURL := callbackMeta(l.ctx) + if path == utils.StringEmpty { + path = ossCallbackPath + } + + if err := analysisoss.VerifyCallback(analysisoss.VerifyInput{ + Path: path, + RawQuery: query, + Body: []byte(rawBody), + Authorization: auth, + PubKeyURLHdr: pubKeyURL, + }); err != nil { + l.Errorf("oss callback verify failed: %v", err) + return nil, status.Error(codes.PermissionDenied, "verify not ok") + } + + payload := analysisoss.CallbackPayload{ + Bucket: in.GetBucket(), + Object: in.GetObject(), + Etag: in.GetEtag(), + Size: in.GetSize(), + MimeType: in.GetMimeType(), + TaskId: in.GetTaskId(), + } + if payload.TaskId == utils.StringEmpty || payload.Object == utils.StringEmpty { + l.Error("oss callback missing task_id or object") + return nil, status.Error(codes.InvalidArgument, "invalid body") + } + + go func(p analysisoss.CallbackPayload) { + defer func() { + if r := recover(); r != nil { + logx.Errorf("oss callback process panic: %v", r) + } + }() + if err := callback.ProcessUpload(context.Background(), p); err != nil { + logx.Errorf("oss callback process failed: %v", err) + } + }(payload) + + return &analysis.OssCallbackResp{Status: "OK"}, nil +} + +func callbackMeta(ctx context.Context) (path, query, auth, pubKeyURL string) { + md, ok := metadata.FromIncomingContext(ctx) + if !ok { + return + } + path = firstMD(md, "x-request-path", "x-original-path") + query = firstMD(md, "x-request-query") + auth = firstMD(md, "x-oss-authorization", "authorization", "grpcgateway-authorization") + pubKeyURL = firstMD(md, "x-oss-pub-key-url", "grpcgateway-x-oss-pub-key-url") + return +} + +func firstMD(md metadata.MD, keys ...string) string { + for _, key := range keys { + vals := md.Get(key) + if len(vals) > 0 && vals[0] != "" { + return vals[0] + } + } + return "" +} diff --git a/services/analysis/internal/logic/analysisdevice/policyLogic.go b/services/analysis/internal/logic/analysisdevice/policyLogic.go new file mode 100644 index 0000000..100e93e --- /dev/null +++ b/services/analysis/internal/logic/analysisdevice/policyLogic.go @@ -0,0 +1,72 @@ +package analysisdevicelogic + +import ( + "context" + + "lone-services/pkg/utils" + "lone-services/pkg/validate" + analysis "lone-services/rpc/analysis/pb" + "lone-services/services/analysis/internal/logic/common" + analysisoss "lone-services/services/analysis/internal/oss" + "lone-services/services/analysis/internal/svc" + "lone-services/services/analysis/validator" + + "github.com/google/uuid" + "github.com/zeromicro/go-zero/core/logx" +) + +type PolicyLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewPolicyLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PolicyLogic { + return &PolicyLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *PolicyLogic) Policy(in *analysis.DevicePolicyReq) (*analysis.Response, error) { + var req validator.DevicePolicyValidator + if msg := validate.ValidateFromProto(in, &req); msg != utils.StringEmpty { + return common.OutResponse(utils.ErrorParams, msg), nil + } + + loginUser := utils.GetUserFromCtx(l.ctx) + if !loginUser.Valid || loginUser.ID < utils.NumberOne { + return common.FailResponse(utils.ErrorNoLogin), nil + } + + cfg := analysisoss.NewConfig("device-" + req.SerialNo) + if err := cfg.Validate(); err != nil { + l.Errorf("device policy config: %v", err) + return common.FailResponse(utils.Fail), nil + } + + taskId := uuid.New().String() + cred, err := analysisoss.AssumeRole(cfg) + if err != nil { + l.Errorf("device policy assume role: %v", err) + return common.FailResponse(utils.Fail), nil + } + + policy, err := analysisoss.BuildUploadPolicy(cfg, taskId, cred) + if err != nil { + l.Errorf("device policy build: %v", err) + return common.FailResponse(utils.Fail), nil + } + + if err = analysisoss.SaveUploadSession(l.ctx, taskId, analysisoss.UploadSession{ + UserId: loginUser.ID, + BizId: loginUser.BizId, + DateDir: policy.DateDir, + }, int(cfg.ExpireSeconds)); err != nil { + l.Errorf("device policy cache session: %v", err) + return common.FailResponse(utils.Fail), nil + } + + return common.OkResponse(policy), nil +} diff --git a/services/analysis/internal/model/analysis.go b/services/analysis/internal/model/analysis.go new file mode 100644 index 0000000..c426f3e --- /dev/null +++ b/services/analysis/internal/model/analysis.go @@ -0,0 +1,16 @@ +package model + +import "lone-services/pkg/modelbase" + +type ImageAnalysisModel struct { + modelbase.Base +} + +func (m ImageAnalysisModel) TableName() string { + return modelbase.Prefix() + "images_analyses" +} + +func (m ImageAnalysisModel) Init() ImageAnalysisModel { + m.Table = m.TableName() + return m +} diff --git a/services/analysis/internal/model/analysis_sub.go b/services/analysis/internal/model/analysis_sub.go new file mode 100644 index 0000000..9dfa54e --- /dev/null +++ b/services/analysis/internal/model/analysis_sub.go @@ -0,0 +1,16 @@ +package model + +import "lone-services/pkg/modelbase" + +type ImageAnalysisSubModel struct { + modelbase.Base +} + +func (m ImageAnalysisSubModel) TableName() string { + return modelbase.Prefix() + "images_analyses_sub" +} + +func (m ImageAnalysisSubModel) Init() ImageAnalysisSubModel { + m.Table = m.TableName() + return m +} diff --git a/services/analysis/internal/model/image.go b/services/analysis/internal/model/image.go new file mode 100644 index 0000000..2fa60d7 --- /dev/null +++ b/services/analysis/internal/model/image.go @@ -0,0 +1,16 @@ +package model + +import "lone-services/pkg/modelbase" + +type ImageModel struct { + modelbase.Base +} + +func (m ImageModel) TableName() string { + return modelbase.Prefix() + "images" +} + +func (m ImageModel) Init() ImageModel { + m.Table = m.TableName() + return m +} diff --git a/services/analysis/internal/oss/callback.go b/services/analysis/internal/oss/callback.go new file mode 100644 index 0000000..efede24 --- /dev/null +++ b/services/analysis/internal/oss/callback.go @@ -0,0 +1,11 @@ +package oss + +// CallbackPayload OSS 以 application/json 回调时的请求体 +type CallbackPayload struct { + Bucket string `json:"bucket"` + Object string `json:"object"` + Etag string `json:"etag"` + Size int64 `json:"size"` + MimeType string `json:"mimeType"` + TaskId string `json:"task_id"` +} diff --git a/services/analysis/internal/oss/policy.go b/services/analysis/internal/oss/policy.go new file mode 100644 index 0000000..e22b595 --- /dev/null +++ b/services/analysis/internal/oss/policy.go @@ -0,0 +1,254 @@ +package oss + +import ( + "crypto/hmac" + "crypto/sha256" + "encoding/base64" + "encoding/hex" + "encoding/json" + "fmt" + "hash" + "io" + "strings" + "time" + + "lone-services/pkg/utils" + + openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client" + sts20150401 "github.com/alibabacloud-go/sts-20150401/v2/client" + util "github.com/alibabacloud-go/tea-utils/v2/service" + "github.com/alibabacloud-go/tea/tea" +) + +const ossProduct = "oss" + +type Config struct { + AccessKeyId string + AccessKeySecret string + RoleArn string + Region string + BucketName string + Endpoint string + StsEndpoint string + Dir string + ExpireSeconds int64 + CallbackUrl string + RoleSessionName string +} + +type Credentials struct { + AccessKeyId string + AccessKeySecret string + SecurityToken string + Expiration string +} + +type UploadPolicy struct { + TaskId string `json:"task_id"` + Policy string `json:"policy"` + SecurityToken string `json:"security_token"` + SignatureVersion string `json:"x_oss_signature_version"` + Credential string `json:"x_oss_credential"` + Date string `json:"x_oss_date"` + Signature string `json:"signature"` + Host string `json:"host"` + Dir string `json:"dir"` + DateDir string `json:"date_dir"` + Callback string `json:"callback"` + CallbackVar string `json:"callback_var"` + ExpireSeconds int64 `json:"expire_seconds"` +} + +func NewConfig(roleSessionName string) *Config { + dir := utils.GetConfigString("oss.dir") + if dir != utils.StringEmpty && !strings.HasSuffix(dir, "/") { + dir += "/" + } + expire := int64(utils.GetConfigInt("oss.expireSeconds")) + if expire <= 0 { + expire = 3600 + } + region := utils.GetConfigString("oss.region") + if region == utils.StringEmpty { + region = "oss-cn-hangzhou" + } + stsEndpoint := utils.GetConfigString("oss.stsEndpoint") + if stsEndpoint == utils.StringEmpty { + stsEndpoint = "sts." + strings.TrimPrefix(region, "oss-") + ".aliyuncs.com" + } + endpoint := utils.GetConfigString("oss.endpoint") + if endpoint == utils.StringEmpty { + endpoint = "https://oss-accelerate.aliyuncs.com" + } + bucket := utils.GetConfigString("oss.bucketName") + if bucket == utils.StringEmpty { + bucket = "lone-images" + } + + return &Config{ + AccessKeyId: utils.GetConfigString("oss.accessKeyId"), + AccessKeySecret: utils.GetConfigString("oss.accessKeySecret"), + RoleArn: utils.GetConfigString("oss.roleArn"), + Region: region, + BucketName: bucket, + Endpoint: endpoint, + StsEndpoint: stsEndpoint, + Dir: dir, + ExpireSeconds: expire, + CallbackUrl: utils.GetConfigString("oss.callbackUrl"), + RoleSessionName: roleSessionName, + } +} + +func (c *Config) Validate() error { + if c.AccessKeyId == utils.StringEmpty || c.AccessKeySecret == utils.StringEmpty || c.RoleArn == utils.StringEmpty { + return fmt.Errorf("oss policy config incomplete") + } + if c.CallbackUrl == utils.StringEmpty { + return fmt.Errorf("oss callbackUrl empty") + } + if c.BucketName == utils.StringEmpty { + return fmt.Errorf("oss bucketName empty") + } + return nil +} + +func AssumeRole(cfg *Config) (*Credentials, error) { + client, err := sts20150401.NewClient(&openapi.Config{ + AccessKeyId: tea.String(cfg.AccessKeyId), + AccessKeySecret: tea.String(cfg.AccessKeySecret), + Endpoint: tea.String(cfg.StsEndpoint), + }) + if err != nil { + return nil, fmt.Errorf("create sts client: %w", err) + } + + response, err := client.AssumeRoleWithOptions(&sts20150401.AssumeRoleRequest{ + DurationSeconds: tea.Int64(cfg.ExpireSeconds), + RoleArn: tea.String(cfg.RoleArn), + RoleSessionName: tea.String(cfg.RoleSessionName), + }, &util.RuntimeOptions{}) + if err != nil { + return nil, fmt.Errorf("assume role: %w", err) + } + if response == nil || response.Body == nil || response.Body.Credentials == nil { + return nil, fmt.Errorf("assume role: empty credentials") + } + + cred := response.Body.Credentials + return &Credentials{ + AccessKeyId: tea.StringValue(cred.AccessKeyId), + AccessKeySecret: tea.StringValue(cred.AccessKeySecret), + SecurityToken: tea.StringValue(cred.SecurityToken), + Expiration: tea.StringValue(cred.Expiration), + }, nil +} + +func BuildUploadPolicy(cfg *Config, taskId string, cred *Credentials) (*UploadPolicy, error) { + region := strings.TrimPrefix(strings.TrimSpace(cfg.Region), "oss-") + dateDir := time.Now().In(utils.AsiaShanghai).Format("20060102") + objectPrefix := fmt.Sprintf("%s%s/%s/", cfg.Dir, dateDir, taskId) + + utcTime := time.Now().UTC() + date := utcTime.Format("20060102") + ossDate := utcTime.Format("20060102T150405Z") + expiration := utcTime.Add(time.Duration(cfg.ExpireSeconds) * time.Second) + credential := fmt.Sprintf("%s/%s/%s/%s/aliyun_v4_request", cred.AccessKeyId, date, region, ossProduct) + + policyMap := map[string]any{ + "expiration": expiration.Format("2006-01-02T15:04:05.000Z"), + "conditions": []any{ + map[string]string{"bucket": cfg.BucketName}, + map[string]string{"x-oss-signature-version": "OSS4-HMAC-SHA256"}, + map[string]string{"x-oss-credential": credential}, + map[string]string{"x-oss-date": ossDate}, + map[string]string{"x-oss-security-token": cred.SecurityToken}, + []any{"starts-with", "$key", objectPrefix}, + []any{"content-length-range", 1, 512 * 1024 * 1024}, + }, + } + + policyJSON, err := json.Marshal(policyMap) + if err != nil { + return nil, fmt.Errorf("marshal policy: %w", err) + } + policyBase64 := base64.StdEncoding.EncodeToString(policyJSON) + signature, err := signPolicyV4(cred.AccessKeySecret, date, region, policyBase64) + if err != nil { + return nil, err + } + + callbackBody := `{"bucket":${bucket},"object":${object},"etag":${etag},"size":${size},"mimeType":${mimeType},"task_id":${x:task_id}}` + callbackVars := map[string]string{"x:task_id": taskId} + + return &UploadPolicy{ + TaskId: taskId, + Policy: policyBase64, + SecurityToken: cred.SecurityToken, + SignatureVersion: "OSS4-HMAC-SHA256", + Credential: credential, + Date: ossDate, + Signature: signature, + Host: cfg.Endpoint, + Dir: objectPrefix, + DateDir: dateDir, + Callback: encodeCallbackBase64(cfg.CallbackUrl, callbackBody, "application/json"), + CallbackVar: encodeCallbackVarBase64(callbackVars), + ExpireSeconds: cfg.ExpireSeconds, + }, nil +} + +func signPolicyV4(accessKeySecret, date, region, policyBase64 string) (string, error) { + hmacHash := func() hash.Hash { return sha256.New() } + + h1 := hmac.New(hmacHash, []byte("aliyun_v4"+accessKeySecret)) + if _, err := io.WriteString(h1, date); err != nil { + return "", err + } + h2 := hmac.New(hmacHash, h1.Sum(nil)) + if _, err := io.WriteString(h2, region); err != nil { + return "", err + } + h3 := hmac.New(hmacHash, h2.Sum(nil)) + if _, err := io.WriteString(h3, ossProduct); err != nil { + return "", err + } + h4 := hmac.New(hmacHash, h3.Sum(nil)) + if _, err := io.WriteString(h4, "aliyun_v4_request"); err != nil { + return "", err + } + h := hmac.New(hmacHash, h4.Sum(nil)) + if _, err := io.WriteString(h, policyBase64); err != nil { + return "", err + } + return hex.EncodeToString(h.Sum(nil)), nil +} + +type callbackParam struct { + CallbackUrl string `json:"callbackUrl"` + CallbackBody string `json:"callbackBody"` + CallbackBodyType string `json:"callbackBodyType"` +} + +func encodeCallbackBase64(url, body, bodyType string) string { + raw, err := json.Marshal(callbackParam{ + CallbackUrl: url, + CallbackBody: body, + CallbackBodyType: bodyType, + }) + if err != nil { + return "" + } + return base64.StdEncoding.EncodeToString(raw) +} + +func encodeCallbackVarBase64(vars map[string]string) string { + if len(vars) == 0 { + return "" + } + raw, err := json.Marshal(vars) + if err != nil { + return "" + } + return base64.StdEncoding.EncodeToString(raw) +} diff --git a/services/analysis/internal/oss/session.go b/services/analysis/internal/oss/session.go new file mode 100644 index 0000000..13ca139 --- /dev/null +++ b/services/analysis/internal/oss/session.go @@ -0,0 +1,53 @@ +package oss + +import ( + "context" + "fmt" + "time" + + "lone-services/pkg/redis" + "lone-services/pkg/utils" + pkgws "lone-services/pkg/ws" + + jsoniter "github.com/json-iterator/go" +) + +type UploadSession struct { + UserId int64 `json:"user_id"` + BizId int64 `json:"biz_id"` + ObjId int64 `json:"obj_id"` // 兼容旧缓存 + DateDir string `json:"date_dir"` +} + +func (s UploadSession) SkinUserId() int64 { + if s.BizId > utils.NumberZero { + return s.BizId + } + return s.ObjId +} + +func SaveUploadSession(ctx context.Context, taskId string, sess UploadSession, expireSeconds int) error { + if expireSeconds <= 0 { + expireSeconds = 3600 + } + raw, err := jsoniter.Marshal(sess) + if err != nil { + return err + } + return redis.Client.Set(ctx, pkgws.RedisKeyOssUpload+taskId, raw, time.Duration(expireSeconds)*time.Second).Err() +} + +func LoadUploadSession(ctx context.Context, taskId string) (*UploadSession, error) { + val, err := redis.Client.Get(ctx, pkgws.RedisKeyOssUpload+taskId).Result() + if err != nil { + return nil, err + } + var sess UploadSession + if err = jsoniter.UnmarshalFromString(val, &sess); err != nil { + return nil, err + } + if sess.UserId < utils.NumberOne { + return nil, fmt.Errorf("upload session user empty") + } + return &sess, nil +} diff --git a/services/analysis/internal/oss/verify.go b/services/analysis/internal/oss/verify.go new file mode 100644 index 0000000..3ab2356 --- /dev/null +++ b/services/analysis/internal/oss/verify.go @@ -0,0 +1,117 @@ +package oss + +import ( + "crypto" + "crypto/md5" + "crypto/rsa" + "crypto/x509" + "encoding/base64" + "encoding/pem" + "fmt" + "io" + "net/http" + "net/url" + "strings" + "time" +) + +const ( + pubKeyURLHeader = "X-Oss-Pub-Key-Url" + authorizationHeader = "Authorization" +) + +type VerifyInput struct { + Path string + RawQuery string + Body []byte + Authorization string + PubKeyURLHdr string +} + +func VerifyCallback(in VerifyInput) error { + pubKeyURLBase64 := in.PubKeyURLHdr + if pubKeyURLBase64 == "" { + return fmt.Errorf("missing %s", pubKeyURLHeader) + } + pubKeyURLBytes, err := base64.StdEncoding.DecodeString(pubKeyURLBase64) + if err != nil { + return fmt.Errorf("decode pub key url: %w", err) + } + pubKeyURL := string(pubKeyURLBytes) + if !isTrustedPubKeyURL(pubKeyURL) { + return fmt.Errorf("untrusted pub key url: %s", pubKeyURL) + } + + pubKeyPEM, err := fetchPublicKey(pubKeyURL) + if err != nil { + return fmt.Errorf("fetch pub key: %w", err) + } + + authBase64 := in.Authorization + if authBase64 == "" { + return fmt.Errorf("missing %s", authorizationHeader) + } + signature, err := base64.StdEncoding.DecodeString(authBase64) + if err != nil { + return fmt.Errorf("decode authorization: %w", err) + } + + authString, err := buildAuthString(in.Path, in.RawQuery, in.Body) + if err != nil { + return err + } + digest := md5.Sum([]byte(authString)) + + block, _ := pem.Decode(pubKeyPEM) + if block == nil { + return fmt.Errorf("invalid pub key pem") + } + pubInterface, err := x509.ParsePKIXPublicKey(block.Bytes) + if err != nil { + return fmt.Errorf("parse pub key: %w", err) + } + pubKey, ok := pubInterface.(*rsa.PublicKey) + if !ok { + return fmt.Errorf("pub key is not rsa") + } + if err := rsa.VerifyPKCS1v15(pubKey, crypto.MD5, digest[:], signature); err != nil { + return fmt.Errorf("verify signature: %w", err) + } + return nil +} + +func buildAuthString(path, query string, body []byte) (string, error) { + decodedPath, err := url.PathUnescape(path) + if err != nil { + return "", fmt.Errorf("unescape path: %w", err) + } + if query == "" { + return decodedPath + "\n" + string(body), nil + } + return decodedPath + "?" + query + "\n" + string(body), nil +} + +func isTrustedPubKeyURL(raw string) bool { + u, err := url.Parse(raw) + if err != nil { + return false + } + if u.Scheme != "http" && u.Scheme != "https" { + return false + } + host := strings.ToLower(u.Hostname()) + return host == "gosspublic.alicdn.com" || strings.HasSuffix(host, ".alicdn.com") +} + +func fetchPublicKey(pubKeyURL string) ([]byte, error) { + client := &http.Client{Timeout: 3 * time.Second} + resp, err := client.Get(pubKeyURL) + if err != nil { + return nil, err + } + defer resp.Body.Close() + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("pub key http status %d", resp.StatusCode) + } + return io.ReadAll(resp.Body) +} diff --git a/services/analysis/internal/server/analysis/analysisServer.go b/services/analysis/internal/server/analysis/analysisServer.go index f8b8944..2be3e74 100644 --- a/services/analysis/internal/server/analysis/analysisServer.go +++ b/services/analysis/internal/server/analysis/analysisServer.go @@ -42,3 +42,8 @@ func (s *AnalysisServer) Switch(ctx context.Context, in *analysis.SwitchReq) (*a l := analysislogic.NewSwitchLogic(ctx, s.svcCtx) return l.Switch(in) } + +func (s *AnalysisServer) QrcodeInfo(ctx context.Context, in *analysis.QrcodeInfoReq) (*analysis.Response, error) { + l := analysislogic.NewQrcodeInfoLogic(ctx, s.svcCtx) + return l.QrcodeInfo(in) +} diff --git a/services/analysis/internal/server/analysisdevice/analysisDeviceServer.go b/services/analysis/internal/server/analysisdevice/analysisDeviceServer.go index f4dbcd3..7107c24 100644 --- a/services/analysis/internal/server/analysisdevice/analysisDeviceServer.go +++ b/services/analysis/internal/server/analysisdevice/analysisDeviceServer.go @@ -5,7 +5,10 @@ package server import ( + "context" + "lone-services/rpc/analysis/pb" + "lone-services/services/analysis/internal/logic/analysisdevice" "lone-services/services/analysis/internal/svc" ) @@ -19,3 +22,18 @@ func NewAnalysisDeviceServer(svcCtx *svc.ServiceContext) *AnalysisDeviceServer { svcCtx: svcCtx, } } + +func (s *AnalysisDeviceServer) Policy(ctx context.Context, in *analysis.DevicePolicyReq) (*analysis.Response, error) { + l := analysisdevicelogic.NewPolicyLogic(ctx, s.svcCtx) + return l.Policy(in) +} + +func (s *AnalysisDeviceServer) Display(ctx context.Context, in *analysis.DeviceDisplayReq) (*analysis.Response, error) { + l := analysisdevicelogic.NewDisplayLogic(ctx, s.svcCtx) + return l.Display(in) +} + +func (s *AnalysisDeviceServer) OssCallback(ctx context.Context, in *analysis.OssCallbackReq) (*analysis.OssCallbackResp, error) { + l := analysisdevicelogic.NewOssCallbackLogic(ctx, s.svcCtx) + return l.OssCallback(in) +} diff --git a/services/analysis/run.toml b/services/analysis/run.toml index ccc6564..613160a 100644 --- a/services/analysis/run.toml +++ b/services/analysis/run.toml @@ -54,11 +54,27 @@ width = 430 auth_page = 'pagesB/authorize/scan' +[oss] + accessKeyId = "LTAI5t7U8KvxSiPE5auwQUuu" + accessKeySecret = "xjfgbQQRpL4TcIspNuClg6bYADa3pk" + roleArn = "acs:ram::1663896742753915:role/oss-upload" + region = "cn-beijing" + bucketName = "lone-images" + endpoint = "https://lone-images.oss-accelerate.aliyuncs.com" + internalEndpoint = "https://lone-images.oss-cn-beijing-internal.aliyuncs.com" + stsEndpoint = "sts.cn-beijing.aliyuncs.com" + dir = "test/skin/analysis/" + imageDir = "test/skin/images/" + fileDir = "test/skin/files/" + expireSeconds = 3600 + callbackUrl = "https://services-test.ailuowan.com/api/v1/oss/callback" + [services] user = "user-service" chore = "chore-service" store = "store-service" equipment = "equipment-service" + [switch] wechat = 1 facepp = 1 diff --git a/services/analysis/validator/user.go b/services/analysis/validator/user.go index 83083e7..8edef84 100644 --- a/services/analysis/validator/user.go +++ b/services/analysis/validator/user.go @@ -60,6 +60,17 @@ func (p SwitchValidator) GetMessage() validate.ValidatorMessages { return validate.ValidatorMessages{} } +type QrcodeInfoValidator struct { + Id int64 `validate:"required,gt=0"` +} + +func (p QrcodeInfoValidator) GetMessage() validate.ValidatorMessages { + return validate.ValidatorMessages{ + "Id.required": "id 必传", + "Id.gt": "id 必传", + } +} + type StoreAuthValidator struct { Username string `validate:"required,max=32"` Password string `validate:"required,max=64"` @@ -116,6 +127,28 @@ func (p DeviceBindValidator) GetMessage() validate.ValidatorMessages { } } +type DevicePolicyValidator struct { + SerialNo string `validate:"required,max=64"` +} + +func (p DevicePolicyValidator) GetMessage() validate.ValidatorMessages { + return validate.ValidatorMessages{ + "SerialNo.required": "serial_no 必传", + "SerialNo.max": "serial_no 过长", + } +} + +type DeviceDisplayValidator struct { + TaskId string `validate:"required,max=64"` +} + +func (p DeviceDisplayValidator) GetMessage() validate.ValidatorMessages { + return validate.ValidatorMessages{ + "TaskId.required": "task_id 必传", + "TaskId.max": "task_id 过长", + } +} + type StoreInfoValidator struct { Id int64 `validate:"required,gt=0"` } diff --git a/services/chore/choreclient/chore.go b/services/chore/choreclient/chore.go index f240511..41d64a6 100644 --- a/services/chore/choreclient/chore.go +++ b/services/chore/choreclient/chore.go @@ -1,5 +1,5 @@ // Code generated by goctl. DO NOT EDIT. -// goctl 1.10.2 +// goctl 1.10.1 // Source: chore.proto package choreClient @@ -42,7 +42,6 @@ type ( Chore interface { Policy(ctx context.Context, in *PolicyReq, opts ...grpc.CallOption) (*Response, error) Upload(ctx context.Context, in *UploadReq, opts ...grpc.CallOption) (*Response, error) - // 微信小程序直传 OSS 所需的 PostObject V4 签名参数 OssSignature(ctx context.Context, in *OssSignatureReq, opts ...grpc.CallOption) (*Response, error) Test(ctx context.Context, in *TestReq, opts ...grpc.CallOption) (*Response, error) DecryptMobile(ctx context.Context, in *DecryptMobileReq, opts ...grpc.CallOption) (*Response, error) @@ -90,7 +89,6 @@ func (m *defaultChore) Upload(ctx context.Context, in *UploadReq, opts ...grpc.C return client.Upload(ctx, in, opts...) } -// 微信小程序直传 OSS 所需的 PostObject V4 签名参数 func (m *defaultChore) OssSignature(ctx context.Context, in *OssSignatureReq, opts ...grpc.CallOption) (*Response, error) { client := chore.NewChoreClient(m.cli.Conn()) return client.OssSignature(ctx, in, opts...) diff --git a/services/chore/internal/dao/sms.go b/services/chore/internal/dao/sms.go index f0d1e36..3de4e81 100644 --- a/services/chore/internal/dao/sms.go +++ b/services/chore/internal/dao/sms.go @@ -3,6 +3,7 @@ package dao const ( SmsSceneLogin int32 = 1 SmsSceneResetPassword int32 = 2 + SmsSceneRebindMobile int32 = 3 SmsRateLimitSeconds = 60 SmsCodeLength = 6 diff --git a/services/chore/internal/logic/sendSmsLogic.go b/services/chore/internal/logic/sendSmsLogic.go index ad8b6a8..1682741 100644 --- a/services/chore/internal/logic/sendSmsLogic.go +++ b/services/chore/internal/logic/sendSmsLogic.go @@ -91,6 +91,8 @@ func smsSceneKind(scene int32) (sms.TemplateKind, bool) { return sms.TemplateCode, true case dao.SmsSceneResetPassword: return sms.TemplatePassword, true + case dao.SmsSceneRebindMobile: + return sms.TemplateRebindMobile, true default: return "", false } diff --git a/services/chore/internal/server/choreServer.go b/services/chore/internal/server/choreServer.go index ada2382..be6e959 100644 --- a/services/chore/internal/server/choreServer.go +++ b/services/chore/internal/server/choreServer.go @@ -1,5 +1,5 @@ // Code generated by goctl. DO NOT EDIT. -// goctl 1.10.2 +// goctl 1.10.1 // Source: chore.proto package server @@ -33,7 +33,6 @@ func (s *ChoreServer) Upload(ctx context.Context, in *chore.UploadReq) (*chore.R return l.Upload(in) } -// 微信小程序直传 OSS 所需的 PostObject V4 签名参数 func (s *ChoreServer) OssSignature(ctx context.Context, in *chore.OssSignatureReq) (*chore.Response, error) { l := logic.NewOssSignatureLogic(ctx, s.svcCtx) return l.OssSignature(in) diff --git a/services/chore/validator/sms.go b/services/chore/validator/sms.go index d319c04..939a02b 100644 --- a/services/chore/validator/sms.go +++ b/services/chore/validator/sms.go @@ -4,7 +4,7 @@ import "lone-services/pkg/validate" type SendSmsValidator struct { Mobile string `validate:"required,len=11"` - Scene int32 `validate:"required,oneof=1 2"` + Scene int32 `validate:"required,oneof=1 2 3"` } func (p SendSmsValidator) GetMessage() validate.ValidatorMessages { diff --git a/services/user/internal/dao/const.go b/services/user/internal/dao/const.go index c1eeb88..384e519 100644 --- a/services/user/internal/dao/const.go +++ b/services/user/internal/dao/const.go @@ -16,6 +16,7 @@ const ( SmsSceneLogin int32 = 1 SmsSceneResetPassword int32 = 2 + SmsSceneRebindMobile int32 = 3 TypeSale uint8 = 1 TypeStore uint8 = 2