60 lines
2.4 KiB
Go
Raw Normal View History

2025-04-18 17:17:23 +08:00
package server
import (
"admin/apps/game/model/dto"
"admin/internal/context"
2025-04-22 15:46:48 +08:00
"admin/internal/global"
2025-04-18 17:17:23 +08:00
"admin/lib/web"
)
func (srv *Server) Route(engine *web.Engine) {
2025-04-22 15:46:48 +08:00
apiGroup := engine.Group("/api", "")
2025-04-18 17:17:23 +08:00
srv.proRoute(apiGroup)
srv.serverRoute(apiGroup)
2025-04-22 15:46:48 +08:00
{
apiGroup.Get("/project/commandlist", "调用对应游戏服api获取命令列表", global.WebPathPermit_Read, srv.ctl.CommandList)
}
2025-04-18 17:17:23 +08:00
}
2025-04-22 15:46:48 +08:00
func (srv *Server) proRoute(engine *web.RoutesGroup) {
2025-04-18 17:17:23 +08:00
resourceName := "project"
2025-04-22 15:46:48 +08:00
srv.registerResourceRouter(resourceName, engine.Group("/"+resourceName, ""))
2025-04-18 17:17:23 +08:00
}
2025-04-22 15:46:48 +08:00
func (srv *Server) serverRoute(engine *web.RoutesGroup) {
2025-04-18 17:17:23 +08:00
resourceName := "server"
2025-04-22 15:46:48 +08:00
srv.registerResourceRouter(resourceName, engine.Group("/"+resourceName, ""))
}
2025-04-18 17:17:23 +08:00
2025-04-22 15:46:48 +08:00
func (srv *Server) registerResourceRouter(resourceName string, group *web.RoutesGroup) {
group.Get("", "获取列表", global.WebPathPermit_Read, commonHandlerList(srv.ctl, resourceName))
group.Post("", "新增", global.WebPathPermit_Read, commonHandlerPost(srv.ctl, resourceName))
group.Put("", "修改", global.WebPathPermit_Read, commonHandlerPut(srv.ctl, resourceName))
group.Delete("", "删除", global.WebPathPermit_Read, commonHandlerDelete(srv.ctl, resourceName))
2025-04-18 17:17:23 +08:00
}
2025-04-22 15:46:48 +08:00
func commonHandlerList(ctl *controller, resourceName string) func(ctx *context.WebContext, params *dto.CommonListReq, rsp *dto.CommonListRsp) error {
return func(ctx *context.WebContext, params *dto.CommonListReq, rsp *dto.CommonListRsp) error {
return ctl.CommonList(ctx, resourceName, params, rsp)
2025-04-18 17:17:23 +08:00
}
}
2025-04-22 15:46:48 +08:00
func commonHandlerPost(ctl *controller, resourceName string) func(ctx *context.WebContext, params *dto.CommonPostReq, rsp *dto.CommonPostRsp) error {
return func(ctx *context.WebContext, params *dto.CommonPostReq, rsp *dto.CommonPostRsp) error {
return ctl.CommonPost(ctx, resourceName, params, rsp)
2025-04-18 17:17:23 +08:00
}
}
2025-04-22 15:46:48 +08:00
func commonHandlerPut(ctl *controller, resourceName string) func(ctx *context.WebContext, params *dto.CommonPutReq, rsp *dto.CommonPutRsp) error {
return func(ctx *context.WebContext, params *dto.CommonPutReq, rsp *dto.CommonPutRsp) error {
return ctl.CommonPut(ctx, resourceName, params, rsp)
2025-04-18 17:17:23 +08:00
}
}
2025-04-22 15:46:48 +08:00
func commonHandlerDelete(ctl *controller, resourceName string) func(ctx *context.WebContext, params *dto.CommonDeleteReq, rsp *dto.CommonDeleteRsp) error {
return func(ctx *context.WebContext, params *dto.CommonDeleteReq, rsp *dto.CommonDeleteRsp) error {
return ctl.CommonDelete(ctx, resourceName, params, rsp)
2025-04-18 17:17:23 +08:00
}
}