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

export interface RoleVO {
  id: number;
  name: string;
  code: string;
  sort: number;
  status: number;
  type: number;
  dataScope: number;
  dataScopeDeptIds: number[];
  createTime: Date;
  menuIds: number[];
}

export interface RolePageReqVO extends PageParam {
  name?: string;
  code?: string;
  status?: string;
  createTime?: Date[];
}

export interface UpdateStatusReq {
  id: number;
  status: number;
}

// 查询角色列表
export const getRolePage = (params: RolePageReqVO) => {
  return request("/system/role/page", {
    method: "GET",
    params,
  });
};
// export const getRolePage = async (
//     params: RolePageReq
//   ): Promise<PageResult<Role[]>> => {
//     return await request.get({ url: "/system/role/page", params });
//   };

// 查询角色（精简)列表

export const getSimpleRoleList = () => {
  return request("/system/role/simple-list", {
    method: "GET",
  });
};
// export const getSimpleRoleList = async (): Promise<Role[]> => {
//     return await request.get({ url: "/system/role/simple-list" });
//   };

// 查询角色详情
export const getRole = (id: number) => {
  return request("/system/role/get", {
    method: "GET",
    params: { id },
  });
};
// export const getRole = async (id: number) => {
//     return await request.get({ url: "/system/role/get?id=" + id });
//   };

// 新增角色
export const createRole = (data: RoleVO) => {
  return request("/system/role/create", {
    method: "POST",
    data,
  });
};

// export const createRole = async (data: Role) => {
//     return await request.post({ url: "/system/role/create", data });
//   };

// 修改角色
// export const updateRole = async (data: Role) => {
//   return await request.put({ url: "/system/role/update", data });
// };
export const updateRole = (data: RoleVO) => {
  return request("/system/role/update", {
    method: "PUT",
    data,
  });
};

// 修改角色状态
export const updateRoleStatus = (data: UpdateStatusReq) => {
  return request("/system/role/update-status", {
    method: "PUT",
    data,
  });
};
// export const updateRoleStatus = async (data: UpdateStatusReq) => {
//   return await request.put({ url: "/system/role/update-status", data });
// };

// 删除角色
export const deleteRole = (id: number) => {
  return request("/system/role/delete", {
    method: "DELETE",
    params: { id },
  });
};
// export const deleteRole = async (id: number) => {
//   return await request.delete({ url: "/system/role/delete?id=" + id });
// };
