import {
  IdParam,
  RoleQueryParam,
  RolePageResult,
  RolePermissionFormData,
  PermissionQueryParam,
  PermissionItem
} from '@/types/api/system/role';
import request from '@/utils/request';
import { AxiosPromise } from 'axios';

/**
 * "系统管理" => "角色管理"
 */
export function roleManage(data: RoleQueryParam): AxiosPromise<RolePageResult> {
  return request({
    url: 'admin/system/role/all',
    method: 'post',
    params: data
  });
}

/**
 * "系统管理" => "角色管理"->"查询角色权限"
 * @param data
 */
export function queryRolePermission(data: PermissionQueryParam): AxiosPromise<PermissionItem[]> {
  return request({
    url: 'admin/system/role/permission',
    method: 'post',
    params: data
  });
}

/**
 * "系统管理" => "角色管理"->"添加或修改角色信息"
 * @param data
 */
export function addAuditRole(data: RolePermissionFormData): any {
  return request({
    url: 'admin/system/role/merge',
    method: 'post',
    params: data
  });
}

/**
 * "系统管理" => "角色管理"->"获取全部权限"
 */
export function getAllPermission(): AxiosPromise<PermissionItem[]> {
  return request({
    url: 'admin/system/role/permission/all',
    method: 'post'
  });
}

/**
 * "系统管理" => "角色管理"->"删除角色"
 */
export function deleteRole(data: IdParam): any {
  return request({
    url: 'admin/system/role/deletes',
    method: 'post',
    params: data
  });
}
