feat(user): 添加临时固定账户

This commit is contained in:
liangzai 2024-11-24 02:07:37 +08:00
parent f80c0812f0
commit 6f77085c72
2 changed files with 19 additions and 11 deletions

View File

@ -30,6 +30,7 @@ func NewMobileCodeLoginLogic(ctx context.Context, svcCtx *svc.ServiceContext) *M
} }
func (l *MobileCodeLoginLogic) MobileCodeLogin(req *types.MobileCodeLoginReq) (resp *types.MobileCodeLoginResp, err error) { func (l *MobileCodeLoginLogic) MobileCodeLogin(req *types.MobileCodeLoginReq) (resp *types.MobileCodeLoginResp, err error) {
if !l.MobileCodeLoginInside(req) {
// 检查手机号是否在一分钟内已发送过验证码 // 检查手机号是否在一分钟内已发送过验证码
redisKey := fmt.Sprintf("%s:%s", "login", req.Mobile) redisKey := fmt.Sprintf("%s:%s", "login", req.Mobile)
cacheCode, err := l.svcCtx.Redis.Get(redisKey) cacheCode, err := l.svcCtx.Redis.Get(redisKey)
@ -42,6 +43,8 @@ func (l *MobileCodeLoginLogic) MobileCodeLogin(req *types.MobileCodeLoginReq) (r
if cacheCode != req.Code { if cacheCode != req.Code {
return nil, errors.Wrapf(xerr.NewErrMsg("验证码不正确"), "手机登录, 验证码不正确: %s", req.Mobile) return nil, errors.Wrapf(xerr.NewErrMsg("验证码不正确"), "手机登录, 验证码不正确: %s", req.Mobile)
} }
}
user, findUserErr := l.svcCtx.UserModel.FindOneByMobile(l.ctx, req.Mobile) user, findUserErr := l.svcCtx.UserModel.FindOneByMobile(l.ctx, req.Mobile)
if findUserErr != nil && findUserErr != model.ErrNotFound { if findUserErr != nil && findUserErr != model.ErrNotFound {
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "手机登录, 读取数据库获取用户失败, mobile: %s, err: %+v", req.Mobile, err) return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "手机登录, 读取数据库获取用户失败, mobile: %s, err: %+v", req.Mobile, err)
@ -85,3 +88,9 @@ func (l *MobileCodeLoginLogic) MobileCodeLogin(req *types.MobileCodeLoginReq) (r
RefreshAfter: l.svcCtx.Config.JwtAuth.RefreshAfter, RefreshAfter: l.svcCtx.Config.JwtAuth.RefreshAfter,
}, nil }, nil
} }
func (l *MobileCodeLoginLogic) MobileCodeLoginInside(req *types.MobileCodeLoginReq) (pass bool) {
if req.Mobile == "17776203797" && req.Code == "688629" {
return true
}
return false
}

View File

@ -507,7 +507,6 @@ func processResponse(resp []byte, apiID string) ([]byte, error) {
} }
func processG09SC02Response(resp []byte) ([]byte, error) { func processG09SC02Response(resp []byte) ([]byte, error) {
// 使用 GJSON 递归搜索 "maritalStatus" 字段
result := gjson.GetBytes(resp, "data.0.maritalStatus") result := gjson.GetBytes(resp, "data.0.maritalStatus")
if result.Exists() { if result.Exists() {