f
This commit is contained in:
@@ -43,6 +43,7 @@ func (l *AdminGetPlatformUserDetailLogic) AdminGetPlatformUserDetail(req *types.
|
||||
Nickname: "",
|
||||
Info: user.Info,
|
||||
Inside: user.Inside,
|
||||
Disable: user.Disable,
|
||||
CreateTime: user.CreateTime.Format("2006-01-02 15:04:05"),
|
||||
UpdateTime: user.UpdateTime.Format("2006-01-02 15:04:05"),
|
||||
}
|
||||
|
||||
@@ -30,8 +30,14 @@ func NewAdminGetPlatformUserListLogic(ctx context.Context, svcCtx *svc.ServiceCo
|
||||
|
||||
func (l *AdminGetPlatformUserListLogic) AdminGetPlatformUserList(req *types.AdminGetPlatformUserListReq) (resp *types.AdminGetPlatformUserListResp, err error) {
|
||||
builder := l.svcCtx.UserModel.SelectBuilder()
|
||||
secretKey := l.svcCtx.Config.Encrypt.SecretKey
|
||||
if req.Mobile != "" {
|
||||
builder = builder.Where("mobile = ?", req.Mobile)
|
||||
// 数据库存密文,筛选时用明文加密后再匹配
|
||||
encryptedMobile, encErr := crypto.EncryptMobile(req.Mobile, secretKey)
|
||||
if encErr != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "手机号加密失败: %v", encErr)
|
||||
}
|
||||
builder = builder.Where("mobile = ?", encryptedMobile)
|
||||
}
|
||||
if req.Nickname != "" {
|
||||
builder = builder.Where("nickname = ?", req.Nickname)
|
||||
@@ -55,8 +61,6 @@ func (l *AdminGetPlatformUserListLogic) AdminGetPlatformUserList(req *types.Admi
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询用户分页失败: %v", err)
|
||||
}
|
||||
var items []types.PlatformUserListItem
|
||||
secretKey := l.svcCtx.Config.Encrypt.SecretKey
|
||||
|
||||
for _, user := range users {
|
||||
mobile := user.Mobile
|
||||
if mobile.Valid {
|
||||
@@ -72,6 +76,7 @@ func (l *AdminGetPlatformUserListLogic) AdminGetPlatformUserList(req *types.Admi
|
||||
Nickname: "",
|
||||
Info: user.Info,
|
||||
Inside: user.Inside,
|
||||
Disable: user.Disable,
|
||||
CreateTime: user.CreateTime.Format("2006-01-02 15:04:05"),
|
||||
UpdateTime: user.UpdateTime.Format("2006-01-02 15:04:05"),
|
||||
}
|
||||
|
||||
@@ -52,6 +52,12 @@ func (l *AdminUpdatePlatformUserLogic) AdminUpdatePlatformUser(req *types.AdminU
|
||||
}
|
||||
user.Inside = *req.Inside
|
||||
}
|
||||
if req.Disable != nil {
|
||||
if *req.Disable != 1 && *req.Disable != 0 {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "封禁状态错误: %d", *req.Disable)
|
||||
}
|
||||
user.Disable = *req.Disable
|
||||
}
|
||||
if req.Password != nil {
|
||||
user.Password = sql.NullString{String: *req.Password, Valid: *req.Password != ""}
|
||||
}
|
||||
|
||||
@@ -40,8 +40,8 @@ func NewQueryServiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Quer
|
||||
|
||||
func (l *QueryServiceLogic) QueryService(req *types.QueryServiceReq) (resp *types.QueryServiceResp, err error) {
|
||||
if req.AgentIdentifier != "" {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("系统正在升级,查询服务暂不可用,恢复时间待定"), "查询服务暂停, AgentIdentifier: %s", req.AgentIdentifier)
|
||||
// l.ctx = context.WithValue(l.ctx, "agentIdentifier", req.AgentIdentifier)
|
||||
// return nil, errors.Wrapf(xerr.NewErrMsg("系统正在升级,查询服务暂不可用,恢复时间待定"), "查询服务暂停, AgentIdentifier: %s", req.AgentIdentifier)
|
||||
l.ctx = context.WithValue(l.ctx, "agentIdentifier", req.AgentIdentifier)
|
||||
} else if req.App {
|
||||
l.ctx = context.WithValue(l.ctx, "app", req.App)
|
||||
}
|
||||
|
||||
@@ -97,6 +97,10 @@ func (l *BindMobileLogic) BindMobile(req *types.BindMobileReq) (resp *types.Bind
|
||||
|
||||
token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID, model.UserTypeNormal)
|
||||
if err != nil {
|
||||
causeErr := errors.Cause(err)
|
||||
if _, ok := causeErr.(*xerr.CodeError); ok {
|
||||
return nil, err
|
||||
}
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "绑定手机号, 生成token失败: %+v", err)
|
||||
}
|
||||
now := time.Now().Unix()
|
||||
|
||||
@@ -2,9 +2,9 @@ package user
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
"tydata-server/common/ctxdata"
|
||||
"tydata-server/common/xerr"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
@@ -35,6 +35,10 @@ func (l *GetTokenLogic) GetToken() (resp *types.MobileCodeLoginResp, err error)
|
||||
}
|
||||
token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, claims.UserId, claims.UserType)
|
||||
if err != nil {
|
||||
causeErr := errors.Cause(err)
|
||||
if _, ok := causeErr.(*xerr.CodeError); ok {
|
||||
return nil, err
|
||||
}
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "用户信息, %v", err)
|
||||
}
|
||||
// 获取当前时间戳
|
||||
|
||||
@@ -68,7 +68,12 @@ func (l *MobileCodeLoginLogic) MobileCodeLogin(req *types.MobileCodeLoginReq) (r
|
||||
}
|
||||
token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID, model.UserTypeNormal)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "手机登录, 生成token失败 : %d", userID)
|
||||
// 封禁等业务错误原样返回,便于前端展示「用户已被封禁」
|
||||
causeErr := errors.Cause(err)
|
||||
if _, ok := causeErr.(*xerr.CodeError); ok {
|
||||
return nil, err
|
||||
}
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "手机登录, 生成token失败 : %d, %v", userID, err)
|
||||
}
|
||||
|
||||
// 获取当前时间戳
|
||||
|
||||
@@ -2,13 +2,13 @@ package user
|
||||
|
||||
import (
|
||||
"context"
|
||||
"tydata-server/app/main/model"
|
||||
"tydata-server/common/xerr"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"time"
|
||||
"tydata-server/app/main/model"
|
||||
"tydata-server/common/xerr"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
@@ -82,6 +82,10 @@ func (l *WxH5AuthLogic) WxH5Auth(req *types.WXH5AuthReq) (resp *types.WXH5AuthRe
|
||||
// Step 4: 生成JWT Token
|
||||
token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID, userType)
|
||||
if err != nil {
|
||||
causeErr := errors.Cause(err)
|
||||
if _, ok := causeErr.(*xerr.CodeError); ok {
|
||||
return nil, err
|
||||
}
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "生成JWT token失败: %v", err)
|
||||
}
|
||||
|
||||
|
||||
@@ -81,6 +81,10 @@ func (l *WxMiniAuthLogic) WxMiniAuth(req *types.WXMiniAuthReq) (resp *types.WXMi
|
||||
// 4. 生成JWT Token
|
||||
token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID, userType)
|
||||
if err != nil {
|
||||
causeErr := errors.Cause(err)
|
||||
if _, ok := causeErr.(*xerr.CodeError); ok {
|
||||
return nil, err
|
||||
}
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "生成JWT Token失败: %v", err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user