mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-05-04 11:01:26 +08:00
【更新】更新restful
This commit is contained in:
@@ -1,43 +1,78 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/XM-GO/PandaKit/casbin"
|
||||
"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 InitApiRouter(router *gin.RouterGroup) {
|
||||
func InitApiRouter(container *restful.Container) {
|
||||
s := &api.SystemApiApi{
|
||||
ApiApp: services.SysApiModelDao,
|
||||
}
|
||||
api := router.Group("api")
|
||||
|
||||
api.GET("list", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("获取api分页列表").Handle(s.GetApiList)
|
||||
})
|
||||
ws := new(restful.WebService)
|
||||
ws.Path("/system/api").Produces(restful.MIME_JSON)
|
||||
tags := []string{"api"}
|
||||
|
||||
api.GET("all", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("获取所有api").Handle(s.GetAllApis)
|
||||
})
|
||||
ws.Route(ws.GET("/list").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取api分页列表").Handle(s.GetApiList)
|
||||
}).
|
||||
Doc("获取api分页列表").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes([]entity.SysApi{}).
|
||||
Returns(200, "OK", []entity.SysApi{}))
|
||||
|
||||
api.GET("getPolicyPathByRoleId", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("获取角色拥有的api权限").Handle(s.GetPolicyPathByRoleId)
|
||||
})
|
||||
ws.Route(ws.GET("/all").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取所有api").Handle(s.GetAllApis)
|
||||
}).
|
||||
Doc("获取所有api").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes([]entity.SysApi{}).
|
||||
Returns(200, "OK", []entity.SysApi{}))
|
||||
|
||||
api.GET(":id", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("获取api信息").Handle(s.GetApiById)
|
||||
})
|
||||
ws.Route(ws.GET("/getPolicyPathByRoleId").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取角色拥有的api权限").Handle(s.GetPolicyPathByRoleId)
|
||||
}).
|
||||
Doc("获取角色拥有的api权限").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes([]casbin.CasbinRule{}).
|
||||
Returns(200, "OK", []casbin.CasbinRule{}))
|
||||
|
||||
api.POST("", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("添加api信息").Handle(s.CreateApi)
|
||||
})
|
||||
ws.Route(ws.GET("/{id}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取api信息").Handle(s.GetApiById)
|
||||
}).
|
||||
Doc("获取api信息").
|
||||
Param(ws.PathParameter("id", "Id").DataType("int").DefaultValue("1")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes(entity.SysApi{}). // on the response
|
||||
Returns(200, "OK", entity.SysApi{}).
|
||||
Returns(404, "Not Found", nil))
|
||||
|
||||
api.PUT("", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("修改api信息").Handle(s.UpdateApi)
|
||||
})
|
||||
ws.Route(ws.POST("").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("添加api信息").Handle(s.CreateApi)
|
||||
}).
|
||||
Doc("添加api信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.SysApi{}))
|
||||
|
||||
api.DELETE(":id", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("删除api信息").Handle(s.DeleteApi)
|
||||
})
|
||||
ws.Route(ws.PUT("").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("修改api信息").Handle(s.UpdateApi)
|
||||
}).
|
||||
Doc("修改api信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.SysApi{})) // from the request
|
||||
|
||||
ws.Route(ws.DELETE("/{id}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("删除api信息").Handle(s.DeleteApi)
|
||||
}).
|
||||
Doc("删除api信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Param(ws.PathParameter("id", "id").DataType("int")))
|
||||
|
||||
container.Add(ws)
|
||||
}
|
||||
|
||||
@@ -2,38 +2,69 @@ 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 InitConfigRouter(router *gin.RouterGroup) {
|
||||
func InitConfigRouter(container *restful.Container) {
|
||||
s := &api.ConfigApi{
|
||||
ConfigApp: services.SysSysConfigModelDao,
|
||||
}
|
||||
config := router.Group("config")
|
||||
|
||||
config.GET("list", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("获取配置分页列表").Handle(s.GetConfigList)
|
||||
})
|
||||
ws := new(restful.WebService)
|
||||
ws.Path("/system/config").Produces(restful.MIME_JSON)
|
||||
tags := []string{"config"}
|
||||
|
||||
config.GET("configKey", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("获取配置列表通过ConfigKey").Handle(s.GetConfigListByKey)
|
||||
})
|
||||
ws.Route(ws.GET("/list").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取配置分页列表").Handle(s.GetConfigList)
|
||||
}).
|
||||
Doc("获取配置分页列表").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes([]entity.SysConfig{}).
|
||||
Returns(200, "OK", []entity.SysConfig{}))
|
||||
|
||||
config.GET(":configId", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("获取配置信息").Handle(s.GetConfig)
|
||||
})
|
||||
ws.Route(ws.GET("/configKey").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取配置列表通过ConfigKey").Handle(s.GetConfigListByKey)
|
||||
}).
|
||||
Doc("获取配置列表通过ConfigKey").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes([]entity.SysConfig{}).
|
||||
Returns(200, "OK", []entity.SysConfig{}))
|
||||
|
||||
config.POST("", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("添加配置信息").Handle(s.InsertConfig)
|
||||
})
|
||||
ws.Route(ws.GET("/{configId}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取配置信息").Handle(s.GetConfig)
|
||||
}).
|
||||
Doc("获取配置信息").
|
||||
Param(ws.PathParameter("configId", "configId").DataType("int").DefaultValue("1")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes(entity.SysConfig{}). // on the response
|
||||
Returns(200, "OK", entity.SysConfig{}).
|
||||
Returns(404, "Not Found", nil))
|
||||
|
||||
config.PUT("", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("修改配置信息").Handle(s.UpdateConfig)
|
||||
})
|
||||
ws.Route(ws.POST("").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("添加配置信息").Handle(s.InsertConfig)
|
||||
}).
|
||||
Doc("添加配置信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.SysConfig{})) // from the request
|
||||
|
||||
ws.Route(ws.PUT("").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("修改配置信息").Handle(s.UpdateConfig)
|
||||
}).
|
||||
Doc("修改配置信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.SysConfig{})) // from the request
|
||||
|
||||
ws.Route(ws.DELETE("/{configId}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("删除配置信息").Handle(s.DeleteConfig)
|
||||
}).
|
||||
Doc("删除配置信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Param(ws.PathParameter("configId", "多id 1,2,3").DataType("string")))
|
||||
|
||||
container.Add(ws)
|
||||
|
||||
config.DELETE(":configId", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("删除配置信息").Handle(s.DeleteConfig)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -2,44 +2,80 @@ 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 InitDeptRouter(router *gin.RouterGroup) {
|
||||
r := &api.DeptApi{
|
||||
func InitDeptRouter(container *restful.Container) {
|
||||
s := &api.DeptApi{
|
||||
DeptApp: services.SysDeptModelDao,
|
||||
RoleApp: services.SysRoleModelDao,
|
||||
UserApp: services.SysUserModelDao,
|
||||
}
|
||||
dept := router.Group("dept")
|
||||
|
||||
dept.GET("roleDeptTreeSelect/:roleId", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("获取角色部门树").Handle(r.GetDeptTreeRoleSelect)
|
||||
})
|
||||
ws := new(restful.WebService)
|
||||
ws.Path("/system/dept").Produces(restful.MIME_JSON)
|
||||
tags := []string{"dept"}
|
||||
|
||||
dept.GET("deptTree", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("获取所有部门树").Handle(r.GetDeptTree)
|
||||
})
|
||||
ws.Route(ws.GET("/roleDeptTreeSelect/{roleId}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取角色部门树").Handle(s.GetDeptTreeRoleSelect)
|
||||
}).
|
||||
Doc("获取角色部门树").
|
||||
Param(ws.PathParameter("roleId", "角色Id").DataType("int").DefaultValue("1")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes(map[string]any{}). // on the response
|
||||
Returns(404, "Not Found", nil))
|
||||
|
||||
dept.GET("list", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("获取部门列表").Handle(r.GetDeptList)
|
||||
})
|
||||
ws.Route(ws.GET("/deptTree").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取所有部门树").Handle(s.GetDeptTree)
|
||||
}).
|
||||
Doc("获取所有部门树").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes([]entity.SysDept{}). // on the response
|
||||
Returns(404, "Not Found", nil))
|
||||
|
||||
dept.GET(":deptId", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("获取部门信息").Handle(r.GetDept)
|
||||
})
|
||||
ws.Route(ws.GET("/list").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取部门列表").Handle(s.GetDeptList)
|
||||
}).
|
||||
Doc("获取部门列表").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes([]entity.SysDept{}).
|
||||
Returns(200, "OK", []entity.SysDept{}))
|
||||
|
||||
dept.POST("", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("添加部门信息").Handle(r.InsertDept)
|
||||
})
|
||||
ws.Route(ws.GET("/{deptId}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取部门信息").Handle(s.GetDept)
|
||||
}).
|
||||
Doc("获取部门信息").
|
||||
Param(ws.PathParameter("deptId", "部门Id").DataType("int").DefaultValue("1")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes(entity.SysDept{}). // on the response
|
||||
Returns(200, "OK", entity.SysDept{}).
|
||||
Returns(404, "Not Found", nil))
|
||||
|
||||
dept.PUT("", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("修改部门信息").Handle(r.UpdateDept)
|
||||
})
|
||||
ws.Route(ws.POST("").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("添加部门信息").Handle(s.InsertDept)
|
||||
}).
|
||||
Doc("添加部门信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.SysDept{})) // from the request
|
||||
|
||||
ws.Route(ws.PUT("").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("修改部门信息").Handle(s.UpdateDept)
|
||||
}).
|
||||
Doc("修改部门信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.SysDept{})) // from the request
|
||||
|
||||
ws.Route(ws.DELETE("/{deptId}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("删除部门信息").Handle(s.DeleteDept)
|
||||
}).
|
||||
Doc("删除部门信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Param(ws.PathParameter("deptId", "多id 1,2,3").DataType("int")))
|
||||
|
||||
container.Add(ws)
|
||||
|
||||
dept.DELETE(":deptId", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("删除部门信息").Handle(r.DeleteDept)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -2,64 +2,107 @@ 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 InitDictRouter(router *gin.RouterGroup) {
|
||||
func InitDictRouter(container *restful.Container) {
|
||||
s := &api.DictApi{
|
||||
DictType: services.SysDictTypeModelDao,
|
||||
DictData: services.SysDictDataModelDao,
|
||||
}
|
||||
dict := router.Group("dict")
|
||||
ws := new(restful.WebService)
|
||||
ws.Path("/system/dict").Produces(restful.MIME_JSON)
|
||||
tags := []string{"dict"}
|
||||
|
||||
dict.GET("type/list", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("获取字典类型分页列表").Handle(s.GetDictTypeList)
|
||||
})
|
||||
ws.Route(ws.GET("/type/list").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取字典类型分页列表").Handle(s.GetDictTypeList)
|
||||
}).
|
||||
Doc("获取字典类型分页列表").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Returns(200, "OK", []entity.SysDictType{}))
|
||||
|
||||
dict.GET("type/:dictId", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("获取字典类型信息").Handle(s.GetDictType)
|
||||
})
|
||||
ws.Route(ws.GET("/type/{dictId}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取字典类型信息").Handle(s.GetDictType)
|
||||
}).
|
||||
Doc("获取字典类型信息").
|
||||
Param(ws.PathParameter("dictId", "Id").DataType("int").DefaultValue("1")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Returns(200, "OK", []entity.SysDictType{}))
|
||||
|
||||
dict.POST("type", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("添加字典类型信息").Handle(s.InsertDictType)
|
||||
})
|
||||
ws.Route(ws.POST("/type").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("添加字典类型信息").Handle(s.InsertDictType)
|
||||
}).
|
||||
Doc("添加字典类型信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.SysDictType{}))
|
||||
|
||||
dict.PUT("type", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("修改字典类型信息").Handle(s.UpdateDictType)
|
||||
})
|
||||
ws.Route(ws.PUT("/type").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("修改字典类型信息").Handle(s.UpdateDictType)
|
||||
}).
|
||||
Doc("修改字典类型信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.SysDictType{}))
|
||||
|
||||
dict.DELETE("type/:dictId", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("删除字典类型信息").Handle(s.DeleteDictType)
|
||||
})
|
||||
ws.Route(ws.DELETE("/type/{dictId}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("删除字典类型信息").Handle(s.DeleteDictType)
|
||||
}).
|
||||
Doc("删除字典类型信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Param(ws.PathParameter("dictId", "多id 1,2,3").DataType("string")))
|
||||
|
||||
dict.GET("type/export", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("导出字典类型信息").Handle(s.ExportDictType)
|
||||
})
|
||||
ws.Route(ws.GET("/type/export").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("导出字典类型信息").Handle(s.ExportDictType)
|
||||
}).
|
||||
Doc("导出字典类型信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags))
|
||||
|
||||
dict.GET("data/list", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("获取字典数据分页列表").Handle(s.GetDictDataList)
|
||||
})
|
||||
ws.Route(ws.GET("/data/list").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取字典数据分页列表").Handle(s.GetDictDataList)
|
||||
}).
|
||||
Doc("获取字典数据分页列表").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Returns(200, "OK", []entity.SysDictData{}))
|
||||
|
||||
dict.GET("data/type", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("获取字典数据列表通过字典类型").Handle(s.GetDictDataListByDictType)
|
||||
})
|
||||
ws.Route(ws.GET("/data/type").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取字典数据列表通过字典类型").Handle(s.GetDictDataListByDictType)
|
||||
}).
|
||||
Doc("获取字典数据列表通过字典类型").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Returns(200, "OK", []entity.SysDictType{}))
|
||||
|
||||
dict.GET("data/:dictCode", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("获取字典数据信息").Handle(s.GetDictData)
|
||||
})
|
||||
ws.Route(ws.GET("/data/{dictCode}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取字典数据信息").Handle(s.GetDictData)
|
||||
}).
|
||||
Doc("获取字典数据信息").
|
||||
Param(ws.PathParameter("dictCode", "dictCode").DataType("string")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Returns(200, "OK", []entity.SysDictType{}))
|
||||
|
||||
dict.POST("data", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("添加字典数据信息").Handle(s.InsertDictData)
|
||||
})
|
||||
ws.Route(ws.POST("/data").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("添加字典数据信息").Handle(s.InsertDictData)
|
||||
}).
|
||||
Doc("添加字典数据信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.SysDictData{}))
|
||||
|
||||
dict.PUT("data", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("修改字典数据信息").Handle(s.UpdateDictData)
|
||||
})
|
||||
ws.Route(ws.PUT("/data").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("修改字典数据信息").Handle(s.UpdateDictData)
|
||||
}).
|
||||
Doc("修改字典数据信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.SysDictData{}))
|
||||
|
||||
dict.DELETE("data/:dictCode", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("删除字典数据信息").Handle(s.DeleteDictData)
|
||||
})
|
||||
ws.Route(ws.DELETE("data/{dictCode}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("删除字典数据信息").Handle(s.DeleteDictData)
|
||||
}).
|
||||
Doc("删除字典数据信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Param(ws.PathParameter("dictCode", "多id 1,2,3").DataType("string")))
|
||||
|
||||
container.Add(ws)
|
||||
|
||||
}
|
||||
|
||||
@@ -2,53 +2,96 @@ 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 InitMenuRouter(router *gin.RouterGroup) {
|
||||
func InitMenuRouter(container *restful.Container) {
|
||||
s := &api.MenuApi{
|
||||
MenuApp: services.SysMenuModelDao,
|
||||
RoleApp: services.SysRoleModelDao,
|
||||
RoleMenuApp: services.SysRoleMenuModelDao,
|
||||
DeptApp: services.SysDeptModelDao,
|
||||
}
|
||||
menu := router.Group("menu")
|
||||
ws := new(restful.WebService)
|
||||
ws.Path("/system/menu").Produces(restful.MIME_JSON)
|
||||
tags := []string{"menu"}
|
||||
|
||||
menu.GET("menuTreeSelect", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("获取菜单树").WithNeedToken(false).WithNeedCasbin(false).Handle(s.GetMenuTreeSelect)
|
||||
})
|
||||
ws.Route(ws.GET("/menuTreeSelect").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取菜单树").WithNeedToken(false).WithNeedCasbin(false).Handle(s.GetMenuTreeSelect)
|
||||
}).
|
||||
Doc("获取菜单树").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes([]entity.SysMenu{}).
|
||||
Returns(200, "OK", []entity.SysMenu{}))
|
||||
|
||||
menu.GET("menuRole", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("获取角色菜单").Handle(s.GetMenuRole)
|
||||
})
|
||||
ws.Route(ws.GET("/menuRole").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取角色菜单").Handle(s.GetMenuRole)
|
||||
}).
|
||||
Doc("获取角色菜单").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes([]entity.MenuRole{}).
|
||||
Returns(200, "OK", []entity.MenuRole{}))
|
||||
|
||||
menu.GET("roleMenuTreeSelect/:roleId", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("获取角色菜单树").Handle(s.GetMenuTreeRoleSelect)
|
||||
})
|
||||
ws.Route(ws.GET("/roleMenuTreeSelect/{roleId}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取角色菜单树").Handle(s.GetMenuTreeRoleSelect)
|
||||
}).
|
||||
Doc("获取角色菜单树").
|
||||
Param(ws.PathParameter("roleId", "Id").DataType("int").DefaultValue("1")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes(entity.SysMenu{}). // on the response
|
||||
Returns(200, "OK", entity.SysMenu{}).
|
||||
Returns(404, "Not Found", nil))
|
||||
|
||||
menu.GET("menuPaths", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("获取角色菜单路径列表").Handle(s.GetMenuPaths)
|
||||
})
|
||||
ws.Route(ws.GET("/menuPaths").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取角色菜单路径列表").Handle(s.GetMenuPaths)
|
||||
}).
|
||||
Doc("获取角色菜单").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes([]entity.MenuPath{}).
|
||||
Returns(200, "OK", []entity.MenuPath{}))
|
||||
|
||||
menu.GET("list", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("获取菜单列表").Handle(s.GetMenuList)
|
||||
})
|
||||
ws.Route(ws.GET("/list").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取菜单列表").Handle(s.GetMenuList)
|
||||
}).
|
||||
Doc("获取菜单列表").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes([]entity.SysMenu{}).
|
||||
Returns(200, "OK", []entity.SysMenu{}))
|
||||
|
||||
menu.GET(":menuId", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("获取菜单信息").Handle(s.GetMenu)
|
||||
})
|
||||
ws.Route(ws.GET("/{menuId}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取菜单信息").Handle(s.GetMenu)
|
||||
}).
|
||||
Doc("获取菜单信息").
|
||||
Param(ws.PathParameter("menuId", "Id").DataType("int").DefaultValue("1")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes(entity.SysMenu{}). // on the response
|
||||
Returns(200, "OK", entity.SysMenu{}).
|
||||
Returns(404, "Not Found", nil))
|
||||
|
||||
menu.POST("", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("添加菜单信息").Handle(s.InsertMenu)
|
||||
})
|
||||
ws.Route(ws.POST("").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("添加菜单信息").Handle(s.InsertMenu)
|
||||
}).
|
||||
Doc("添加菜单信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.SysMenu{})) // from the request
|
||||
|
||||
menu.PUT("", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("修改菜单信息").Handle(s.UpdateMenu)
|
||||
})
|
||||
ws.Route(ws.PUT("").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("修改菜单信息").Handle(s.UpdateMenu)
|
||||
}).
|
||||
Doc("修改菜单信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.SysMenu{})) // from the request
|
||||
|
||||
menu.DELETE(":menuId", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("删除菜单信息").Handle(s.DeleteMenu)
|
||||
})
|
||||
ws.Route(ws.DELETE("/{menuId}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("删除菜单信息").Handle(s.DeleteMenu)
|
||||
}).
|
||||
Doc("删除SysTenant信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Param(ws.PathParameter("menuId", "多id 1,2,3").DataType("string")))
|
||||
|
||||
container.Add(ws)
|
||||
}
|
||||
|
||||
@@ -2,31 +2,51 @@ 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 InitNoticeRouter(router *gin.RouterGroup) {
|
||||
func InitNoticeRouter(container *restful.Container) {
|
||||
s := &api.NoticeApi{
|
||||
DeptApp: services.SysDeptModelDao,
|
||||
NoticeApp: services.SysNoticeModelDao,
|
||||
}
|
||||
notice := router.Group("notice")
|
||||
ws := new(restful.WebService)
|
||||
ws.Path("/system/notice").Produces(restful.MIME_JSON)
|
||||
tags := []string{"notice"}
|
||||
|
||||
notice.GET("list", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("获取通知分页列表").Handle(s.GetNoticeList)
|
||||
})
|
||||
ws.Route(ws.GET("/list").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取通知分页列表").Handle(s.GetNoticeList)
|
||||
}).
|
||||
Doc("获取通知分页列表").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes([]entity.SysNotice{}).
|
||||
Returns(200, "OK", []entity.SysNotice{}))
|
||||
|
||||
notice.POST("", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("添加通知信息").Handle(s.InsertNotice)
|
||||
})
|
||||
ws.Route(ws.POST("").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("添加通知信息").Handle(s.InsertNotice)
|
||||
}).
|
||||
Doc("添加通知信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.SysNotice{})) // from the request
|
||||
|
||||
notice.PUT("", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("修改通知信息").Handle(s.UpdateNotice)
|
||||
})
|
||||
ws.Route(ws.PUT("").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("修改通知信息").Handle(s.UpdateNotice)
|
||||
}).
|
||||
Doc("修改通知信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.SysNotice{})) // from the request
|
||||
|
||||
ws.Route(ws.DELETE("/{noticeId}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("删除通知信息").Handle(s.DeleteNotice)
|
||||
}).
|
||||
Doc("删除通知信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Param(ws.PathParameter("noticeId", "多id 1,2,3").DataType("string")))
|
||||
|
||||
container.Add(ws)
|
||||
|
||||
notice.DELETE(":noticeId", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("删除通知信息").Handle(s.DeleteNotice)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -2,36 +2,61 @@ 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 InitPostRouter(router *gin.RouterGroup) {
|
||||
func InitPostRouter(container *restful.Container) {
|
||||
s := &api.PostApi{
|
||||
PostApp: services.SysPostModelDao,
|
||||
UserApp: services.SysUserModelDao,
|
||||
RoleApp: services.SysRoleModelDao,
|
||||
}
|
||||
post := router.Group("post")
|
||||
ws := new(restful.WebService)
|
||||
ws.Path("/system/post").Produces(restful.MIME_JSON)
|
||||
tags := []string{"post"}
|
||||
|
||||
post.GET("list", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("获取岗位分页列表").Handle(s.GetPostList)
|
||||
})
|
||||
ws.Route(ws.GET("/list").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取岗位分页列表").Handle(s.GetPostList)
|
||||
}).
|
||||
Doc("获取岗位分页列表").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes([]entity.SysPost{}).
|
||||
Returns(200, "OK", []entity.SysPost{}))
|
||||
|
||||
post.GET(":postId", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("获取岗位信息").Handle(s.GetPost)
|
||||
})
|
||||
ws.Route(ws.GET("/{postId}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取岗位信息").Handle(s.GetPost)
|
||||
}).
|
||||
Doc("获取岗位信息").
|
||||
Param(ws.PathParameter("postId", "Id").DataType("int").DefaultValue("1")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes(entity.SysPost{}). // on the response
|
||||
Returns(200, "OK", entity.SysPost{}).
|
||||
Returns(404, "Not Found", nil))
|
||||
|
||||
post.POST("", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("添加岗位信息").Handle(s.InsertPost)
|
||||
})
|
||||
ws.Route(ws.POST("").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("添加岗位信息").Handle(s.InsertPost)
|
||||
}).
|
||||
Doc("添加岗位信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.SysPost{})) // from the request
|
||||
|
||||
post.PUT("", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("修改岗位信息").Handle(s.UpdatePost)
|
||||
})
|
||||
ws.Route(ws.PUT("").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("修改岗位信息").Handle(s.UpdatePost)
|
||||
}).
|
||||
Doc("修改岗位信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.SysPost{})) // from the request
|
||||
|
||||
post.DELETE(":postId", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("删除岗位信息").Handle(s.DeletePost)
|
||||
})
|
||||
ws.Route(ws.DELETE("/{postId}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("删除岗位信息").Handle(s.DeletePost)
|
||||
}).
|
||||
Doc("删除岗位信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Param(ws.PathParameter("postId", "多id 1,2,3").DataType("string")))
|
||||
|
||||
container.Add(ws)
|
||||
}
|
||||
|
||||
@@ -2,49 +2,80 @@ 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 InitRoleRouter(router *gin.RouterGroup) {
|
||||
func InitRoleRouter(container *restful.Container) {
|
||||
s := &api.RoleApi{
|
||||
RoleApp: services.SysRoleModelDao,
|
||||
RoleMenuApp: services.SysRoleMenuModelDao,
|
||||
RoleDeptApp: services.SysRoleDeptModelDao,
|
||||
UserApp: services.SysUserModelDao,
|
||||
}
|
||||
role := router.Group("role")
|
||||
ws := new(restful.WebService)
|
||||
ws.Path("/system/role").Produces(restful.MIME_JSON)
|
||||
tags := []string{"role"}
|
||||
|
||||
role.GET("list", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("获取角色分页列表").Handle(s.GetRoleList)
|
||||
})
|
||||
ws.Route(ws.GET("/list").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取角色分页列表").Handle(s.GetRoleList)
|
||||
}).
|
||||
Doc("获取角色分页列表").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes([]entity.SysRole{}).
|
||||
Returns(200, "OK", []entity.SysRole{}))
|
||||
|
||||
role.GET(":roleId", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("获取角色信息").Handle(s.GetRole)
|
||||
})
|
||||
ws.Route(ws.GET("/{roleId}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取角色信息").Handle(s.GetRole)
|
||||
}).
|
||||
Doc("获取角色信息").
|
||||
Param(ws.PathParameter("roleId", "Id").DataType("int").DefaultValue("1")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes(entity.SysRole{}). // on the response
|
||||
Returns(200, "OK", entity.SysRole{}).
|
||||
Returns(404, "Not Found", nil))
|
||||
|
||||
role.POST("", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("添加角色信息").Handle(s.InsertRole)
|
||||
})
|
||||
ws.Route(ws.POST("").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("添加角色信息").Handle(s.InsertRole)
|
||||
}).
|
||||
Doc("添加角色信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.SysRole{})) // from the request
|
||||
|
||||
role.PUT("", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("修改角色信息").Handle(s.UpdateRole)
|
||||
})
|
||||
ws.Route(ws.PUT("").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("修改角色信息").Handle(s.UpdateRole)
|
||||
}).
|
||||
Doc("修改角色信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.SysRole{}))
|
||||
|
||||
role.PUT("changeStatus", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("修改角色状态").Handle(s.UpdateRoleStatus)
|
||||
})
|
||||
ws.Route(ws.PUT("/changeStatus").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("修改角色状态").Handle(s.UpdateRoleStatus)
|
||||
}).
|
||||
Doc("修改角色状态").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.SysRole{}))
|
||||
|
||||
role.PUT("dataScope", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("修改角色部门权限").Handle(s.UpdateRoleDataScope)
|
||||
})
|
||||
ws.Route(ws.PUT("/dataScope").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("修改角色部门权限").Handle(s.UpdateRoleDataScope)
|
||||
}).
|
||||
Doc("修改角色部门权限").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.SysRole{}))
|
||||
|
||||
role.DELETE(":roleId", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("删除角色信息").Handle(s.DeleteRole)
|
||||
})
|
||||
ws.Route(ws.DELETE("/{roleId}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("删除角色信息").Handle(s.DeleteRole)
|
||||
}).
|
||||
Doc("删除角色信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Param(ws.PathParameter("roleId", "多id 1,2,3").DataType("string")))
|
||||
|
||||
role.GET("export", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("导出角色信息").Handle(s.ExportRole)
|
||||
})
|
||||
ws.Route(ws.GET("/export").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("导出角色信息").Handle(s.ExportRole)
|
||||
}).
|
||||
Doc("导出角色信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags))
|
||||
}
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/emicklei/go-restful/v3"
|
||||
"pandax/apps/system/api"
|
||||
)
|
||||
|
||||
func InitSystemRouter(router *gin.RouterGroup) {
|
||||
func InitSystemRouter(container *restful.Container) {
|
||||
s := &api.System{}
|
||||
sys := router.Group("")
|
||||
|
||||
{
|
||||
sys.GET("", s.ConnectWs)
|
||||
sys.GET("server", s.ServerInfo)
|
||||
}
|
||||
ws := new(restful.WebService)
|
||||
ws.Path("/system").Produces(restful.MIME_JSON)
|
||||
ws.Route(ws.GET("/").To(s.ConnectWs))
|
||||
ws.Route(ws.GET("/server").To(s.ServerInfo))
|
||||
container.Add(ws)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"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"
|
||||
|
||||
"github.com/XM-GO/PandaKit/restfulx"
|
||||
logServices "pandax/apps/log/services"
|
||||
)
|
||||
|
||||
func InitUserRouter(router *gin.RouterGroup) {
|
||||
func InitUserRouter(container *restful.Container) {
|
||||
s := &api.UserApi{
|
||||
RoleApp: services.SysRoleModelDao,
|
||||
MenuApp: services.SysMenuModelDao,
|
||||
@@ -19,61 +21,112 @@ func InitUserRouter(router *gin.RouterGroup) {
|
||||
DeptApp: services.SysDeptModelDao,
|
||||
PostApp: services.SysPostModelDao,
|
||||
}
|
||||
user := router.Group("user")
|
||||
// 获取验证码
|
||||
user.GET("getCaptcha", s.GenerateCaptcha)
|
||||
ws := new(restful.WebService)
|
||||
ws.Path("/system/user").Produces(restful.MIME_JSON)
|
||||
tags := []string{"user"}
|
||||
|
||||
user.POST("login", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("登录").WithNeedToken(false).WithNeedCasbin(false).Handle(s.Login)
|
||||
})
|
||||
user.GET("auth", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("认证信息").WithNeedCasbin(false).Handle(s.Auth)
|
||||
})
|
||||
user.POST("logout", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("退出登录").WithNeedToken(false).WithNeedCasbin(false).Handle(s.LogOut)
|
||||
})
|
||||
ws.Route(ws.GET("/getCaptcha").To(s.GenerateCaptcha).Doc("获取验证码"))
|
||||
|
||||
user.GET("list", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("得到用户分页列表").Handle(s.GetSysUserList)
|
||||
})
|
||||
ws.Route(ws.POST("/login").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithNeedToken(false).WithNeedCasbin(false).WithLog("登录").Handle(s.Login)
|
||||
}).
|
||||
Doc("登录").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.SysUser{})) // from the request
|
||||
|
||||
user.POST("avatar", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("修改用户头像").Handle(s.InsetSysUserAvatar)
|
||||
})
|
||||
ws.Route(ws.POST("/logout").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithNeedToken(false).WithNeedCasbin(false).WithLog("退出登录").Handle(s.LogOut)
|
||||
}).
|
||||
Doc("退出登录").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags))
|
||||
|
||||
user.PUT("pwd", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("修改用户密码").Handle(s.SysUserUpdatePwd)
|
||||
})
|
||||
ws.Route(ws.GET("/auth").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithNeedCasbin(false).WithLog("认证信息").Handle(s.Auth)
|
||||
}).
|
||||
Doc("认证信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes(entity.SysUser{}).
|
||||
Returns(200, "OK", entity.SysUser{}))
|
||||
|
||||
user.GET("getById/:userId", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("获取用户信息").Handle(s.GetSysUser)
|
||||
})
|
||||
ws.Route(ws.GET("/list").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("得到用户分页列表").Handle(s.GetSysUserList)
|
||||
}).
|
||||
Doc("得到用户分页列表").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes([]entity.SysUser{}).
|
||||
Returns(200, "OK", []entity.SysUser{}))
|
||||
|
||||
user.GET("getInit", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("获取初始化角色岗位信息(添加用户初始化)").Handle(s.GetSysUserInit)
|
||||
})
|
||||
ws.Route(ws.GET("/getById/{userId}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取用户信息").Handle(s.GetSysUser)
|
||||
}).
|
||||
Doc("获取用户信息").
|
||||
Param(ws.PathParameter("userId", "Id").DataType("int").DefaultValue("1")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes(entity.SysUser{}). // on the response
|
||||
Returns(200, "OK", entity.SysUser{}).
|
||||
Returns(404, "Not Found", nil))
|
||||
|
||||
user.GET("getRoPo", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("获取用户角色岗位信息(添加用户初始化)").Handle(s.GetUserRolePost)
|
||||
})
|
||||
ws.Route(ws.GET("/getInit").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取初始化角色岗位信息(添加用户初始化)").Handle(s.GetSysUserInit)
|
||||
}).
|
||||
Doc("获取初始化角色岗位信息(添加用户初始化)").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes(entity.SysUser{}). // on the response
|
||||
Returns(200, "OK", entity.SysUser{}).
|
||||
Returns(404, "Not Found", nil))
|
||||
|
||||
user.POST("", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("添加用户信息").Handle(s.InsertSysUser)
|
||||
})
|
||||
ws.Route(ws.GET("/getRoPo").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取用户角色岗位信息(添加用户初始化)").Handle(s.GetUserRolePost)
|
||||
}).
|
||||
Doc("获取用户角色岗位信息(添加用户初始化)").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Returns(200, "OK", entity.SysUser{}).
|
||||
Returns(404, "Not Found", nil))
|
||||
|
||||
user.PUT("", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("修改用户信息").Handle(s.UpdateSysUser)
|
||||
})
|
||||
ws.Route(ws.POST("").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("添加用户信息").Handle(s.InsertSysUser)
|
||||
}).
|
||||
Doc("添加用户信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.SysUser{})) // from the request
|
||||
|
||||
user.PUT("changeStatus", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("修改用户状态").Handle(s.UpdateSysUserStu)
|
||||
})
|
||||
ws.Route(ws.PUT("").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("修改用户信息").Handle(s.UpdateSysUser)
|
||||
}).
|
||||
Doc("修改用户信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags)) // from the request
|
||||
|
||||
user.DELETE(":userId", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("删除用户信息").Handle(s.DeleteSysUser)
|
||||
})
|
||||
ws.Route(ws.PUT("/changeStatus").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("修改用户状态").Handle(s.UpdateSysUserStu)
|
||||
}).
|
||||
Doc("修改用户状态").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags)) // from the request
|
||||
|
||||
ws.Route(ws.DELETE("/{userId}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("删除用户信息").Handle(s.DeleteSysUser)
|
||||
}).
|
||||
Doc("删除用户信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Param(ws.PathParameter("userId", "多id 1,2,3").DataType("string")))
|
||||
|
||||
ws.Route(ws.POST("/avatar").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("修改用户头像").Handle(s.InsetSysUserAvatar)
|
||||
}).
|
||||
Doc("修改用户头像").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags))
|
||||
|
||||
ws.Route(ws.PUT("pwd").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("修改用户密码").Handle(s.SysUserUpdatePwd)
|
||||
}).
|
||||
Doc("修改用户密码").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags))
|
||||
|
||||
ws.Route(ws.GET("/export").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("导出用户信息").Handle(s.ExportUser)
|
||||
}).
|
||||
Doc("导出用户信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags))
|
||||
|
||||
container.Add(ws)
|
||||
|
||||
user.GET("export", func(c *gin.Context) {
|
||||
restfulx.NewReqCtx(c).WithLog("导出用户信息").Handle(s.ExportUser)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user