feat: analysis user auth and ws
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
package analysisuserlogic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"lone-services/pkg/modelbase"
|
||||
"lone-services/pkg/utils"
|
||||
"lone-services/pkg/validate"
|
||||
analysis "lone-services/rpc/analysis/pb"
|
||||
"lone-services/services/analysis/internal/logic/common"
|
||||
"lone-services/services/analysis/internal/model"
|
||||
"lone-services/services/analysis/internal/svc"
|
||||
"lone-services/services/analysis/validator"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type FaceBindLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewFaceBindLogic(ctx context.Context, svcCtx *svc.ServiceContext) *FaceBindLogic {
|
||||
return &FaceBindLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *FaceBindLogic) FaceBind(in *analysis.FaceBindReq) (*analysis.Response, error) {
|
||||
var req validator.FaceBindValidator
|
||||
if msg := validate.ValidateFromProto(in, &req); msg != utils.StringEmpty {
|
||||
return common.OutResponse(utils.ErrorParams, msg), nil
|
||||
}
|
||||
|
||||
bizId, _, fail := common.RequireBizUserId(l.ctx)
|
||||
if fail != nil {
|
||||
return fail, nil
|
||||
}
|
||||
|
||||
row, err := common.LoadAnalysisUser(bizId)
|
||||
if err != nil {
|
||||
l.Errorf("face bind load user: %v", err)
|
||||
return common.FailResponse(utils.Fail), nil
|
||||
}
|
||||
if row == nil {
|
||||
return common.FailResponse(utils.ErrorNotFund), nil
|
||||
}
|
||||
|
||||
_, err = model.UserModel{}.Init().Edit(modelbase.Params{
|
||||
Eq: map[string]string{"id": strconv.FormatInt(bizId, utils.NumberTen)},
|
||||
}, map[string]interface{}{
|
||||
"face_path": req.FacePath,
|
||||
"is_face_verified": uint8(utils.StatusOk),
|
||||
})
|
||||
if err != nil {
|
||||
l.Errorf("face bind update: %v", err)
|
||||
return common.FailResponse(utils.Fail), nil
|
||||
}
|
||||
|
||||
return common.OkResponse(nil), nil
|
||||
}
|
||||
Reference in New Issue
Block a user