Files
bl/modules/config/controller/admin/server.go

45 lines
1.0 KiB
Go
Raw Normal View History

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
}