Files
PandaX/resource/template/go/router.template
PandaGoAdmin 412020ae2a [优化]结构
2022-08-03 22:33:27 +08:00

42 lines
1.4 KiB
Plaintext

// ==========================================================================
// 生成日期:{{.CreatedAt}}
// 生成路径: apps/{{.PackageName}}/router/{{.TableName}}.go
// 生成人:{{.FunctionAuthor}}
// ==========================================================================
package router
import (
"github.com/gin-gonic/gin"
"pandax/apps/{{.PackageName}}/api"
"pandax/apps/{{.PackageName}}/services"
"github.com/XM-GO/PandaKit/ginx"
)
func Init{{.ClassName}}Router(router *gin.RouterGroup) {
s := &api.{{.ClassName}}Api{
{{.ClassName}}App: services.{{.ClassName}}ModelDao,
}
routerGroup := router.Group("{{.BusinessName}}")
routerGroup.GET("list", func(c *gin.Context) {
ginx.NewReqCtx(c).WithLog("获取{{.FunctionName}}分页列表").Handle(s.Get{{.ClassName}}List)
})
routerGroup.GET(":{{.PkJsonField}}", func(c *gin.Context) {
ginx.NewReqCtx(c).WithLog("获取{{.FunctionName}}信息").Handle(s.Get{{.ClassName}})
})
routerGroup.POST("", func(c *gin.Context) {
ginx.NewReqCtx(c).WithLog("添加{{.FunctionName}}信息").Handle(s.Insert{{.ClassName}})
})
routerGroup.PUT("", func(c *gin.Context) {
ginx.NewReqCtx(c).WithLog("修改{{.FunctionName}}信息").Handle(s.Update{{.ClassName}})
})
routerGroup.DELETE(":{{.PkJsonField}}", func(c *gin.Context) {
ginx.NewReqCtx(c).WithLog("删除{{.FunctionName}}信息").Handle(s.Delete{{.ClassName}})
})
}