【更新】更新swagger文档

This commit is contained in:
PandaGoAdmin
2022-08-04 16:57:18 +08:00
parent 6db51fb2c9
commit 6d893f7c4e
39 changed files with 439 additions and 214 deletions

View File

@@ -5,6 +5,7 @@ import (
restfulspec "github.com/emicklei/go-restful-openapi/v2"
"github.com/emicklei/go-restful/v3"
"pandax/apps/system/api"
"pandax/apps/system/api/vo"
"pandax/apps/system/entity"
"pandax/apps/system/services"
)
@@ -26,21 +27,29 @@ func InitDeptRouter(container *restful.Container) {
Doc("获取角色部门树").
Param(ws.PathParameter("roleId", "角色Id").DataType("int").DefaultValue("1")).
Metadata(restfulspec.KeyOpenAPITags, tags).
Writes(map[string]any{}). // on the response
Writes(vo.DeptTreeVo{}).
Returns(200, "OK", vo.DeptTreeVo{}).
Returns(404, "Not Found", nil))
ws.Route(ws.GET("/deptTree").To(func(request *restful.Request, response *restful.Response) {
restfulx.NewReqCtx(request, response).WithLog("获取所有部门树").Handle(s.GetDeptTree)
}).
Doc("获取所有部门树").
Param(ws.QueryParameter("deptName", "deptName").DataType("string")).
Param(ws.QueryParameter("status", "status").DataType("string")).
Param(ws.QueryParameter("deptId", "deptId").DataType("int")).
Metadata(restfulspec.KeyOpenAPITags, tags).
Writes([]entity.SysDept{}). // on the response
Writes([]entity.SysDept{}).
Returns(200, "OK", []entity.SysDept{}).
Returns(404, "Not Found", nil))
ws.Route(ws.GET("/list").To(func(request *restful.Request, response *restful.Response) {
restfulx.NewReqCtx(request, response).WithLog("获取部门列表").Handle(s.GetDeptList)
}).
Doc("获取部门列表").
Param(ws.QueryParameter("deptName", "deptName").DataType("string")).
Param(ws.QueryParameter("status", "status").DataType("string")).
Param(ws.QueryParameter("deptId", "deptId").DataType("int")).
Metadata(restfulspec.KeyOpenAPITags, tags).
Writes([]entity.SysDept{}).
Returns(200, "OK", []entity.SysDept{}))
@@ -60,14 +69,14 @@ func InitDeptRouter(container *restful.Container) {
}).
Doc("添加部门信息").
Metadata(restfulspec.KeyOpenAPITags, tags).
Reads(entity.SysDept{})) // from the request
Reads(entity.SysDept{}))
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
Reads(entity.SysDept{}))
ws.Route(ws.DELETE("/{deptId}").To(func(request *restful.Request, response *restful.Response) {
restfulx.NewReqCtx(request, response).WithLog("删除部门信息").Handle(s.DeleteDept)