Files
bl/modules/config/controller/admin/server.go
昔念 026689f3ed ```
feat(cache): 添加复合键缓存操作支持

添加了基于 uint32+string 组合键的缓存操作方法,包括
GetByCompoundKey、SetByCompoundKey、DelByCompoundKey 和
ContainsByCompoundKey 方法,用于处理用户ID和会话ID的组合缓存场景

fix(vscode): 添加 cSpell 配置支持 struc 词汇

refactor(session): 移除过时的会话管理方法

移除了基于单一字符串键的会话管理方法,因为已迁移到使用
复合键的缓存操作方式
```
2026-01-19 18:51:56 +08:00

45 lines
1.0 KiB
Go

package admin
import (
"blazing/cool"
"blazing/modules/config/service"
"context"
"github.com/gogf/gf/v2/frame/g"
)
type ServerController struct {
*cool.Controller
}
func init() {
// 注册路由
cool.RegisterController(&ServerController{
&cool.Controller{
Prefix: "/admin/config/server",
Api: []string{"Add", "Delete", "Update", "Info", "List", "Page"},
Service: service.NewServerService(),
},
})
}
// quit 退出
type QuitSReq struct {
g.Meta `path:"/quit" method:"POST"`
ID uint32 `json:"id" v:"required#请选择要退出的服务器"`
//code 0是非强制,1是强制QuitReq
Code int `json:"code" v:"required#请选择退出类型"`
}
func (this *ServerController) Quit(ctx context.Context, req *QuitSReq) (res *cool.BaseRes, err error) {
res = &cool.BaseRes{}
serv := service.NewServerService().GetServerID(uint16(req.ID))
aa, ok := cool.GetClient(serv.Port)
if ok && aa != nil { //如果已经存在且这个端口已经被存过
aa.QuitSelf(req.Code)
}
return res, nil
}