syntax = "v1" import ( "user.api" "base.api" ) type ( QueryDeptsReq { PageReq SortReq } CreateDeptReq { Name string `json:"name" validate:"required" comment:"部门名称"` ParentId int `json:"parentId" validate:"required" comment:"上级部门"` Order int `json:"order,optional" comment:"排序, 在父部门中的次序值, order值大的排序靠前"` } UpdateDeptReq { PathId Name string `json:"name" validate:"required" comment:"部门名称"` ParentId int `json:"parentId" validate:"required" comment:"上级部门"` Order int `json:"order,optional" comment:"排序, 在父部门中的次序值, order值大的排序靠前"` } QueryDeptsReply { PageReply Data []DeptReply `json:"data"` } DeptReply { Id int `json:"id"` Name string `json:"name" comment:"部门名称"` ParentId int `json:"parentId" comment:"上级部门"` Order int `json:"order" comment:"排序, 在父部门中的次序值, order值大的排序靠前"` CreatedAt int64 `json:"createdAt" comment:"创建时间"` // 创建时间 UpdatedAt int64 `json:"updatedAt" comment:"更新时间"` // 更新时间 } DeptTree { Id int `json:"id"` Name string `json:"name"` Children []*DeptTree `json:"children,omitempty"` } ) @server ( jwt: Auth group: dept prefix: /api/v1 ) service spherical-api { @doc "查询部门分页列表" @handler queryDepts get /depts (QueryDeptsReq) returns (QueryDeptsReply) @doc "获取部门树" @handler deptsTree get /depts/tree returns ([]*DeptTree) @doc "获取部门详情" @handler getDept get /depts/:id (PathId) returns (DeptReply) @doc ( summary: "创建部门" comment: "创建成功返回部门信息" ) @handler createDept post /depts (CreateDeptReq) returns (int) @doc "编辑部门" @handler updateDept put /depts/:id (UpdateDeptReq) @doc "删除部门" @handler deleteDept delete /depts/:id (PathId) }