package server import ( "admin/apps/game/model/dto" "admin/internal/context" "admin/internal/global" "admin/lib/web" ) func (srv *Server) Route(engine *web.Engine) { apiGroup := engine.Group("/api", "") srv.proRoute(apiGroup) srv.serverRoute(apiGroup) { apiGroup.Get("/project/commandlist", "调用对应游戏服api获取命令列表", global.WebPathPermit_Read, srv.ctl.CommandList) } } func (srv *Server) proRoute(engine *web.RoutesGroup) { resourceName := "project" srv.registerResourceRouter(resourceName, engine.Group("/"+resourceName, "")) } func (srv *Server) serverRoute(engine *web.RoutesGroup) { resourceName := "server" srv.registerResourceRouter(resourceName, engine.Group("/"+resourceName, "")) } 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)) } 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) } } 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) } } 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) } } 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) } }