This commit is contained in:
15
help/异常经验数据修复.sql
Normal file
15
help/异常经验数据修复.sql
Normal file
@@ -0,0 +1,15 @@
|
||||
SELECT
|
||||
player_id,
|
||||
-- 使用 CASE WHEN 实现条件判断:超过 1000 万重置为 200 万,否则保留原数值
|
||||
CASE
|
||||
WHEN (data->>'exp_pool')::bigint > 10000000 -- 判断是否超过 1000 万
|
||||
THEN 2000000::bigint -- 超过则重置为 200 万,统一为 bigint 类型避免类型不一致
|
||||
ELSE (data->>'exp_pool')::bigint -- 未超过则保留原 bigint 数值
|
||||
END AS online_time
|
||||
FROM "player_info"
|
||||
-- 保留 jsonb_exists 函数判断字段存在,避免占位符冲突
|
||||
WHERE
|
||||
jsonb_exists(data, 'exp_pool')
|
||||
AND (data->>'exp_pool')::bigint > 0 -- 此处仍保留原判断,过滤大于 0 的数据
|
||||
-- 按修正后的 online_time 降序排序
|
||||
ORDER BY online_time DESC;
|
||||
@@ -232,13 +232,14 @@ func (player1 *Player) Kick(qtype int) {
|
||||
// player1.Save() //先保存数据再返回
|
||||
head := common.NewTomeeHeader(1001, player1.Info.UserID)
|
||||
|
||||
head.Result = uint32(errorcode.ErrorCodes.ErrAccountLoggedInElsewhere)
|
||||
if qtype == 1 {
|
||||
head.Result = uint32(errorcode.ErrorCodes.ErrXinPlanSleepMode)
|
||||
}
|
||||
head.Result = uint32(errorcode.ErrorCodes.ErrXinPlanSleepMode)
|
||||
// 实际上这里有个问题,会造成重复保存问题
|
||||
|
||||
player1.SendPack(head.Pack(nil))
|
||||
if qtype == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
CloseChan := make(chan struct{})
|
||||
|
||||
player1.MainConn.CloseWithCallback(func(c gnet.Conn, err error) error {
|
||||
|
||||
@@ -14,7 +14,6 @@ import (
|
||||
func (p *Player) Save() {
|
||||
cool.CacheManager.Remove(context.TODO(), fmt.Sprintf("player:%d", p.Info.UserID))
|
||||
if cool.Config.ServerInfo.IsVip != 0 {
|
||||
cool.Logger.Info(context.TODO(), "测试服不保存玩家数据", p.Info.UserID)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ func BaseAuthorityMiddleware(r *ghttp.Request) {
|
||||
return []byte(config.Config.Jwt.Secret), nil
|
||||
})
|
||||
if err != nil {
|
||||
cool.Logger.Error(ctx, "BaseAuthorityMiddleware", err)
|
||||
|
||||
statusCode = 401
|
||||
r.Response.WriteStatusExit(statusCode, g.Map{
|
||||
"code": 1001,
|
||||
@@ -59,7 +59,7 @@ func BaseAuthorityMiddleware(r *ghttp.Request) {
|
||||
})
|
||||
}
|
||||
if !token.Valid {
|
||||
cool.Logger.Error(ctx, "BaseAuthorityMiddleware", "token invalid")
|
||||
|
||||
statusCode = 401
|
||||
r.Response.WriteStatusExit(statusCode, g.Map{
|
||||
"code": 1001,
|
||||
@@ -75,7 +75,7 @@ func BaseAuthorityMiddleware(r *ghttp.Request) {
|
||||
// 超管拥有所有权限
|
||||
if admin.UserId == 10001 && !admin.IsRefresh {
|
||||
if tokenString != rtoken && config.Config.Jwt.Sso {
|
||||
cool.Logger.Error(ctx, "BaseAuthorityMiddleware", "token invalid")
|
||||
|
||||
statusCode = 401
|
||||
r.Response.WriteStatusExit(statusCode, g.Map{
|
||||
"code": 1001,
|
||||
@@ -94,7 +94,7 @@ func BaseAuthorityMiddleware(r *ghttp.Request) {
|
||||
}
|
||||
// 如果传的token是refreshToken则校验失败
|
||||
if admin.IsRefresh {
|
||||
cool.Logger.Error(ctx, "BaseAuthorityMiddleware", "token invalid")
|
||||
|
||||
statusCode = 401
|
||||
r.Response.WriteStatusExit(statusCode, g.Map{
|
||||
"code": 1001,
|
||||
@@ -104,16 +104,16 @@ func BaseAuthorityMiddleware(r *ghttp.Request) {
|
||||
// 判断密码版本是否正确
|
||||
passwordV, _ := cool.CacheManager.Get(ctx, "admin:passwordVersion:"+gconv.String(admin.UserId))
|
||||
if passwordV.Int32() != *admin.PasswordVersion {
|
||||
cool.Logger.Error(ctx, "BaseAuthorityMiddleware", "passwordV invalid")
|
||||
|
||||
statusCode = 401
|
||||
r.Response.WriteStatusExit(statusCode, g.Map{
|
||||
"code": 1001,
|
||||
"message": "登陆失效~",
|
||||
"message": "密码过期,登陆失效~",
|
||||
})
|
||||
}
|
||||
// 如果rtoken为空
|
||||
if rtoken == "" {
|
||||
cool.Logger.Error(ctx, "BaseAuthorityMiddleware", "rtoken invalid")
|
||||
|
||||
statusCode = 401
|
||||
r.Response.WriteStatusExit(statusCode, g.Map{
|
||||
"code": 1001,
|
||||
@@ -122,7 +122,7 @@ func BaseAuthorityMiddleware(r *ghttp.Request) {
|
||||
}
|
||||
// 如果rtoken不等于token 且 sso 未开启
|
||||
if tokenString != rtoken && !config.Config.Jwt.Sso {
|
||||
cool.Logger.Error(ctx, "BaseAuthorityMiddleware", "token invalid")
|
||||
|
||||
statusCode = 401
|
||||
r.Response.WriteStatusExit(statusCode, g.Map{
|
||||
"code": 1001,
|
||||
@@ -137,7 +137,7 @@ func BaseAuthorityMiddleware(r *ghttp.Request) {
|
||||
perms := garray.NewStrArrayFrom(permsVar)
|
||||
// 如果perms为空
|
||||
if perms.Len() == 0 {
|
||||
cool.Logger.Error(ctx, "BaseAuthorityMiddleware", "perms invalid")
|
||||
|
||||
statusCode = 403
|
||||
r.Response.WriteStatusExit(statusCode, g.Map{
|
||||
"code": 1001,
|
||||
@@ -157,7 +157,7 @@ func BaseAuthorityMiddleware(r *ghttp.Request) {
|
||||
url = gstr.Join(urls, ":")
|
||||
// 如果perms中不包含url 则无权限
|
||||
if !perms.ContainsI(url) {
|
||||
cool.Logger.Error(ctx, "BaseAuthorityMiddleware", "perms invalid")
|
||||
|
||||
statusCode = 403
|
||||
r.Response.WriteStatusExit(statusCode, g.Map{
|
||||
"code": 1001,
|
||||
|
||||
@@ -134,7 +134,7 @@ func (*BaseSysLoginService) Captcha(req *v1.BaseOpenCaptchaReq) (interface{}, er
|
||||
result.Data = `data:image/svg+xml;base64,` + svgbase64
|
||||
result.CaptchaId = guid.S()
|
||||
cool.CacheManager.Set(ctx, "login:"+result.CaptchaId, captchaText, 1800*time.Second)
|
||||
cool.Logger.Debug(ctx, "验证码", result.CaptchaId, captchaText)
|
||||
|
||||
return result, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user