You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.4 KiB
57 lines
1.4 KiB
|
1 year ago
|
package guser
|
||
|
|
|
||
|
|
import (
|
||
|
|
"fmt"
|
||
|
|
"server/call"
|
||
|
|
"server/common"
|
||
|
|
"server/db"
|
||
|
|
"server/modules/backend/values"
|
||
|
|
"server/modules/customer/app"
|
||
|
|
"server/natsClient"
|
||
|
|
"server/pb"
|
||
|
|
|
||
|
|
"github.com/gin-gonic/gin"
|
||
|
|
"github.com/liangdas/mqant/log"
|
||
|
|
)
|
||
|
|
|
||
|
|
func EditGameUserStatus(c *gin.Context) {
|
||
|
|
a := app.NewApp(c)
|
||
|
|
defer func() {
|
||
|
|
a.Response()
|
||
|
|
}()
|
||
|
|
req := new(values.EditGameUserStatusReq)
|
||
|
|
if !a.S(req) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if req.Status <= common.AccountStatus || req.Status >= common.AccountStatusAll {
|
||
|
|
a.Code = values.CodeParam
|
||
|
|
a.Msg = "请求状态不合法"
|
||
|
|
return
|
||
|
|
}
|
||
|
|
user, err := call.GetUserInfo(req.UID)
|
||
|
|
if err != nil {
|
||
|
|
log.Error("err:%v", err)
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if user.Status == req.Status {
|
||
|
|
a.Code = values.CodeParam
|
||
|
|
a.Msg = "无内容修改"
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if err = call.UpdateUserXInfo(&common.PlayerDBInfo{Id: req.UID}, map[string]interface{}{"status": req.Status}); err != nil {
|
||
|
|
log.Error("err:%v", err)
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if req.Status == common.AccountStatusLimit { // 封禁账号要通知全服,踢出玩家
|
||
|
|
db.Redis().Delkey(common.GetRedisKeyToken(db.Redis().GetUserToken(req.UID)))
|
||
|
|
db.Redis().Delkey(common.GetRedisKeyUser(req.UID))
|
||
|
|
err = call.Publish(natsClient.TopicInnerOptPlayer, &pb.InnerOptPlayer{UID: uint32(req.UID), Opt: common.OptPlayerTypeKick})
|
||
|
|
if err != nil {
|
||
|
|
log.Error(err.Error())
|
||
|
|
}
|
||
|
|
}
|
||
|
|
a.RecordEdit(values.PowerGUser, fmt.Sprintf("修改玩家%v状态:%v", req.UID, req.Status))
|
||
|
|
}
|