92 lines
2.6 KiB
TypeScript
92 lines
2.6 KiB
TypeScript
import type * as T from './type'
|
|
import http from '@/utils/http'
|
|
|
|
export type * from './type'
|
|
|
|
const BASE_URL = '/system/role'
|
|
|
|
/** @desc 查询角色列表(已废弃) */
|
|
export function listRole(query: T.RoleQuery) {
|
|
return http.get<T.RoleResp[]>(`${BASE_URL}/list`, query)
|
|
}
|
|
|
|
/** @desc 查询角色列表(新接口) */
|
|
export function getRoleList(query?: T.RoleNewQuery) {
|
|
return http.get<T.RoleNewResp[]>('/role/list', query)
|
|
}
|
|
|
|
/** @desc 分页查询角色列表(新接口) */
|
|
export function getRolePage(query?: T.RoleNewQuery) {
|
|
return http.get<PageRes<T.RoleNewResp[]>>('/role/page', query)
|
|
}
|
|
|
|
/** @desc 查询角色详情(已废弃) */
|
|
export function getRole(id: string) {
|
|
return http.get<T.RoleDetailResp>(`${BASE_URL}/${id}`)
|
|
}
|
|
|
|
/** @desc 查询角色详情(新接口) */
|
|
export function getRoleDetail(roleId: string) {
|
|
return http.get<T.RoleNewResp>(`/role/detail/${roleId}`)
|
|
}
|
|
|
|
/** @desc 新增角色(已废弃) */
|
|
export function addRole(data: any) {
|
|
return http.post(`${BASE_URL}`, data)
|
|
}
|
|
|
|
/** @desc 新增角色(新接口) */
|
|
export function addRoleNew(data: T.RoleAddReq) {
|
|
return http.post<boolean>('/role', data)
|
|
}
|
|
|
|
/** @desc 修改角色(已废弃) */
|
|
export function updateRole(data: any, id: string) {
|
|
return http.put(`${BASE_URL}/${id}`, data)
|
|
}
|
|
|
|
/** @desc 修改角色(新接口) */
|
|
export function updateRoleNew(roleId: string, data: T.RoleUpdateReq) {
|
|
return http.put<boolean>(`/role/${roleId}`, data)
|
|
}
|
|
|
|
/** @desc 删除角色(已废弃) */
|
|
export function deleteRole(id: string) {
|
|
return http.del(`${BASE_URL}`, { ids: [id] })
|
|
}
|
|
|
|
/** @desc 删除角色(新接口) */
|
|
export function deleteRoleNew(roleId: string) {
|
|
return http.del<boolean>(`/role/${roleId}`)
|
|
}
|
|
|
|
/** @desc 绑定菜单(新接口) */
|
|
export function bindRoleMenu(data: T.RoleBindMenuReq) {
|
|
return http.put<boolean>('/role/bind-menu', data)
|
|
}
|
|
|
|
/** @desc 修改角色权限(已废弃) */
|
|
export function updateRolePermission(id: string, data: any) {
|
|
return http.put(`${BASE_URL}/${id}/permission`, data)
|
|
}
|
|
|
|
/** @desc 查询角色关联用户 */
|
|
export function listRoleUser(id: string, query: T.RoleUserPageQuery) {
|
|
return http.get<PageRes<T.RoleUserResp[]>>(`${BASE_URL}/${id}/user`, query)
|
|
}
|
|
|
|
/** @desc 分配角色给用户 */
|
|
export function assignToUsers(id: string, userIds: Array<string>) {
|
|
return http.post(`${BASE_URL}/${id}/user`, userIds)
|
|
}
|
|
|
|
/** @desc 取消分配角色给用户 */
|
|
export function unassignFromUsers(userRoleIds: Array<string | number>) {
|
|
return http.del(`${BASE_URL}/user`, userRoleIds)
|
|
}
|
|
|
|
/** @desc 查询角色关联用户 ID */
|
|
export function listRoleUserId(id: string) {
|
|
return http.get(`${BASE_URL}/${id}/user/id`)
|
|
}
|