f
This commit is contained in:
@@ -61,6 +61,7 @@ type (
|
||||
Nickname string `json:"nickname"` // 昵称
|
||||
Info string `json:"info"` // 备注信息
|
||||
Inside int64 `json:"inside"` // 是否内部用户 1-是 0-否
|
||||
Disable int64 `json:"disable"` // 0可用 1禁用
|
||||
CreateTime string `json:"create_time"` // 创建时间
|
||||
UpdateTime string `json:"update_time"` // 更新时间
|
||||
}
|
||||
@@ -77,6 +78,7 @@ type (
|
||||
Nickname string `json:"nickname"` // 昵称
|
||||
Info string `json:"info"` // 备注信息
|
||||
Inside int64 `json:"inside"` // 是否内部用户 1-是 0-否
|
||||
Disable int64 `json:"disable"` // 0可用 1禁用
|
||||
CreateTime string `json:"create_time"` // 创建时间
|
||||
UpdateTime string `json:"update_time"` // 更新时间
|
||||
}
|
||||
@@ -103,6 +105,7 @@ type (
|
||||
Nickname *string `json:"nickname,optional"` // 昵称
|
||||
Info *string `json:"info,optional"` // 备注信息
|
||||
Inside *int64 `json:"inside,optional"` // 是否内部用户 1-是 0-否
|
||||
Disable *int64 `json:"disable,optional"` // 0可用 1禁用
|
||||
}
|
||||
|
||||
// 更新响应
|
||||
|
||||
@@ -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"),
|
||||
}
|
||||
|
||||
@@ -29,9 +29,14 @@ func NewAdminGetPlatformUserListLogic(ctx context.Context, svcCtx *svc.ServiceCo
|
||||
}
|
||||
|
||||
func (l *AdminGetPlatformUserListLogic) AdminGetPlatformUserList(req *types.AdminGetPlatformUserListReq) (resp *types.AdminGetPlatformUserListResp, err error) {
|
||||
secretKey := l.svcCtx.Config.Encrypt.SecretKey
|
||||
builder := l.svcCtx.UserModel.SelectBuilder()
|
||||
if req.Mobile != "" {
|
||||
builder = builder.Where("mobile = ?", req.Mobile)
|
||||
encryptedMobile, err := crypto.EncryptMobile(req.Mobile, secretKey)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "手机号加密失败: %v", err)
|
||||
}
|
||||
builder = builder.Where("mobile = ?", encryptedMobile)
|
||||
}
|
||||
if req.Nickname != "" {
|
||||
builder = builder.Where("nickname = ?", req.Nickname)
|
||||
@@ -55,7 +60,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
|
||||
@@ -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 != ""}
|
||||
}
|
||||
|
||||
@@ -64,6 +64,10 @@ func (l *MobileCodeLoginLogic) MobileCodeLogin(req *types.MobileCodeLoginReq) (r
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "手机登录, 注册用户失败: %+v", err)
|
||||
}
|
||||
} else {
|
||||
// 封禁用户禁止登录
|
||||
if user.Disable == model.UserDisableBanned {
|
||||
return nil, xerr.NewErrCode(xerr.USER_DISABLED)
|
||||
}
|
||||
userID = user.Id
|
||||
}
|
||||
token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID, model.UserTypeNormal)
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"net/http"
|
||||
|
||||
"xingfucha-server/app/main/api/internal/config"
|
||||
"xingfucha-server/app/main/model"
|
||||
jwtx "xingfucha-server/common/jwt"
|
||||
"xingfucha-server/common/xerr"
|
||||
|
||||
@@ -18,12 +19,14 @@ const (
|
||||
)
|
||||
|
||||
type AuthInterceptorMiddleware struct {
|
||||
Config config.Config
|
||||
Config config.Config
|
||||
UserModel model.UserModel
|
||||
}
|
||||
|
||||
func NewAuthInterceptorMiddleware(c config.Config) *AuthInterceptorMiddleware {
|
||||
func NewAuthInterceptorMiddleware(c config.Config, userModel model.UserModel) *AuthInterceptorMiddleware {
|
||||
return &AuthInterceptorMiddleware{
|
||||
Config: c,
|
||||
Config: c,
|
||||
UserModel: userModel,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +49,15 @@ func (m *AuthInterceptorMiddleware) Handle(next http.HandlerFunc) http.HandlerFu
|
||||
return
|
||||
}
|
||||
|
||||
// 携带token的请求:校验用户是否被封禁(保证封禁即时生效)
|
||||
if m.UserModel != nil && claims.UserId > 0 {
|
||||
user, err := m.UserModel.FindOne(r.Context(), claims.UserId)
|
||||
if err == nil && user.Disable == model.UserDisableBanned {
|
||||
httpx.Error(w, xerr.NewErrCode(xerr.USER_DISABLED))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
ctx := context.WithValue(r.Context(), jwtx.ExtraKey, claims)
|
||||
|
||||
// 使用新的上下文继续处理请求
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"xingfucha-server/app/main/model"
|
||||
"xingfucha-server/common/ctxdata"
|
||||
"xingfucha-server/common/xerr"
|
||||
"net/http"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
)
|
||||
|
||||
type UserAuthInterceptorMiddleware struct {
|
||||
UserModel model.UserModel
|
||||
}
|
||||
|
||||
func NewUserAuthInterceptorMiddleware() *UserAuthInterceptorMiddleware {
|
||||
return &UserAuthInterceptorMiddleware{}
|
||||
func NewUserAuthInterceptorMiddleware(userModel model.UserModel) *UserAuthInterceptorMiddleware {
|
||||
return &UserAuthInterceptorMiddleware{UserModel: userModel}
|
||||
}
|
||||
|
||||
func (m *UserAuthInterceptorMiddleware) Handle(next http.HandlerFunc) http.HandlerFunc {
|
||||
@@ -28,6 +30,15 @@ func (m *UserAuthInterceptorMiddleware) Handle(next http.HandlerFunc) http.Handl
|
||||
httpx.Error(w, errors.Wrapf(xerr.NewErrCode(xerr.USER_NEED_BIND_MOBILE), "token解析失败: %v", err))
|
||||
return
|
||||
}
|
||||
user, err := m.UserModel.FindOne(r.Context(), claims.UserId)
|
||||
if err != nil {
|
||||
httpx.Error(w, errors.Wrapf(xerr.NewErrCode(ErrCodeUnauthorized), "用户不存在: %v", err))
|
||||
return
|
||||
}
|
||||
if user.Disable == model.UserDisableBanned {
|
||||
httpx.Error(w, xerr.NewErrCode(xerr.USER_DISABLED))
|
||||
return
|
||||
}
|
||||
next(w, r)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,8 +222,8 @@ func NewServiceContext(c config.Config) *ServiceContext {
|
||||
return &ServiceContext{
|
||||
Config: c,
|
||||
Redis: redisClient,
|
||||
AuthInterceptor: middleware.NewAuthInterceptorMiddleware(c).Handle,
|
||||
UserAuthInterceptor: middleware.NewUserAuthInterceptorMiddleware().Handle,
|
||||
AuthInterceptor: middleware.NewAuthInterceptorMiddleware(c, userModel).Handle,
|
||||
UserAuthInterceptor: middleware.NewUserAuthInterceptorMiddleware(userModel).Handle,
|
||||
AdminAuthInterceptor: middleware.NewAdminAuthInterceptorMiddleware(c,
|
||||
adminUserModel, adminUserRoleModel, adminRoleModel, adminApiModel, adminRoleApiModel).Handle,
|
||||
|
||||
|
||||
@@ -568,6 +568,7 @@ type AdminGetPlatformUserDetailResp struct {
|
||||
Nickname string `json:"nickname"` // 昵称
|
||||
Info string `json:"info"` // 备注信息
|
||||
Inside int64 `json:"inside"` // 是否内部用户 1-是 0-否
|
||||
Disable int64 `json:"disable"` // 0可用 1禁用
|
||||
CreateTime string `json:"create_time"` // 创建时间
|
||||
UpdateTime string `json:"update_time"` // 更新时间
|
||||
}
|
||||
@@ -950,6 +951,7 @@ type AdminUpdatePlatformUserReq struct {
|
||||
Nickname *string `json:"nickname,optional"` // 昵称
|
||||
Info *string `json:"info,optional"` // 备注信息
|
||||
Inside *int64 `json:"inside,optional"` // 是否内部用户 1-是 0-否
|
||||
Disable *int64 `json:"disable,optional"` // 0可用 1禁用
|
||||
}
|
||||
|
||||
type AdminUpdatePlatformUserResp struct {
|
||||
@@ -1856,6 +1858,7 @@ type PlatformUserListItem struct {
|
||||
Nickname string `json:"nickname"` // 昵称
|
||||
Info string `json:"info"` // 备注信息
|
||||
Inside int64 `json:"inside"` // 是否内部用户 1-是 0-否
|
||||
Disable int64 `json:"disable"` // 0可用 1禁用
|
||||
CreateTime string `json:"create_time"` // 创建时间
|
||||
UpdateTime string `json:"update_time"` // 更新时间
|
||||
}
|
||||
|
||||
@@ -27,8 +27,8 @@ var (
|
||||
userRowsExpectAutoSet = strings.Join(stringx.Remove(userFieldNames, "`id`", "`create_time`", "`update_time`"), ",")
|
||||
userRowsWithPlaceHolder = strings.Join(stringx.Remove(userFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?"
|
||||
|
||||
cacheHmUserIdPrefix = "cache:xingfucha:user:id:"
|
||||
cacheHmUserMobilePrefix = "cache:xingfucha:user:mobile:"
|
||||
cacheXfcUserIdPrefix = "cache:xfc:user:id:"
|
||||
cacheXfcUserMobilePrefix = "cache:xfc:user:mobile:"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -68,6 +68,7 @@ type (
|
||||
Nickname sql.NullString `db:"nickname"`
|
||||
Info string `db:"info"`
|
||||
Inside int64 `db:"inside"`
|
||||
Disable int64 `db:"disable"` // 0可用 1禁用
|
||||
}
|
||||
)
|
||||
|
||||
@@ -80,21 +81,21 @@ func newUserModel(conn sqlx.SqlConn, c cache.CacheConf) *defaultUserModel {
|
||||
|
||||
func (m *defaultUserModel) Insert(ctx context.Context, session sqlx.Session, data *User) (sql.Result, error) {
|
||||
data.DelState = globalkey.DelStateNo
|
||||
hmUserIdKey := fmt.Sprintf("%s%v", cacheHmUserIdPrefix, data.Id)
|
||||
hmUserMobileKey := fmt.Sprintf("%s%v", cacheHmUserMobilePrefix, data.Mobile)
|
||||
xfcUserIdKey := fmt.Sprintf("%s%v", cacheXfcUserIdPrefix, data.Id)
|
||||
xfcUserMobileKey := fmt.Sprintf("%s%v", cacheXfcUserMobilePrefix, data.Mobile)
|
||||
return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?)", m.table, userRowsExpectAutoSet)
|
||||
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, userRowsExpectAutoSet)
|
||||
if session != nil {
|
||||
return session.ExecCtx(ctx, query, data.DeleteTime, data.DelState, data.Version, data.Mobile, data.Password, data.Nickname, data.Info, data.Inside)
|
||||
return session.ExecCtx(ctx, query, data.DeleteTime, data.DelState, data.Version, data.Mobile, data.Password, data.Nickname, data.Info, data.Inside, data.Disable)
|
||||
}
|
||||
return conn.ExecCtx(ctx, query, data.DeleteTime, data.DelState, data.Version, data.Mobile, data.Password, data.Nickname, data.Info, data.Inside)
|
||||
}, hmUserIdKey, hmUserMobileKey)
|
||||
return conn.ExecCtx(ctx, query, data.DeleteTime, data.DelState, data.Version, data.Mobile, data.Password, data.Nickname, data.Info, data.Inside, data.Disable)
|
||||
}, xfcUserIdKey, xfcUserMobileKey)
|
||||
}
|
||||
|
||||
func (m *defaultUserModel) FindOne(ctx context.Context, id int64) (*User, error) {
|
||||
hmUserIdKey := fmt.Sprintf("%s%v", cacheHmUserIdPrefix, id)
|
||||
xfcUserIdKey := fmt.Sprintf("%s%v", cacheXfcUserIdPrefix, id)
|
||||
var resp User
|
||||
err := m.QueryRowCtx(ctx, &resp, hmUserIdKey, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) error {
|
||||
err := m.QueryRowCtx(ctx, &resp, xfcUserIdKey, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) error {
|
||||
query := fmt.Sprintf("select %s from %s where `id` = ? and del_state = ? limit 1", userRows, m.table)
|
||||
return conn.QueryRowCtx(ctx, v, query, id, globalkey.DelStateNo)
|
||||
})
|
||||
@@ -109,9 +110,9 @@ func (m *defaultUserModel) FindOne(ctx context.Context, id int64) (*User, error)
|
||||
}
|
||||
|
||||
func (m *defaultUserModel) FindOneByMobile(ctx context.Context, mobile sql.NullString) (*User, error) {
|
||||
hmUserMobileKey := fmt.Sprintf("%s%v", cacheHmUserMobilePrefix, mobile)
|
||||
xfcUserMobileKey := fmt.Sprintf("%s%v", cacheXfcUserMobilePrefix, mobile)
|
||||
var resp User
|
||||
err := m.QueryRowIndexCtx(ctx, &resp, hmUserMobileKey, m.formatPrimary, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) (i interface{}, e error) {
|
||||
err := m.QueryRowIndexCtx(ctx, &resp, xfcUserMobileKey, m.formatPrimary, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) (i interface{}, e error) {
|
||||
query := fmt.Sprintf("select %s from %s where `mobile` = ? and del_state = ? limit 1", userRows, m.table)
|
||||
if err := conn.QueryRowCtx(ctx, &resp, query, mobile, globalkey.DelStateNo); err != nil {
|
||||
return nil, err
|
||||
@@ -133,15 +134,15 @@ func (m *defaultUserModel) Update(ctx context.Context, session sqlx.Session, new
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
hmUserIdKey := fmt.Sprintf("%s%v", cacheHmUserIdPrefix, data.Id)
|
||||
hmUserMobileKey := fmt.Sprintf("%s%v", cacheHmUserMobilePrefix, data.Mobile)
|
||||
xfcUserIdKey := fmt.Sprintf("%s%v", cacheXfcUserIdPrefix, data.Id)
|
||||
xfcUserMobileKey := fmt.Sprintf("%s%v", cacheXfcUserMobilePrefix, data.Mobile)
|
||||
return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, userRowsWithPlaceHolder)
|
||||
if session != nil {
|
||||
return session.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.Mobile, newData.Password, newData.Nickname, newData.Info, newData.Inside, newData.Id)
|
||||
return session.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.Mobile, newData.Password, newData.Nickname, newData.Info, newData.Inside, newData.Disable, newData.Id)
|
||||
}
|
||||
return conn.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.Mobile, newData.Password, newData.Nickname, newData.Info, newData.Inside, newData.Id)
|
||||
}, hmUserIdKey, hmUserMobileKey)
|
||||
return conn.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.Mobile, newData.Password, newData.Nickname, newData.Info, newData.Inside, newData.Disable, newData.Id)
|
||||
}, xfcUserIdKey, xfcUserMobileKey)
|
||||
}
|
||||
|
||||
func (m *defaultUserModel) UpdateWithVersion(ctx context.Context, session sqlx.Session, newData *User) error {
|
||||
@@ -156,15 +157,15 @@ func (m *defaultUserModel) UpdateWithVersion(ctx context.Context, session sqlx.S
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
hmUserIdKey := fmt.Sprintf("%s%v", cacheHmUserIdPrefix, data.Id)
|
||||
hmUserMobileKey := fmt.Sprintf("%s%v", cacheHmUserMobilePrefix, data.Mobile)
|
||||
xfcUserIdKey := fmt.Sprintf("%s%v", cacheXfcUserIdPrefix, data.Id)
|
||||
xfcUserMobileKey := fmt.Sprintf("%s%v", cacheXfcUserMobilePrefix, data.Mobile)
|
||||
sqlResult, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||
query := fmt.Sprintf("update %s set %s where `id` = ? and version = ? ", m.table, userRowsWithPlaceHolder)
|
||||
if session != nil {
|
||||
return session.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.Mobile, newData.Password, newData.Nickname, newData.Info, newData.Inside, newData.Id, oldVersion)
|
||||
return session.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.Mobile, newData.Password, newData.Nickname, newData.Info, newData.Inside, newData.Disable, newData.Id, oldVersion)
|
||||
}
|
||||
return conn.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.Mobile, newData.Password, newData.Nickname, newData.Info, newData.Inside, newData.Id, oldVersion)
|
||||
}, hmUserIdKey, hmUserMobileKey)
|
||||
return conn.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.Mobile, newData.Password, newData.Nickname, newData.Info, newData.Inside, newData.Disable, newData.Id, oldVersion)
|
||||
}, xfcUserIdKey, xfcUserMobileKey)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -387,19 +388,19 @@ func (m *defaultUserModel) Delete(ctx context.Context, session sqlx.Session, id
|
||||
return err
|
||||
}
|
||||
|
||||
hmUserIdKey := fmt.Sprintf("%s%v", cacheHmUserIdPrefix, id)
|
||||
hmUserMobileKey := fmt.Sprintf("%s%v", cacheHmUserMobilePrefix, data.Mobile)
|
||||
xfcUserIdKey := fmt.Sprintf("%s%v", cacheXfcUserIdPrefix, id)
|
||||
xfcUserMobileKey := fmt.Sprintf("%s%v", cacheXfcUserMobilePrefix, data.Mobile)
|
||||
_, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||
query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
|
||||
if session != nil {
|
||||
return session.ExecCtx(ctx, query, id)
|
||||
}
|
||||
return conn.ExecCtx(ctx, query, id)
|
||||
}, hmUserIdKey, hmUserMobileKey)
|
||||
}, xfcUserIdKey, xfcUserMobileKey)
|
||||
return err
|
||||
}
|
||||
func (m *defaultUserModel) formatPrimary(primary interface{}) string {
|
||||
return fmt.Sprintf("%s%v", cacheHmUserIdPrefix, primary)
|
||||
return fmt.Sprintf("%s%v", cacheXfcUserIdPrefix, primary)
|
||||
}
|
||||
func (m *defaultUserModel) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary interface{}) error {
|
||||
query := fmt.Sprintf("select %s from %s where `id` = ? and del_state = ? limit 1", userRows, m.table)
|
||||
|
||||
@@ -92,6 +92,12 @@ const (
|
||||
UserTypeAdmin = 2 // 管理员
|
||||
)
|
||||
|
||||
// 用户禁用状态
|
||||
const (
|
||||
UserDisableNormal = 0 // 可用
|
||||
UserDisableBanned = 1 // 封禁
|
||||
)
|
||||
|
||||
// 管理员角色编码
|
||||
const (
|
||||
AdminRoleCodeSuper = "SUPER" // 超级管理员
|
||||
|
||||
@@ -16,6 +16,7 @@ const PARAM_VERIFICATION_ERROR uint32 = 100007
|
||||
const CUSTOM_ERROR uint32 = 100008
|
||||
const USER_NOT_FOUND uint32 = 100009
|
||||
const USER_NEED_BIND_MOBILE uint32 = 100010
|
||||
const USER_DISABLED uint32 = 100011
|
||||
|
||||
const LOGIN_FAILED uint32 = 200001
|
||||
const LOGIC_QUERY_WAIT uint32 = 200002
|
||||
|
||||
@@ -11,6 +11,7 @@ func init() {
|
||||
message[TOKEN_GENERATE_ERROR] = "生成token失败"
|
||||
message[DB_ERROR] = "系统维护升级中,请稍后再试"
|
||||
message[DB_UPDATE_AFFECTED_ZERO_ERROR] = "更新数据影响行数为0"
|
||||
message[USER_DISABLED] = "您已被封禁"
|
||||
}
|
||||
|
||||
func MapErrMsg(errcode uint32) string {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
# 设置输出编码为UTF-8
|
||||
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
||||
# 数据库连接信息 - 修改了URL格式
|
||||
$DB_URL = "xingfucha:5vg67b3UNHu8@(127.0.0.1:21001)/xingfucha"
|
||||
# $DB_URL = "xingfucha:5vg67b3UNHu8@(127.0.0.1:21001)/xingfucha"
|
||||
$DB_URL = "xfc:xfc5vg67b3UNHu8@(127.0.0.1:23201)/xfc"
|
||||
$OUTPUT_DIR = "./model"
|
||||
$TEMPLATE_DIR = "../template"
|
||||
|
||||
@@ -38,7 +39,7 @@ $tables = @(
|
||||
# "query_cleanup_log"
|
||||
# "query_cleanup_detail"
|
||||
# "query_cleanup_config"
|
||||
# "user"
|
||||
"user"
|
||||
# "user_auth"
|
||||
# "user_temp"
|
||||
# "example"
|
||||
@@ -60,5 +61,6 @@ $tables = @(
|
||||
|
||||
# 为每个表生成模型
|
||||
foreach ($table in $tables) {
|
||||
goctl model mysql datasource -url="xingfucha:5vg67b3UNHu8@tcp(127.0.0.1:21001)/xingfucha" -table="$table" -dir="./model" --home="../template" -cache=true --style=goZero
|
||||
# goctl model mysql datasource -url="xingfucha:5vg67b3UNHu8@tcp(127.0.0.1:21001)/xingfucha" -table="$table" -dir="./model" --home="../template" -cache=true --style=goZero
|
||||
goctl model mysql datasource -url="xfc:xfc5vg67b3UNHu8@tcp(127.0.0.1:23201)/xfc" -table="$table" -dir="./model" --home="../template" -cache=true --style=goZero
|
||||
}
|
||||
|
||||
2
deploy/sql/user_add_disable.sql
Normal file
2
deploy/sql/user_add_disable.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
-- 为用户表添加 disable 字段:0 可用,1 禁用,默认 0
|
||||
ALTER TABLE `user` ADD COLUMN `disable` tinyint NOT NULL DEFAULT 0 COMMENT '0可用 1禁用' AFTER `inside`;
|
||||
Reference in New Issue
Block a user