syntax = "v1"

info(
	title: "天联鹰蜓"
	desc: "天联鹰蜓"
	author: "email"
	email: "email"
	version: "v1"
)

@server(
	prefix: v1
	group: role
	middleware: LoginStatusCheck
	jwt: SystemAuth
)
service Core {
	@doc "角色详情"
	@handler systemGetRole
	get /system/role/:id (RoleGetRequest) returns (RoleGetResponse)
	@doc "角色新增"
	@handler systemSaveRole
	post /system/role (RoleSaveRequest) returns (RoleSaveResponse)
	@doc "角色删除"
	@handler systemDeleteRole
	delete /system/role/:id (RoleDeleteRequest) returns (RoleDeleteResponse)
	@doc "角色更新"
	@handler systemUpdateRole
	put /system/role/:id (RoleUpdateRequest) returns (RoleUpdateResponse)
	@doc "角色列表搜索"
	@handler systemSearchRole
	post /system/role/search (RoleSearchRequest) returns (RoleSearchResponse)
}

type (
	RoleGetRequest {
		Id int64 `path:"id"`
	}
	RoleGetResponse {
		Role     RoleItem `json:"role"`
		AuthList []Auth   `json:"authList"`
	}

	RoleSaveRequest {
		Role RoleItem `json:"role"`
	}
	RoleSaveResponse struct{}

	RoleDeleteRequest {
		Id int64 `path:"id"`
	}
	RoleDeleteResponse struct{}

	RoleUpdateRequest {
		Id   int64    `path:"id"`
		Role RoleItem `json:"role"`
	}
	RoleUpdateResponse struct{}

	RoleSearchRequest {
		Page  int    `json:"page,optional"`
		Size  int    `json:"size,optional"`
		Style string `json:"style,options=[simple,,full]"` // simple:只返回角色ID名称 full:所有字段都返回
	}
	RoleSearchResponse {
		List  []RoleItem `json:"list"`
		Total int64      `json:"total"`
	}
	RoleItem {
		Id        int64      `json:"id,optional"`                  // 角色ID
		CompanyId int64      `json:"companyId,optional,omitempty"` // 公司ID
		Name      string     `json:"name"`                         // 角色名称
		AuthIds   []int64    `json:"authIds,optional,omitempty"`   // 角色权限列表
		AuthsDesc string     `json:"authsDesc,optional,omitempty"` // 权限列表描述
		UsersDesc string     `json:"usersDesc,optional,omitempty"` // 用户列表描述
		Remark    string     `json:"remark,optional,omitempty"`    // 备注
		Users     []RoleUser `json:"users,optional,omitempty"`     // 绑定的用户
		UpdatedAt int64      `json:"updatedAt,optional,omitempty"` // 更新时间
	}
	RoleUser {
		Id   int64  `json:"id"`
		Name string `json:"name"`
	}
	Auth {
		Id   int64  `json:"id"`   // ID
		Name string `json:"name"` // 名称
		Code string `json:"code"` // 编码
	}
)