83 lines
2.1 KiB
Plaintext
83 lines
2.1 KiB
Plaintext
syntax = "v1"
|
|||
|
|
|
||
|
|
import (
|
||
|
|
"base.api"
|
||
|
|
"user.api"
|
||
|
|
"permission.api"
|
||
|
|
)
|
||
|
|
|
||
|
|
type (
|
||
|
|
QueryRolesReq {
|
||
|
|
PageReq
|
||
|
|
SortReq
|
||
|
|
Name string `form:"name,optional"`
|
||
|
|
}
|
||
|
|
CreateRoleReq {
|
||
|
|
Name string `json:"name,optional" validate:"required,gte=2,lte=20" comment:"角色名, 不能超过20个字符"`
|
||
|
|
Description string `json:"description,optional" comment:"描述, 不能超过60个字符"`
|
||
|
|
}
|
||
|
|
UpdateRoleReq {
|
||
|
|
PathId
|
||
|
|
Name string `json:"name,optional" validate:"required,gte=2,lte=20" comment:"角色名, 不能超过20个字符"`
|
||
|
|
Description string `json:"description,optional" comment:"描述, 不能超过60个字符"`
|
||
|
|
}
|
||
|
|
SetRolePermissionsReq {
|
||
|
|
PathId
|
||
|
|
Permissions []int `json:"permissions,optional" validate:"required"`
|
||
|
|
}
|
||
|
|
AddRoleUsersReq {
|
||
|
|
PathId
|
||
|
|
Users []int `json:"users,optional" validate:"required"`
|
||
|
|
}
|
||
|
|
DeleteRoleUserReq {
|
||
|
|
PathId
|
||
|
|
UserId int `path:"userId"`
|
||
|
|
}
|
||
|
|
QueryRolesReply {
|
||
|
|
PageReply
|
||
|
|
Data []RoleReply `json:"data"`
|
||
|
|
}
|
||
|
|
RoleReply {
|
||
|
|
Id int `json:"id"`
|
||
|
|
Name string `json:"name" comment:"角色名, 不能超过20个字符"`
|
||
|
|
Description string `json:"description" comment:"描述, 不能超过60个字符"`
|
||
|
|
CreatedAt int64 `json:"createdAt" comment:"创建时间"` // 创建时间
|
||
|
|
UpdatedAt int64 `json:"updatedAt" comment:"更新时间"` // 更新时间
|
||
|
|
}
|
||
|
|
)
|
||
|
|
|
||
|
|
@server (
|
||
|
|
jwt: Auth
|
||
|
|
group: role
|
||
|
|
prefix: /api/v1
|
||
|
|
)
|
||
|
|
service spherical-api {
|
||
|
|
@doc "查询角色分页列表"
|
||
|
|
@handler queryRoles
|
||
|
|
get /roles (QueryRolesReq) returns (QueryRolesReply)
|
||
|
|
|
||
|
|
@doc "创建角色"
|
||
|
|
@handler createRole
|
||
|
|
post /roles (CreateRoleReq) returns (int)
|
||
|
|
|
||
|
|
@doc "编辑角色"
|
||
|
|
@handler updateRole
|
||
|
|
put /roles/:id (UpdateRoleReq)
|
||
|
|
|
||
|
|
@doc "删除角色"
|
||
|
|
@handler deleteRole
|
||
|
|
delete /roles/:id (PathId)
|
||
|
|
|
||
|
|
//////////////////////////////////////////////////
|
||
|
|
@doc "设置角色权限"
|
||
|
|
@handler setRolePermissions
|
||
|
|
put /roles/:id/permissions (SetRolePermissionsReq)
|
||
|
|
|
||
|
|
@doc "添加角色用户"
|
||
|
|
@handler addRoleUsers
|
||
|
|
post /roles/:id/users (AddRoleUsersReq)
|
||
|
|
|
||
|
|
@doc "删除角色用户"
|
||
|
|
@handler deleteRoleUser
|
||
|
|
delete /roles/:id/users/:userId (DeleteRoleUserReq)
|
||
|
|
}
|