import { http } from '@/utils/http/axios';

/**
 * @description: 添加管理角色
 */
export function addAdminRole(params) {
  return http.request({
    url: '/role/addAdmin',
    method: 'POST',
    params,
  });
}

export interface RoleType<T> {
  permissionList?: T[];
  remark?: string;
  roleName?: string;
  roleCode?: string;
  roleId?: number;
}

export interface PermissionType {
  workshopCode: string;
  permissionId: string;
}

/**
 * @description: 添加用户角色
 */
export function addRole(params: RoleType<PermissionType>) {
  return http.request({
    url: '/role/add',
    method: 'POST',
    params,
  });
}

/**
 * @description: 修改用户角色
 */
export function updateRole(params: RoleType<PermissionType>) {
  return http.request({
    url: '/role/update',
    method: 'POST',
    params,
  });
}

/**
 * @description: 查询管理角色信息
 */
export function roleAdminInfo(params) {
  return http.request({
    url: '/role/infoAdmin',

    params,
  });
}

/**
 * @description: 查询用户角色信息
 */
export function roleUserInfo(params) {
  return http.request({
    url: '/role/info',

    params,
  });
}

/**
 * @description: 编辑管理角色
 */
export function editAdminRole(params) {
  return http.request({
    url: '/role/updateAdmin',
    method: 'POST',
    params,
  });
}

/**
 * @description: 删除管理角色
 */
export function delAdminRole(params) {
  return http.request({
    url: '/role/deleteAdmin',
    method: 'POST',
    params,
  });
}

/**
 * @description: 删除用户角色
 */
export function delUserRole(params) {
  return http.request({
    url: '/role/delete',
    method: 'POST',
    params,
  });
}

/**
 * @description: 角色列表
 */
export function roleList(params?) {
  return http.request({
    url: '/role/pageList',

    params,
  });
}

/**
 * @description: 所有角色列表
 */
export function roleAllList(params?) {
  return http.request({
    url: '/role/getAllRoles',

    params,
  });
}

/**
 * @description: 获取所有权限
 */
export function permissionList() {
  return http.request({
    url: '/role/listAllPermission',

  });
}

/** @description: 获取功能权限 */
export function getFeaturePermissions() {
  return http.request({
    url: '/role/listFunctionPermission',

  });
}
