mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-23 02:48:34 +08:00
代码生成
This commit is contained in:
32
apps/develop/router/gen.go
Normal file
32
apps/develop/router/gen.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"pandax/apps/develop/api"
|
||||
"pandax/apps/develop/services"
|
||||
"pandax/base/ctx"
|
||||
)
|
||||
|
||||
func InitGenRouter(router *gin.RouterGroup) {
|
||||
// 登录日志
|
||||
genApi := &api.GenApi{
|
||||
GenTableApp: services.DevGenTableModelDao,
|
||||
}
|
||||
gen := router.Group("gen")
|
||||
|
||||
genViewLog := ctx.NewLogInfo("获取生成代码视图")
|
||||
gen.GET("preview/:tableId", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).WithLog(genViewLog).Handle(genApi.Preview)
|
||||
})
|
||||
|
||||
genCodeLog := ctx.NewLogInfo("生成代码")
|
||||
gen.GET("code/:tableId", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).WithLog(genCodeLog).Handle(genApi.GenCode)
|
||||
})
|
||||
|
||||
genApiLog := ctx.NewLogInfo("生成菜单和api配置")
|
||||
gen.GET("menuAndApi/:tableId", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).WithLog(genApiLog).Handle(genApi.AutoApi)
|
||||
})
|
||||
|
||||
}
|
||||
56
apps/develop/router/table.go
Normal file
56
apps/develop/router/table.go
Normal file
@@ -0,0 +1,56 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"pandax/apps/develop/api"
|
||||
"pandax/apps/develop/services"
|
||||
"pandax/base/ctx"
|
||||
)
|
||||
|
||||
func InitGenTableRouter(router *gin.RouterGroup) {
|
||||
// 登录日志
|
||||
genApi := &api.GenTableApi{
|
||||
GenTableApp: services.DevGenTableModelDao,
|
||||
}
|
||||
gen := router.Group("table")
|
||||
|
||||
genDbListLog := ctx.NewLogInfo("获取数据库列表")
|
||||
gen.GET("/db/list", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).WithLog(genDbListLog).Handle(genApi.GetDBTableList)
|
||||
})
|
||||
|
||||
genListLog := ctx.NewLogInfo("获取表列表")
|
||||
gen.GET("list", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).WithLog(genListLog).Handle(genApi.GetTablePage)
|
||||
})
|
||||
|
||||
genInfoNameLog := ctx.NewLogInfo("获取表信息By tableName")
|
||||
gen.GET("/info/tableName", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).WithLog(genInfoNameLog).Handle(genApi.GetTableInfoByName)
|
||||
})
|
||||
|
||||
genInfoLog := ctx.NewLogInfo("获取表信息")
|
||||
gen.GET("info/:tableId", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).WithLog(genInfoLog).Handle(genApi.GetTableInfo)
|
||||
})
|
||||
|
||||
genTreeLog := ctx.NewLogInfo("获取表树")
|
||||
gen.GET("tableTree", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).WithLog(genTreeLog).Handle(genApi.GetTableTree)
|
||||
})
|
||||
|
||||
genInsterLog := ctx.NewLogInfo("新增表")
|
||||
gen.POST("", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).WithLog(genInsterLog).Handle(genApi.Insert)
|
||||
})
|
||||
|
||||
genUpdateLog := ctx.NewLogInfo("修改表")
|
||||
gen.PUT("", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).WithLog(genUpdateLog).Handle(genApi.Update)
|
||||
})
|
||||
|
||||
genDeleteLog := ctx.NewLogInfo("删除表")
|
||||
gen.DELETE(":tableId", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).WithLog(genDeleteLog).Handle(genApi.Delete)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user