import { request } from "@umijs/max";

export interface PermissionAssignUserRoleReqVO {
  userId: number;
  roleIds: number[];
}

export interface PermissionAssignRoleMenuReqVO {
  roleId: number;
  menuIds: number[];
}

export interface PermissionAssignRoleDataScopeReqVO {
  roleId: number;
  dataScope: number;
  dataScopeDeptIds: React.Key[];
}

// export async function postProductProdRestoreProdList(
//   // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
//   params: API.postProductProdRestoreProdListParams,
//   options?: { [key: string]: any }
// ) {
//   return request<API.CommonResultBoolean>("/product/prod/restoreProdList", {
//     method: "POST",
//     params: {
//       ...params,
//     },
//     ...(options || {}),
//   });
// }
// export async function getRoleMenuList(
//   // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
//   params: API.getProductCategoryCategoryListParams,
//   options?: { [key: string]: any }
// ) {
//   return request<API.CommonResultListCategoryDto>(
//     "/product/category/categoryList",
//     {
//       method: "GET",
//       params: {
//         ...params,
//       },
//       ...(options || {}),
//     }
//   );
// }
// 查询角色拥有的菜单权限
// export const getRoleMenuList = async (roleId: number) => {
//   return await request.get({ url: '/system/permission/list-role-menus?roleId=' + roleId })
// }
export async function getRoleMenuList(roleId: number) {
  return request("/system/permission/list-role-menus", {
    method: "GET",
    params: {
      roleId,
    },
  });
}
// // 赋予角色菜单权限
// export const assignRoleMenu = async (data: PermissionAssignRoleMenuReqVO) => {
//   return await request.post({ url: '/system/permission/assign-role-menu', data })
// }
export async function assignRoleMenu(
  params: PermissionAssignRoleMenuReqVO,
  options?: { [key: string]: any }
) {
  return request("/system/permission/assign-role-menu", {
    method: "POST",
    params: {
      ...params,
    },
    ...(options || {}),
  });
}
// // 赋予角色数据权限
// export const assignRoleDataScope = async (data: PermissionAssignRoleDataScopeReqVO) => {
//   return await request.post({ url: '/system/permission/assign-role-data-scope', data })
// }
export async function assignRoleDataScope(
  params: PermissionAssignRoleDataScopeReqVO,
  options?: { [key: string]: any }
) {
  return request("/system/permission/assign-role-data-scope", {
    method: "POST",
    params: {
      ...params,
    },
    ...(options || {}),
  });
}
// // 查询用户拥有的角色数组
// export const getUserRoleList = async (userId: number) => {
//   return await request.get({ url: '/system/permission/list-user-roles?userId=' + userId })
// }
export async function getUserRoleList(userId: number) {
  return request("/system/permission/list-user-roles", {
    method: "GET",
    params: {
      userId,
    },
  });
}
// // 赋予用户角色
// export const assignUserRole = async (data: PermissionAssignUserRoleReqVO) => {
//   return await request.post({ url: '/system/permission/assign-user-role', data })
// }
export async function assignUserRole(
  params: PermissionAssignUserRoleReqVO,
  options?: { [key: string]: any }
) {
  return request("/system/permission/assign-user-role", {
    method: "POST",
    params: {
      ...params,
    },
    ...(options || {}),
  });
}
