mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-23 10:58:35 +08:00
【更新】更新
This commit is contained in:
@@ -3,7 +3,6 @@ package api
|
||||
import (
|
||||
"pandax/apps/develop/gen"
|
||||
"pandax/apps/develop/services"
|
||||
"pandax/base/ctx"
|
||||
"pandax/base/ginx"
|
||||
)
|
||||
|
||||
@@ -18,7 +17,7 @@ type GenApi struct {
|
||||
// @Success 200 {string} string "{"code": 200, "data": [...]}"
|
||||
// @Router /develop/code/gen/preview/{tableId} [get]
|
||||
// @Security X-TOKEN
|
||||
func (e *GenApi) Preview(rc *ctx.ReqCtx) {
|
||||
func (e *GenApi) Preview(rc *ginx.ReqCtx) {
|
||||
tableId := ginx.PathParamInt(rc.GinCtx, "tableId")
|
||||
rc.ResData = gen.Preview(int64(tableId))
|
||||
}
|
||||
@@ -30,7 +29,7 @@ func (e *GenApi) Preview(rc *ctx.ReqCtx) {
|
||||
// @Success 200 {string} string "{"code": 200, "data": [...]}"
|
||||
// @Router /develop/code/gen/code/{tableId} [get]
|
||||
// @Security X-TOKEN
|
||||
func (e *GenApi) GenCode(rc *ctx.ReqCtx) {
|
||||
func (e *GenApi) GenCode(rc *ginx.ReqCtx) {
|
||||
tableId := ginx.PathParamInt(rc.GinCtx, "tableId")
|
||||
gen.GenCode(int64(tableId))
|
||||
}
|
||||
@@ -42,7 +41,7 @@ func (e *GenApi) GenCode(rc *ctx.ReqCtx) {
|
||||
// @Success 200 {string} string "{"code": 200, "data": [...]}"
|
||||
// @Router /develop/code/gen/configure/{tableId} [get]
|
||||
// @Security X-TOKEN
|
||||
func (e *GenApi) GenConfigure(rc *ctx.ReqCtx) {
|
||||
func (e *GenApi) GenConfigure(rc *ginx.ReqCtx) {
|
||||
tableId := ginx.PathParamInt(rc.GinCtx, "tableId")
|
||||
menuId := ginx.QueryInt(rc.GinCtx, "menuId", 0)
|
||||
gen.GenConfigure(tableId, menuId)
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"pandax/apps/develop/entity"
|
||||
"pandax/apps/develop/gen"
|
||||
"pandax/apps/develop/services"
|
||||
"pandax/base/ctx"
|
||||
"pandax/base/ginx"
|
||||
"pandax/base/utils"
|
||||
"strings"
|
||||
@@ -23,7 +22,7 @@ type GenTableApi struct {
|
||||
// @Param pageNum query int false "pageNum / 页码"
|
||||
// @Success 200 {string} string "{"code": 200, "data": [...]}"
|
||||
// @Router /develop/code/table/db/list [get]
|
||||
func (g *GenTableApi) GetDBTableList(rc *ctx.ReqCtx) {
|
||||
func (g *GenTableApi) GetDBTableList(rc *ginx.ReqCtx) {
|
||||
pageNum := ginx.QueryInt(rc.GinCtx, "pageNum", 1)
|
||||
pageSize := ginx.QueryInt(rc.GinCtx, "pageSize", 10)
|
||||
tableName := rc.GinCtx.Query("tableName")
|
||||
@@ -45,7 +44,7 @@ func (g *GenTableApi) GetDBTableList(rc *ctx.ReqCtx) {
|
||||
// @Param pageIndex query int false "pageIndex / 页码"
|
||||
// @Success 200 {string} string "{"code": 200, "data": [...]}"
|
||||
// @Router /develop/code/table/list [get]
|
||||
func (g *GenTableApi) GetTablePage(rc *ctx.ReqCtx) {
|
||||
func (g *GenTableApi) GetTablePage(rc *ginx.ReqCtx) {
|
||||
pageNum := ginx.QueryInt(rc.GinCtx, "pageNum", 1)
|
||||
pageSize := ginx.QueryInt(rc.GinCtx, "pageSize", 10)
|
||||
tableName := rc.GinCtx.Query("tableName")
|
||||
@@ -66,7 +65,7 @@ func (g *GenTableApi) GetTablePage(rc *ctx.ReqCtx) {
|
||||
// @Success 200 {string} string "{"code": 200, "data": [...]}"
|
||||
// @Router /develop/code/table/info/{tableId} [get]
|
||||
// @Security Bearer
|
||||
func (g *GenTableApi) GetTableInfo(rc *ctx.ReqCtx) {
|
||||
func (g *GenTableApi) GetTableInfo(rc *ginx.ReqCtx) {
|
||||
tableId := ginx.PathParamInt(rc.GinCtx, "tableId")
|
||||
result := g.GenTableApp.FindOne(entity.DevGenTable{TableId: int64(tableId)}, true)
|
||||
mp := make(map[string]any)
|
||||
@@ -82,7 +81,7 @@ func (g *GenTableApi) GetTableInfo(rc *ctx.ReqCtx) {
|
||||
// @Success 200 {string} string "{"code": 200, "data": [...]}"
|
||||
// @Router /develop/code/table/info/tableName [get]
|
||||
// @Security X-TOKEN
|
||||
func (g *GenTableApi) GetTableInfoByName(rc *ctx.ReqCtx) {
|
||||
func (g *GenTableApi) GetTableInfoByName(rc *ginx.ReqCtx) {
|
||||
tableName := rc.GinCtx.Query("tableName")
|
||||
result := g.GenTableApp.FindOne(entity.DevGenTable{TableName: tableName}, true)
|
||||
mp := make(map[string]any)
|
||||
@@ -97,7 +96,7 @@ func (g *GenTableApi) GetTableInfoByName(rc *ctx.ReqCtx) {
|
||||
// @Success 200 {string} string "{"code": 200, "data": [...]}"
|
||||
// @Router /develop/code/table/tableTree [get]
|
||||
// @Security X-TOKEN
|
||||
func (g *GenTableApi) GetTableTree(rc *ctx.ReqCtx) {
|
||||
func (g *GenTableApi) GetTableTree(rc *ginx.ReqCtx) {
|
||||
rc.ResData = g.GenTableApp.FindTree(entity.DevGenTable{})
|
||||
}
|
||||
|
||||
@@ -111,7 +110,7 @@ func (g *GenTableApi) GetTableTree(rc *ctx.ReqCtx) {
|
||||
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
|
||||
// @Router /develop/code/table [post]
|
||||
// @Security Bearer
|
||||
func (g *GenTableApi) Insert(rc *ctx.ReqCtx) {
|
||||
func (g *GenTableApi) Insert(rc *ginx.ReqCtx) {
|
||||
tablesList := strings.Split(rc.GinCtx.Query("tables"), ",")
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
@@ -137,7 +136,7 @@ func (g *GenTableApi) Insert(rc *ctx.ReqCtx) {
|
||||
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
|
||||
// @Router /develop/code/table [put]
|
||||
// @Security Bearer
|
||||
func (g *GenTableApi) Update(rc *ctx.ReqCtx) {
|
||||
func (g *GenTableApi) Update(rc *ginx.ReqCtx) {
|
||||
var data entity.DevGenTable
|
||||
ginx.BindJsonAndValid(rc.GinCtx, &data)
|
||||
g.GenTableApp.Update(data)
|
||||
@@ -151,7 +150,7 @@ func (g *GenTableApi) Update(rc *ctx.ReqCtx) {
|
||||
// @Success 200 {string} string "{"code": 200, "message": "删除成功"}"
|
||||
// @Success 200 {string} string "{"code": -1, "message": "删除失败"}"
|
||||
// @Router /develop/code/table/{tableId} [delete]
|
||||
func (g *GenTableApi) Delete(rc *ctx.ReqCtx) {
|
||||
func (g *GenTableApi) Delete(rc *ginx.ReqCtx) {
|
||||
tableIds := rc.GinCtx.Param("tableId")
|
||||
group := utils.IdsStrToIdsIntGroup(tableIds)
|
||||
g.GenTableApp.Delete(group)
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"pandax/apps/develop/api"
|
||||
"pandax/apps/develop/services"
|
||||
"pandax/base/ctx"
|
||||
"pandax/base/ginx"
|
||||
)
|
||||
|
||||
func InitGenRouter(router *gin.RouterGroup) {
|
||||
@@ -14,18 +14,15 @@ func InitGenRouter(router *gin.RouterGroup) {
|
||||
}
|
||||
gen := router.Group("gen")
|
||||
|
||||
genViewLog := ctx.NewLogInfo("获取生成代码视图")
|
||||
gen.GET("preview/:tableId", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).WithLog(genViewLog).Handle(genApi.Preview)
|
||||
ginx.NewReqCtx(c).WithLog("获取生成代码视图").Handle(genApi.Preview)
|
||||
})
|
||||
|
||||
genCodeLog := ctx.NewLogInfo("生成代码")
|
||||
gen.GET("code/:tableId", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).WithLog(genCodeLog).Handle(genApi.GenCode)
|
||||
ginx.NewReqCtx(c).WithLog("生成代码").Handle(genApi.GenCode)
|
||||
})
|
||||
|
||||
genConfigureLog := ctx.NewLogInfo("生成配置")
|
||||
gen.GET("configure/:tableId", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).WithLog(genConfigureLog).Handle(genApi.GenConfigure)
|
||||
ginx.NewReqCtx(c).WithLog("生成配置").Handle(genApi.GenConfigure)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"pandax/apps/develop/api"
|
||||
"pandax/apps/develop/services"
|
||||
"pandax/base/ctx"
|
||||
"pandax/base/ginx"
|
||||
)
|
||||
|
||||
func InitGenTableRouter(router *gin.RouterGroup) {
|
||||
@@ -14,43 +14,35 @@ func InitGenTableRouter(router *gin.RouterGroup) {
|
||||
}
|
||||
gen := router.Group("table")
|
||||
|
||||
genDbListLog := ctx.NewLogInfo("获取数据库列表")
|
||||
gen.GET("/db/list", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).WithLog(genDbListLog).Handle(genApi.GetDBTableList)
|
||||
ginx.NewReqCtx(c).WithLog("获取数据库列表").Handle(genApi.GetDBTableList)
|
||||
})
|
||||
|
||||
genListLog := ctx.NewLogInfo("获取表列表")
|
||||
gen.GET("list", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).WithLog(genListLog).Handle(genApi.GetTablePage)
|
||||
ginx.NewReqCtx(c).WithLog("获取表列表").Handle(genApi.GetTablePage)
|
||||
})
|
||||
|
||||
genInfoNameLog := ctx.NewLogInfo("获取表信息By tableName")
|
||||
gen.GET("/info/tableName", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).WithLog(genInfoNameLog).Handle(genApi.GetTableInfoByName)
|
||||
ginx.NewReqCtx(c).WithLog("获取表信息By tableName").Handle(genApi.GetTableInfoByName)
|
||||
})
|
||||
|
||||
genInfoLog := ctx.NewLogInfo("获取表信息")
|
||||
gen.GET("info/:tableId", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).WithLog(genInfoLog).Handle(genApi.GetTableInfo)
|
||||
ginx.NewReqCtx(c).WithLog("获取表信息").Handle(genApi.GetTableInfo)
|
||||
})
|
||||
|
||||
genTreeLog := ctx.NewLogInfo("获取表树")
|
||||
gen.GET("tableTree", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).WithLog(genTreeLog).Handle(genApi.GetTableTree)
|
||||
ginx.NewReqCtx(c).WithLog("获取表树").Handle(genApi.GetTableTree)
|
||||
})
|
||||
|
||||
genInsterLog := ctx.NewLogInfo("新增表")
|
||||
gen.POST("", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).WithLog(genInsterLog).Handle(genApi.Insert)
|
||||
ginx.NewReqCtx(c).WithLog("新增表").Handle(genApi.Insert)
|
||||
})
|
||||
|
||||
genUpdateLog := ctx.NewLogInfo("修改表")
|
||||
gen.PUT("", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).WithLog(genUpdateLog).Handle(genApi.Update)
|
||||
ginx.NewReqCtx(c).WithLog("修改表").Handle(genApi.Update)
|
||||
})
|
||||
|
||||
genDeleteLog := ctx.NewLogInfo("删除表")
|
||||
gen.DELETE(":tableId", func(c *gin.Context) {
|
||||
ctx.NewReqCtxWithGin(c).WithLog(genDeleteLog).Handle(genApi.Delete)
|
||||
ginx.NewReqCtx(c).WithLog("删除表").Handle(genApi.Delete)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user