mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-27 03:09:37 +08:00
【更新】更新restful
This commit is contained in:
@@ -8,38 +8,67 @@ package router
|
||||
|
||||
import (
|
||||
"github.com/XM-GO/PandaKit/restfulx"
|
||||
"github.com/gin-gonic/gin"
|
||||
restfulspec "github.com/emicklei/go-restful-openapi/v2"
|
||||
"github.com/emicklei/go-restful/v3"
|
||||
"pandax/apps/system/api"
|
||||
"pandax/apps/system/entity"
|
||||
"pandax/apps/system/services"
|
||||
)
|
||||
|
||||
func InitSysTenantRouter(router *gin.RouterGroup) {
|
||||
func InitSysTenantRouter(container *restful.Container) {
|
||||
s := &api.SysTenantsApi{
|
||||
SysTenantsApp: services.SysTenantModelDao,
|
||||
}
|
||||
routerGroup := router.Group("tenant")
|
||||
ws := new(restful.WebService)
|
||||
ws.Path("/system/tenant").Produces(restful.MIME_JSON)
|
||||
tags := []string{"tenant"}
|
||||
|
||||
routerGroup.GET("list", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("获取SysTenant分页列表").Handle(s.GetSysTenantsList)
|
||||
})
|
||||
ws.Route(ws.GET("/list").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取SysTenant分页列表").Handle(s.GetSysTenantsList)
|
||||
}).
|
||||
Doc("获取SysTenant分页列表").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes([]entity.SysTenants{}).
|
||||
Returns(200, "OK", []entity.SysTenants{}))
|
||||
|
||||
routerGroup.GET("lists", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("获取SysTenant列表").Handle(s.GetSysTenantsAll)
|
||||
})
|
||||
ws.Route(ws.GET("/lists").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取SysTenant列表").Handle(s.GetSysTenantsAll)
|
||||
}).
|
||||
Doc("获取SysTenant列表").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes([]entity.SysTenants{}).
|
||||
Returns(200, "OK", []entity.SysTenants{}))
|
||||
|
||||
routerGroup.GET(":tenantId", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("获取SysTenant信息").Handle(s.GetSysTenants)
|
||||
})
|
||||
ws.Route(ws.GET("/{tenantId}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取SysTenant信息").Handle(s.GetSysTenants)
|
||||
}).
|
||||
Doc("获取SysTenant信息").
|
||||
Param(ws.PathParameter("tenantId", "租户Id").DataType("int").DefaultValue("1")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes(entity.SysTenants{}). // on the response
|
||||
Returns(200, "OK", entity.SysTenants{}).
|
||||
Returns(404, "Not Found", nil))
|
||||
|
||||
routerGroup.POST("", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("添加SysTenant信息").Handle(s.InsertSysTenants)
|
||||
})
|
||||
ws.Route(ws.POST("").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("添加SysTenant信息").Handle(s.InsertSysTenants)
|
||||
}).
|
||||
Doc("添加SysTenant信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.SysTenants{})) // from the request
|
||||
|
||||
routerGroup.PUT("", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("修改SysTenant信息").Handle(s.UpdateSysTenants)
|
||||
})
|
||||
ws.Route(ws.PUT("").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("修改SysTenant信息").Handle(s.UpdateSysTenants)
|
||||
}).
|
||||
Doc("修改SysTenant信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.SysTenants{})) // from the request
|
||||
|
||||
routerGroup.DELETE(":tenantId", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("删除SysTenant信息").Handle(s.DeleteSysTenants)
|
||||
})
|
||||
ws.Route(ws.DELETE("/{tenantId}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("删除SysTenant信息").Handle(s.DeleteSysTenants)
|
||||
}).
|
||||
Doc("删除SysTenant信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Param(ws.PathParameter("tenantId", "多id 1,2,3").DataType("string")))
|
||||
|
||||
container.Add(ws)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user