【更新】更新restful

This commit is contained in:
PandaGoAdmin
2022-08-03 16:00:32 +08:00
parent 2cb23c0ecf
commit 6945277fdb
48 changed files with 1234 additions and 836 deletions

View File

@@ -18,7 +18,7 @@ type GenApi struct {
// @Router /develop/code/gen/preview/{tableId} [get]
// @Security X-TOKEN
func (e *GenApi) Preview(rc *restfulx.ReqCtx) {
tableId := restfulx.PathParamInt(rc.GinCtx, "tableId")
tableId := restfulx.PathParamInt(rc, "tableId")
rc.ResData = gen.Preview(int64(tableId))
}
@@ -30,7 +30,7 @@ func (e *GenApi) Preview(rc *restfulx.ReqCtx) {
// @Router /develop/code/gen/code/{tableId} [get]
// @Security X-TOKEN
func (e *GenApi) GenCode(rc *restfulx.ReqCtx) {
tableId := restfulx.PathParamInt(rc.GinCtx, "tableId")
tableId := restfulx.PathParamInt(rc, "tableId")
gen.GenCode(int64(tableId))
}
@@ -42,7 +42,7 @@ func (e *GenApi) GenCode(rc *restfulx.ReqCtx) {
// @Router /develop/code/gen/configure/{tableId} [get]
// @Security X-TOKEN
func (e *GenApi) GenConfigure(rc *restfulx.ReqCtx) {
tableId := restfulx.PathParamInt(rc.GinCtx, "tableId")
menuId := restfulx.QueryInt(rc.GinCtx, "menuId", 0)
tableId := restfulx.PathParamInt(rc, "tableId")
menuId := restfulx.QueryInt(rc, "menuId", 0)
gen.GenConfigure(tableId, menuId)
}

View File

@@ -23,9 +23,10 @@ type GenTableApi struct {
// @Success 200 {string} string "{"code": 200, "data": [...]}"
// @Router /develop/code/table/db/list [get]
func (g *GenTableApi) GetDBTableList(rc *restfulx.ReqCtx) {
pageNum := restfulx.QueryInt(rc.GinCtx, "pageNum", 1)
pageSize := restfulx.QueryInt(rc.GinCtx, "pageSize", 10)
tableName := rc.GinCtx.Query("tableName")
pageNum := restfulx.QueryInt(rc, "pageNum", 1)
pageSize := restfulx.QueryInt(rc, "pageSize", 10)
tableName := restfulx.QueryParam(rc, "tableName")
list, total := g.GenTableApp.FindDbTablesListPage(pageNum, pageSize, entity.DBTables{TableName: tableName})
rc.ResData = map[string]any{
"data": list,
@@ -45,10 +46,11 @@ func (g *GenTableApi) GetDBTableList(rc *restfulx.ReqCtx) {
// @Success 200 {string} string "{"code": 200, "data": [...]}"
// @Router /develop/code/table/list [get]
func (g *GenTableApi) GetTablePage(rc *restfulx.ReqCtx) {
pageNum := restfulx.QueryInt(rc.GinCtx, "pageNum", 1)
pageSize := restfulx.QueryInt(rc.GinCtx, "pageSize", 10)
tableName := rc.GinCtx.Query("tableName")
tableComment := rc.GinCtx.Query("tableComment")
pageNum := restfulx.QueryInt(rc, "pageNum", 1)
pageSize := restfulx.QueryInt(rc, "pageSize", 10)
tableName := restfulx.QueryParam(rc, "tableName")
tableComment := restfulx.QueryParam(rc, "tableComment")
list, total := g.GenTableApp.FindListPage(pageNum, pageSize, entity.DevGenTable{TableName: tableName, TableComment: tableComment})
rc.ResData = map[string]any{
"data": list,
@@ -66,7 +68,7 @@ func (g *GenTableApi) GetTablePage(rc *restfulx.ReqCtx) {
// @Router /develop/code/table/info/{tableId} [get]
// @Security Bearer
func (g *GenTableApi) GetTableInfo(rc *restfulx.ReqCtx) {
tableId := restfulx.PathParamInt(rc.GinCtx, "tableId")
tableId := restfulx.PathParamInt(rc, "tableId")
result := g.GenTableApp.FindOne(entity.DevGenTable{TableId: int64(tableId)}, true)
mp := make(map[string]any)
mp["list"] = result.Columns
@@ -82,7 +84,7 @@ func (g *GenTableApi) GetTableInfo(rc *restfulx.ReqCtx) {
// @Router /develop/code/table/info/tableName [get]
// @Security X-TOKEN
func (g *GenTableApi) GetTableInfoByName(rc *restfulx.ReqCtx) {
tableName := rc.GinCtx.Query("tableName")
tableName := restfulx.QueryParam(rc, "tableName")
result := g.GenTableApp.FindOne(entity.DevGenTable{TableName: tableName}, true)
mp := make(map[string]any)
mp["list"] = result.Columns
@@ -111,7 +113,7 @@ func (g *GenTableApi) GetTableTree(rc *restfulx.ReqCtx) {
// @Router /develop/code/table [post]
// @Security Bearer
func (g *GenTableApi) Insert(rc *restfulx.ReqCtx) {
tablesList := strings.Split(rc.GinCtx.Query("tables"), ",")
tablesList := strings.Split(restfulx.QueryParam(rc, "tables"), ",")
wg := sync.WaitGroup{}
for i := 0; i < len(tablesList); i++ {
@@ -138,7 +140,7 @@ func (g *GenTableApi) Insert(rc *restfulx.ReqCtx) {
// @Security Bearer
func (g *GenTableApi) Update(rc *restfulx.ReqCtx) {
var data entity.DevGenTable
restfulx.BindJsonAndValid(rc.GinCtx, &data)
restfulx.BindQuery(rc, &data)
g.GenTableApp.Update(data)
}
@@ -151,7 +153,7 @@ func (g *GenTableApi) Update(rc *restfulx.ReqCtx) {
// @Success 200 {string} string "{"code": -1, "message": "删除失败"}"
// @Router /develop/code/table/{tableId} [delete]
func (g *GenTableApi) Delete(rc *restfulx.ReqCtx) {
tableIds := rc.GinCtx.Param("tableId")
tableIds := restfulx.PathParam(rc, "tableId")
group := utils.IdsStrToIdsIntGroup(tableIds)
g.GenTableApp.Delete(group)
}

View File

@@ -1,28 +1,25 @@
package router
import (
"github.com/XM-GO/PandaKit/restfulx"
"github.com/gin-gonic/gin"
"pandax/apps/develop/api"
"pandax/apps/develop/services"
"github.com/emicklei/go-restful/v3"
)
func InitGenRouter(router *gin.RouterGroup) {
func InitGenRouter(container *restful.Container) {
// 登录日志
genApi := &api.GenApi{
GenTableApp: services.DevGenTableModelDao,
}
gen := router.Group("gen")
/* genApi := &api.GenApi{
GenTableApp: services.DevGenTableModelDao,
}
gen := router.Group("gen")
gen.GET("preview/:tableId", func(c *gin.Context) {
restfulx.NewReqCtx(c).WithLog("获取生成代码视图").Handle(genApi.Preview)
})
gen.GET("preview/:tableId", func(c *gin.Context) {
restfulx.NewReqCtx(c).WithLog("获取生成代码视图").Handle(genApi.Preview)
})
gen.GET("code/:tableId", func(c *gin.Context) {
restfulx.NewReqCtx(c).WithLog("生成代码").Handle(genApi.GenCode)
})
gen.GET("code/:tableId", func(c *gin.Context) {
restfulx.NewReqCtx(c).WithLog("生成代码").Handle(genApi.GenCode)
})
gen.GET("configure/:tableId", func(c *gin.Context) {
restfulx.NewReqCtx(c).WithLog("生成配置").Handle(genApi.GenConfigure)
})
gen.GET("configure/:tableId", func(c *gin.Context) {
restfulx.NewReqCtx(c).WithLog("生成配置").Handle(genApi.GenConfigure)
})*/
}

View File

@@ -1,15 +1,12 @@
package router
import (
"github.com/XM-GO/PandaKit/restfulx"
"github.com/gin-gonic/gin"
"pandax/apps/develop/api"
"pandax/apps/develop/services"
"github.com/emicklei/go-restful/v3"
)
func InitGenTableRouter(router *gin.RouterGroup) {
func InitGenTableRouter(container *restful.Container) {
// 登录日志
genApi := &api.GenTableApi{
/*genApi := &api.GenTableApi{
GenTableApp: services.DevGenTableModelDao,
}
gen := router.Group("table")
@@ -44,5 +41,5 @@ func InitGenTableRouter(router *gin.RouterGroup) {
gen.DELETE(":tableId", func(c *gin.Context) {
restfulx.NewReqCtx(c).WithLog("删除表").Handle(genApi.Delete)
})
})*/
}