From d4545983c8c6e5e71b0704ceea4e5e4e1a84ada5 Mon Sep 17 00:00:00 2001 From: zzw <1464003642@qq.com> Date: Mon, 2 Nov 2026 10:34:59 +0800 Subject: [PATCH] fix: face login --- rpc/analysis/analysis.pb | Bin 21588 -> 21526 bytes rpc/analysis/analysis.proto | 4 +-- rpc/analysis/pb/analysis.pb.go | 25 +++--------------- .../logic/analysisdevice/faceLoginLogic.go | 16 +++++------ services/analysis/validator/user.go | 8 +++--- 5 files changed, 13 insertions(+), 40 deletions(-) diff --git a/rpc/analysis/analysis.pb b/rpc/analysis/analysis.pb index 4cfe0fc9df3510cfc9e68e0f3870934ed2c4b77c..34f72ea573a68b7a9b844cc264219d24fbe6a794 100644 GIT binary patch delta 28 kcmcbzf^pgk#tlxUOqXmoyO>&YGb&APa8TO(z@bDK0G_1^SpWb4 delta 90 zcmbQXg7L}<#tlxUOcU%jyO>&YGbT)Ka8R-plIG$}%gjlQFGwuOkYG|^)Zh%_00{&D j`9kts+{rnasd**w$@wX%63k#}E{KqGe#+*B4yD2X;lUeG diff --git a/rpc/analysis/analysis.proto b/rpc/analysis/analysis.proto index 6083ded..3c28997 100644 --- a/rpc/analysis/analysis.proto +++ b/rpc/analysis/analysis.proto @@ -550,9 +550,7 @@ message AdminUserDetailReq { int64 id = 1; } -// FaceLoginReq 设备人脸登录。gRPC/网关不走 multipart,传 file(图片字节) 或共享盘 file_path 其一。 +// FaceLoginReq 设备人脸登录。gRPC/网关不走 multipart,传 file(图片字节)。 message FaceLoginReq { bytes file = 1; - string file_path = 2; - string client_code = 3; } diff --git a/rpc/analysis/pb/analysis.pb.go b/rpc/analysis/pb/analysis.pb.go index 98b6e16..05c5ddd 100644 --- a/rpc/analysis/pb/analysis.pb.go +++ b/rpc/analysis/pb/analysis.pb.go @@ -2378,12 +2378,10 @@ func (x *AdminUserDetailReq) GetId() int64 { return 0 } -// FaceLoginReq 设备人脸登录。gRPC/网关不走 multipart,传 file(图片字节) 或共享盘 file_path 其一。 +// FaceLoginReq 设备人脸登录。gRPC/网关不走 multipart,传 file(图片字节)。 type FaceLoginReq struct { state protoimpl.MessageState `protogen:"open.v1"` File []byte `protobuf:"bytes,1,opt,name=file,proto3" json:"file,omitempty"` - FilePath string `protobuf:"bytes,2,opt,name=file_path,json=filePath,proto3" json:"file_path,omitempty"` - ClientCode string `protobuf:"bytes,3,opt,name=client_code,json=clientCode,proto3" json:"client_code,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -2425,20 +2423,6 @@ func (x *FaceLoginReq) GetFile() []byte { return nil } -func (x *FaceLoginReq) GetFilePath() string { - if x != nil { - return x.FilePath - } - return "" -} - -func (x *FaceLoginReq) GetClientCode() string { - if x != nil { - return x.ClientCode - } - return "" -} - var File_analysis_analysis_proto protoreflect.FileDescriptor const file_analysis_analysis_proto_rawDesc = "" + @@ -2580,12 +2564,9 @@ const file_analysis_analysis_proto_rawDesc = "" + "\x04page\x18\x02 \x01(\x05R\x04page\x12\x12\n" + "\x04size\x18\x03 \x01(\x05R\x04size\"$\n" + "\x12AdminUserDetailReq\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\"`\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"\"\n" + "\fFaceLoginReq\x12\x12\n" + - "\x04file\x18\x01 \x01(\fR\x04file\x12\x1b\n" + - "\tfile_path\x18\x02 \x01(\tR\bfilePath\x12\x1f\n" + - "\vclient_code\x18\x03 \x01(\tR\n" + - "clientCode2\xe6\x11\n" + + "\x04file\x18\x01 \x01(\fR\x04file2\xe6\x11\n" + "\bAnalysis\x12W\n" + "\x12InternalCreateUser\x12\x1f.analysis.InternalCreateUserReq\x1a .analysis.InternalCreateUserData\x12`\n" + "\x15InternalSetRegistered\x12\".analysis.InternalSetRegisteredReq\x1a#.analysis.InternalSetRegisteredData\x12k\n" + diff --git a/services/analysis/internal/logic/analysisdevice/faceLoginLogic.go b/services/analysis/internal/logic/analysisdevice/faceLoginLogic.go index d31f3c1..0e5f4ec 100644 --- a/services/analysis/internal/logic/analysisdevice/faceLoginLogic.go +++ b/services/analysis/internal/logic/analysisdevice/faceLoginLogic.go @@ -32,10 +32,10 @@ func NewFaceLoginLogic(ctx context.Context, svcCtx *svc.ServiceContext) *FaceLog } type faceLoginResult struct { - AccessToken string `json:"access_token"` - RefreshToken string `json:"refresh_token"` + AccessToken string `json:"access_token"` + RefreshToken string `json:"refresh_token"` Info jsoniter.RawMessage `json:"info"` - Status int `json:"status"` + Status int `json:"status"` } func (l *FaceLoginLogic) FaceLogin(in *analysis.FaceLoginReq) (*analysis.Response, error) { @@ -43,11 +43,11 @@ func (l *FaceLoginLogic) FaceLogin(in *analysis.FaceLoginReq) (*analysis.Respons if msg := validate.ValidateFromProto(in, &req); msg != utils.StringEmpty { return common.OutResponse(utils.ErrorParams, msg), nil } - if len(req.File) == utils.NumberZero && req.FilePath == utils.StringEmpty { + if len(req.File) == utils.NumberZero { return common.FailResponse(utils.ErrorFileUpFailed), nil } - imgPath, cleanup, err := face.PrepareImagePath(req.File, req.FilePath) + imgPath, cleanup, err := face.PrepareImagePath(req.File, utils.StringEmpty) if err != nil { l.Errorf("face login prepare image: %v", err) return common.FailResponse(utils.ErrorFileUpFailed), nil @@ -66,10 +66,6 @@ func (l *FaceLoginLogic) FaceLogin(in *analysis.FaceLoginReq) (*analysis.Respons return common.FailResponse(utils.ErrorFaceNotMatch), nil } - clientCode := req.ClientCode - if clientCode == utils.StringEmpty { - clientCode = dao.ClientCodeUserSkin - } if l.svcCtx.UserSvcName == utils.StringEmpty { return common.FailResponse(utils.Fail), nil } @@ -80,7 +76,7 @@ func (l *FaceLoginLogic) FaceLogin(in *analysis.FaceLoginReq) (*analysis.Respons } token, err := userpb.NewUserClient(cli.Conn()).InternalLoginByUserId(l.ctx, &userpb.InternalLoginByUserIdReq{ UserId: userID, - ClientCode: clientCode, + ClientCode: dao.ClientCodeUserSkin, }) if err != nil { l.Errorf("face login issue token: %v", err) diff --git a/services/analysis/validator/user.go b/services/analysis/validator/user.go index 64fd6fa..15ccad8 100644 --- a/services/analysis/validator/user.go +++ b/services/analysis/validator/user.go @@ -29,15 +29,13 @@ func (p FaceBindValidator) GetMessage() validate.ValidatorMessages { } type FaceLoginValidator struct { - File []byte - FilePath string `validate:"omitempty,max=512"` - ClientCode string `validate:"omitempty,max=32"` + File []byte `validate:"required,min=1"` } func (p FaceLoginValidator) GetMessage() validate.ValidatorMessages { return validate.ValidatorMessages{ - "FilePath.max": "file_path 过长", - "ClientCode.max": "client_code 过长", + "File.required": "file 必传", + "File.min": "file 必传", } }