98 lines
3.5 KiB
Plaintext
98 lines
3.5 KiB
Plaintext
syntax = "v1"
|
|
|
|
import (
|
|
"base.api"
|
|
)
|
|
|
|
type (
|
|
CreatePermissionReq {
|
|
Name string `json:"name,optional" validate:"required" comment:"权限名称"`
|
|
Code string `json:"code,optional" validate:"required" comment:"权限代码"`
|
|
ParentId *int `json:"parentId,optional" comment:"父权限ID"`
|
|
Sort string `json:"sort,optional" comment:"排序"`
|
|
IsMenu bool `json:"isMenu" comment:"是否菜单"` // 是否菜单
|
|
Description string `json:"description,optional" comment:"权限描述"` // 描述
|
|
}
|
|
UpdatePermissionReq {
|
|
PathId
|
|
Name string `json:"name,optional" validate:"required" comment:"权限名称"`
|
|
Code string `json:"code,optional" validate:"required" comment:"权限代码"`
|
|
ParentId *int `json:"parentId,optional" comment:"父权限ID"`
|
|
Sort string `json:"sort,optional" comment:"排序"`
|
|
IsMenu bool `json:"isMenu" comment:"是否菜单"` // 是否菜单
|
|
Description string `json:"description,optional" comment:"权限描述"` // 描述
|
|
}
|
|
SetPermissionApisReq {
|
|
PathId
|
|
Apis []int `json:"apis"`
|
|
}
|
|
DeletePermissionApiReq {
|
|
PathId
|
|
ApiId int `path:"apiId"`
|
|
}
|
|
PermissionReply {
|
|
Id int `json:"id,omitempty"`
|
|
Name string `json:"name,omitempty" comment:"权限名称"`
|
|
Code string `json:"code,omitempty" comment:"权限代码"`
|
|
ParentId *int `json:"parentId,omitempty" comment:"父权限ID"`
|
|
Sort string `json:"sort,omitempty" comment:"排序"`
|
|
IsMenu bool `json:"isMenu,omitempty" comment:"是否菜单"` // 是否菜单
|
|
Description string `json:"description,omitempty" comment:"权限描述"` // 描述
|
|
CreatedAt int64 `json:"createdAt" comment:"创建时间"`
|
|
UpdatedAt int64 `json:"updatedAt" comment:"更新时间"`
|
|
}
|
|
PermissionTree {
|
|
Id int `json:"id"`
|
|
Name string `json:"name" comment:"权限名称"`
|
|
Code string `json:"code" comment:"权限代码"`
|
|
ParentId *int `json:"parentId" comment:"父权限ID"`
|
|
Sort string `json:"sort" comment:"排序"`
|
|
IsMenu bool `json:"isMenu" comment:"是否菜单"` // 是否菜单
|
|
Description string `json:"description,omitempty" comment:"权限描述"` // 描述
|
|
Children []PermissionTree `json:"children,omitempty"`
|
|
}
|
|
)
|
|
|
|
@server (
|
|
jwt: Auth
|
|
group: permission
|
|
prefix: /api/v1
|
|
)
|
|
service spherical-api {
|
|
@doc "获取权限列表"
|
|
@handler listPermissions
|
|
get /permissions/list returns ([]PermissionReply)
|
|
|
|
@doc "获取子权限列表"
|
|
@handler listChildrenPermissions
|
|
get /permissions/:id/children-permissions/list (PathId) returns ([]PermissionReply)
|
|
|
|
@doc "获取权限树"
|
|
@handler permissionsTree
|
|
get /permissions/tree returns (PermissionTree)
|
|
|
|
@doc "创建权限"
|
|
@handler createPermission
|
|
post /permissions (CreatePermissionReq) returns (int)
|
|
|
|
@doc "编辑权限"
|
|
@handler updatePermission
|
|
put /permissions/:id (UpdatePermissionReq)
|
|
|
|
@doc "删除权限"
|
|
@handler deletePermission
|
|
delete /permissions/:id (PathId)
|
|
|
|
//////////////////////////////////////////////////
|
|
@doc "通过角色获取权限ID列表"
|
|
@handler listPermissionIdsOfRole
|
|
get /roles/:id/permissions/ids (PathId) returns ([]int)
|
|
|
|
@doc "设置权限接口"
|
|
@handler setPermissionApis
|
|
put /permissions/:id/apis (SetPermissionApisReq)
|
|
|
|
@doc "删除权限接口"
|
|
@handler deletePermissionApi
|
|
delete /permissions/:id/apis/:apiId (DeletePermissionApiReq)
|
|
} |