/*
 * @Author: zhanghaifeng
 * @Date: 2024-11-04 16:39:08
 * @LastEditors: zhanghaifeng
 * @LastEditTime: 2024-11-07 13:56:39
 * @Description:
 * @FilePath: /hospital-project/src/api/roles.ts
 */
import { http } from "@/utils/http";

type pageRole = {
  code: number;
  msg: string;
  data: boolean;
};
type pageRoleList = {
  code: number;
  msg: string;
  data: recordsList;
};

type recordsList = {
  records: Array<any>;
  totalPage: number;
  totalRow: number;
};
export const postPageRole = data => {
  return http.request<pageRoleList>("post", "/sysRole/pageRole", { data });
};
export const postDelRole = data => {
  return http.request<pageRole>("post", "/sysRole/delRole", { data });
};
// 添加角色信息
export const postAddRole = data => {
  return http.request<pageRole>("post", "/sysRole/addRole", { data });
};
// 修改角色信息
export const postUpdateRole = data => {
  return http.request<pageRole>("post", "/sysRole/updateRole", { data });
};
export const postUpdateRoleName = data => {
  return http.request<pageRole>("post", "/sysRole/updateRoleName", { data });
};
// 查询角色下用户
export const postPageUserByRole = data => {
  return http.request<pageRoleList>("post", "/sysRole/pageUserByRole", {
    data
  });
};
// 根据角色code查询菜单信息编码
export const getUserPermissionsByRoleCode = params => {
  return http.request<pageRoleList>(
    "get",
    "/sysRole/getUserPermissionsByRoleCode",
    {
      params
    }
  );
};
