mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-23 10:58:35 +08:00
【更新】更新swagger文档
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/XM-GO/PandaKit/model"
|
||||
restfulspec "github.com/emicklei/go-restful-openapi/v2"
|
||||
"github.com/emicklei/go-restful/v3"
|
||||
"pandax/apps/system/api"
|
||||
"pandax/apps/system/api/form"
|
||||
"pandax/apps/system/api/vo"
|
||||
"pandax/apps/system/entity"
|
||||
"pandax/apps/system/services"
|
||||
|
||||
@@ -32,7 +35,9 @@ func InitUserRouter(container *restful.Container) {
|
||||
}).
|
||||
Doc("登录").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.SysUser{})) // from the request
|
||||
Reads(form.Login{}).
|
||||
Writes(vo.TokenVo{}).
|
||||
Returns(200, "OK", vo.TokenVo{}))
|
||||
|
||||
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)
|
||||
@@ -44,17 +49,23 @@ func InitUserRouter(container *restful.Container) {
|
||||
restfulx.NewReqCtx(request, response).WithNeedCasbin(false).WithLog("认证信息").Handle(s.Auth)
|
||||
}).
|
||||
Doc("认证信息").
|
||||
Param(ws.QueryParameter("username", "username").DataType("string")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes(entity.SysUser{}).
|
||||
Returns(200, "OK", entity.SysUser{}))
|
||||
Writes(vo.AuthVo{}).
|
||||
Returns(200, "OK", vo.AuthVo{}))
|
||||
|
||||
ws.Route(ws.GET("/list").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("得到用户分页列表").Handle(s.GetSysUserList)
|
||||
}).
|
||||
Doc("得到用户分页列表").
|
||||
Param(ws.QueryParameter("pageNum", "页数").Required(true).DataType("int")).
|
||||
Param(ws.QueryParameter("pageSize", "每页条数").Required(true).DataType("int")).
|
||||
Param(ws.QueryParameter("status", "status").DataType("string")).
|
||||
Param(ws.QueryParameter("username", "username").DataType("string")).
|
||||
Param(ws.QueryParameter("phone", "phone").DataType("string")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes([]entity.SysUser{}).
|
||||
Returns(200, "OK", []entity.SysUser{}))
|
||||
Writes(model.ResultPage{}).
|
||||
Returns(200, "OK", model.ResultPage{}))
|
||||
|
||||
ws.Route(ws.GET("/getById/{userId}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取用户信息").Handle(s.GetSysUser)
|
||||
@@ -62,8 +73,8 @@ func InitUserRouter(container *restful.Container) {
|
||||
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{}).
|
||||
Writes(vo.UserVo{}).
|
||||
Returns(200, "OK", vo.UserVo{}).
|
||||
Returns(404, "Not Found", nil))
|
||||
|
||||
ws.Route(ws.GET("/getInit").To(func(request *restful.Request, response *restful.Response) {
|
||||
@@ -71,8 +82,8 @@ func InitUserRouter(container *restful.Container) {
|
||||
}).
|
||||
Doc("获取初始化角色岗位信息(添加用户初始化)").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes(entity.SysUser{}). // on the response
|
||||
Returns(200, "OK", entity.SysUser{}).
|
||||
Writes(vo.UserRolePost{}). // on the response
|
||||
Returns(200, "OK", vo.UserRolePost{}).
|
||||
Returns(404, "Not Found", nil))
|
||||
|
||||
ws.Route(ws.GET("/getRoPo").To(func(request *restful.Request, response *restful.Response) {
|
||||
@@ -80,7 +91,7 @@ func InitUserRouter(container *restful.Container) {
|
||||
}).
|
||||
Doc("获取用户角色岗位信息(添加用户初始化)").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Returns(200, "OK", entity.SysUser{}).
|
||||
Returns(200, "OK", vo.UserRolePost{}).
|
||||
Returns(404, "Not Found", nil))
|
||||
|
||||
ws.Route(ws.POST("").To(func(request *restful.Request, response *restful.Response) {
|
||||
@@ -94,13 +105,15 @@ func InitUserRouter(container *restful.Container) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("修改用户信息").Handle(s.UpdateSysUser)
|
||||
}).
|
||||
Doc("修改用户信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags)) // from the request
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.SysUser{}))
|
||||
|
||||
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
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.SysUser{}))
|
||||
|
||||
ws.Route(ws.DELETE("/{userId}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("删除用户信息").Handle(s.DeleteSysUser)
|
||||
@@ -125,6 +138,10 @@ func InitUserRouter(container *restful.Container) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("导出用户信息").Handle(s.ExportUser)
|
||||
}).
|
||||
Doc("导出用户信息").
|
||||
Param(ws.QueryParameter("filename", "filename").DataType("string")).
|
||||
Param(ws.QueryParameter("status", "status").DataType("string")).
|
||||
Param(ws.QueryParameter("username", "username").DataType("string")).
|
||||
Param(ws.QueryParameter("phone", "phone").DataType("string")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags))
|
||||
|
||||
container.Add(ws)
|
||||
|
||||
Reference in New Issue
Block a user