手机号适配双端
This commit is contained in:
@@ -8,7 +8,6 @@ import (
|
||||
"time"
|
||||
"tydata-server/app/main/api/internal/service"
|
||||
"tydata-server/common/ctxdata"
|
||||
jwtx "tydata-server/common/jwt"
|
||||
"tydata-server/common/xerr"
|
||||
"tydata-server/pkg/lzkit/crypto"
|
||||
"tydata-server/pkg/lzkit/validator"
|
||||
@@ -125,8 +124,8 @@ func (l *QueryServiceLogic) ProcessMarriageLogic(req *types.QueryServiceReq) (*t
|
||||
if cacheDataErr != nil {
|
||||
return nil, cacheDataErr
|
||||
}
|
||||
token, generaErr := jwtx.GenerateJwtToken(userID, l.svcCtx.Config.JwtAuth.AccessSecret, l.svcCtx.Config.JwtAuth.AccessExpire)
|
||||
if generaErr != nil {
|
||||
token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 生成token失败 : %d", userID)
|
||||
}
|
||||
|
||||
@@ -186,8 +185,8 @@ func (l *QueryServiceLogic) ProcessHomeServiceLogic(req *types.QueryServiceReq)
|
||||
return nil, cacheDataErr
|
||||
}
|
||||
|
||||
token, generaErr := jwtx.GenerateJwtToken(userID, l.svcCtx.Config.JwtAuth.AccessSecret, l.svcCtx.Config.JwtAuth.AccessExpire)
|
||||
if generaErr != nil {
|
||||
token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 生成token失败 : %d", userID)
|
||||
}
|
||||
|
||||
@@ -247,8 +246,8 @@ func (l *QueryServiceLogic) ProcessRiskAssessmentLogic(req *types.QueryServiceRe
|
||||
return nil, cacheDataErr
|
||||
}
|
||||
|
||||
token, generaErr := jwtx.GenerateJwtToken(userID, l.svcCtx.Config.JwtAuth.AccessSecret, l.svcCtx.Config.JwtAuth.AccessExpire)
|
||||
if generaErr != nil {
|
||||
token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 生成token失败 : %d", userID)
|
||||
}
|
||||
|
||||
@@ -307,8 +306,8 @@ func (l *QueryServiceLogic) ProcessCompanyInfoLogic(req *types.QueryServiceReq)
|
||||
return nil, cacheDataErr
|
||||
}
|
||||
|
||||
token, generaErr := jwtx.GenerateJwtToken(userID, l.svcCtx.Config.JwtAuth.AccessSecret, l.svcCtx.Config.JwtAuth.AccessExpire)
|
||||
if generaErr != nil {
|
||||
token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 生成token失败 : %d", userID)
|
||||
}
|
||||
|
||||
@@ -368,8 +367,8 @@ func (l *QueryServiceLogic) ProcessRentalInfoLogic(req *types.QueryServiceReq) (
|
||||
return nil, cacheDataErr
|
||||
}
|
||||
|
||||
token, generaErr := jwtx.GenerateJwtToken(userID, l.svcCtx.Config.JwtAuth.AccessSecret, l.svcCtx.Config.JwtAuth.AccessExpire)
|
||||
if generaErr != nil {
|
||||
token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 生成token失败 : %d", userID)
|
||||
}
|
||||
|
||||
@@ -429,8 +428,8 @@ func (l *QueryServiceLogic) ProcessPreLoanBackgroundCheckLogic(req *types.QueryS
|
||||
return nil, cacheDataErr
|
||||
}
|
||||
|
||||
token, generaErr := jwtx.GenerateJwtToken(userID, l.svcCtx.Config.JwtAuth.AccessSecret, l.svcCtx.Config.JwtAuth.AccessExpire)
|
||||
if generaErr != nil {
|
||||
token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 生成token失败 : %d", userID)
|
||||
}
|
||||
|
||||
@@ -489,8 +488,8 @@ func (l *QueryServiceLogic) ProcessBackgroundCheckLogic(req *types.QueryServiceR
|
||||
return nil, cacheDataErr
|
||||
}
|
||||
|
||||
token, generaErr := jwtx.GenerateJwtToken(userID, l.svcCtx.Config.JwtAuth.AccessSecret, l.svcCtx.Config.JwtAuth.AccessExpire)
|
||||
if generaErr != nil {
|
||||
token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 生成token失败 : %d", userID)
|
||||
}
|
||||
|
||||
@@ -1393,30 +1392,32 @@ func (l *QueryServiceLogic) CacheData(params map[string]interface{}, Product str
|
||||
// 3. 其他情况返回未登录错误
|
||||
func (l *QueryServiceLogic) GetOrCreateUser() (int64, error) {
|
||||
// 尝试获取用户ID
|
||||
userID, err := ctxdata.GetUidFromCtx(l.ctx)
|
||||
if err == nil {
|
||||
return userID, nil // 已有用户ID,直接返回
|
||||
}
|
||||
|
||||
// 如果不是未登录错误,说明是其他错误,直接返回
|
||||
if !ctxdata.IsNoUserIdError(err) {
|
||||
claims, err := ctxdata.GetClaimsFromCtx(l.ctx)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
userID := claims.UserId
|
||||
return userID, nil
|
||||
|
||||
// 检查是否是代理查询或APP请求
|
||||
isAgentQuery := false
|
||||
if agentID, ok := l.ctx.Value("agentIdentifier").(string); ok && agentID != "" {
|
||||
isAgentQuery = true
|
||||
}
|
||||
if app, ok := l.ctx.Value("app").(bool); ok && app {
|
||||
isAgentQuery = true
|
||||
}
|
||||
// // 如果不是未登录错误,说明是其他错误,直接返回
|
||||
// if !ctxdata.IsNoUserIdError(err) {
|
||||
// return 0, err
|
||||
// }
|
||||
|
||||
// 如果不是代理查询或APP请求,返回未登录错误
|
||||
if !isAgentQuery {
|
||||
return 0, ctxdata.ErrNoUserIdInCtx
|
||||
}
|
||||
// // 检查是否是代理查询或APP请求
|
||||
// isAgentQuery := false
|
||||
// if agentID, ok := l.ctx.Value("agentIdentifier").(string); ok && agentID != "" {
|
||||
// isAgentQuery = true
|
||||
// }
|
||||
// if app, ok := l.ctx.Value("app").(bool); ok && app {
|
||||
// isAgentQuery = true
|
||||
// }
|
||||
|
||||
// 创建新用户
|
||||
return l.svcCtx.UserService.RegisterUUIDUser(l.ctx)
|
||||
// // 如果不是代理查询或APP请求,返回未登录错误
|
||||
// if !isAgentQuery {
|
||||
// return 0, ctxdata.ErrNoUserIdInCtx
|
||||
// }
|
||||
|
||||
// // 创建新用户
|
||||
// return l.svcCtx.UserService.RegisterUUIDUser(l.ctx)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user