import {
  GetUserListParams,
  IRoleItem,
  PermItemType,
  SaveRoleParams,
  SaveUserType,
} from "@/types";
import { requestByGet, requestByPost } from "@dage/service";

export const userApi = {
  getList(params: GetUserListParams) {
    return requestByPost("/api/sys/user/list", params);
  },
  getRoleList() {
    return requestByGet<IRoleItem[]>("/api/sys/user/getRole");
  },
  getPermTree() {
    return requestByGet<PermItemType[]>("/api/sys/user/perm/getTree");
  },
  saveRole(params: SaveRoleParams) {
    return requestByPost("/api/sys/role/save", params);
  },
  deleteRole(id: number | string) {
    return requestByGet(`/api/sys/role/remove/${id}`);
  },
  getRole(id: number | string) {
    return requestByGet(`/api/sys/role/detail/${id}`);
  },
  handleType(id: number, isEnabled: number) {
    return requestByGet(`/api/sys/user/editStatus/${id}/${isEnabled}`);
  },
  del(ids: number) {
    return requestByGet(`/api/sys/user/removes/${ids}`);
  },
  resetPwd(id: number) {
    return requestByGet(`/api/sys/user/resetPass/${id}`);
  },
  getDetail(id: number) {
    return requestByGet(`/api/sys/user/detail/${id}`);
  },
  edit(params: SaveUserType) {
    return requestByPost("/api/sys/user/save", params);
  },
};
