2026-01-01 19:57:39 +08:00
|
|
|
package admin
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"blazing/cool"
|
|
|
|
|
"blazing/modules/config/service"
|
2026-01-19 18:51:56 +08:00
|
|
|
"context"
|
|
|
|
|
|
|
|
|
|
"github.com/gogf/gf/v2/frame/g"
|
2026-01-01 19:57:39 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
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(),
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
}
|
2026-01-19 18:51:56 +08:00
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
}
|