Files
bl/modules/base/controller/admin/base_sys_user.go
昔念 fa928c9a48 ```
feat(common): 添加GlowFilter的Level字段

添加了GlowFilter结构体中的Level字段,用于表示等级信息,
对应JSON标签为"level,omitempty"

---

fix(utils): 修复concurrent_swiss_map中的panic处理

- 使用goroutine替代线程池来监听通道
- 添加panic恢复机制,当发生panic时记录错误日志
- 确保在异常情况下程序能够
2026-01-25 23:17:46 +08:00

140 lines
3.4 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package admin
import (
"context"
"fmt"
"strings"
"blazing/cool"
"blazing/modules/base/service"
config "blazing/modules/config/service"
dict "blazing/modules/dict/service"
blazing "blazing/modules/player/service"
playerservice "blazing/modules/player/service"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
)
type BaseSysUserController struct {
*cool.Controller
}
func init() {
var base_sys_user_controller = &BaseSysUserController{
&cool.Controller{
Prefix: "/admin/base/sys/user",
Api: []string{"Add", "Delete", "Update", "Info", "List", "Page", "Move"},
Service: service.NewBaseSysUserService(),
},
}
// 注册路由
cool.RegisterController(base_sys_user_controller)
}
type UserMoveReq struct {
g.Meta `path:"/move" method:"GET"`
Authorization string `json:"Authorization" in:"header"`
}
func (c *BaseSysUserController) Move(ctx context.Context, req *UserMoveReq) (res *cool.BaseRes, err error) {
err = service.NewBaseSysUserService().Move(ctx)
res = cool.Ok(nil)
return
}
type SessionReq struct {
g.Meta `path:"/getSession" method:"GET"`
Authorization string `json:"Authorization" in:"header"`
}
func (c *BaseSysUserController) GetSession(ctx context.Context, req *SessionReq) (res *SessionRes, err error) {
t := cool.GetAdmin(ctx)
if t == nil || t.UserId == 0 {
return &SessionRes{}, nil
}
res = &SessionRes{}
t1 := service.NewBaseSysUserService().GetPerson(uint32(t.UserId))
res.UserID = int(t1.ID)
if blazing.NewUserService(uint32(t1.ID)).Info.IsReg() {
res.IsReg = 1
}
res.PetID = dict.NewDictInfoService().GetShiny()
res.Server = config.NewServerService().GetPort(int(t1.Debug))
// share.ShareManager.DeleteSession(t1)
ser := playerservice.NewUserService(uint32(t1.ID))
kickErr := ser.Info.Kick(uint32(t1.ID))
if kickErr != nil {
fmt.Println("踢人失败", kickErr)
}
logininfo := ser.Info.SetLogin()
if logininfo != nil {
res.Session = blazing.NewInfoService(uint32(t.UserId)).Gensession()
cool.CacheManager.Set(context.TODO(), fmt.Sprintf("player:%d", uint32(t1.ID)), logininfo, 0)
}
return
}
type SessionRes struct {
IsReg int `json:"isreg"`
UserID int `json:"userid"`
Session string `json:"session"`
Server gdb.List `json:"server"`
PetID []int `json:"petid"`
}
type RegReq struct {
g.Meta `path:"/regrobot" method:"GET"`
Authorization string `json:"Authorization" in:"header"`
// 玩家昵称,@ArraySerialize注解
Nickname string `json:"nickname" ` // 固定长度16字节
// 机器人人物颜色 rgb@UInt注解
Color uint32 `json:"color" ` // 4字节
}
func (c *BaseSysUserController) Regrobot(ctx context.Context, req *RegReq) (res *RegRes, err error) {
t := cool.GetAdmin(ctx)
res = &RegRes{}
t1 := service.NewBaseSysUserService().GetPerson(uint32(t.UserId))
if blazing.NewUserService(uint32(t1.ID)).Info.IsReg() {
return
}
ser := playerservice.NewUserService(uint32(t1.ID))
kickErr := ser.Info.Kick(uint32(t1.ID))
if kickErr != nil {
fmt.Println("踢人失败", kickErr)
}
logininfo := ser.Info.Reg(cool.Filter.Replace(strings.Trim(req.Nickname, "\x00"), '*'), req.Color)
if logininfo != nil {
res.Session = blazing.NewInfoService(uint32(t.UserId)).Gensession()
cool.CacheManager.Set(context.TODO(), fmt.Sprintf("player:%d", uint32(t1.ID)), logininfo, 0)
}
return
}
type RegRes struct {
Session string `json:"session"`
}