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

export interface UserVO {
  id: number;
  username: string;
  nickname: string;
  deptId: number;
  postIds: string[];
  email: string;
  mobile: string;
  sex: number;
  avatar: string;
  loginIp: string;
  status: number;
  remark: string;
  loginDate: Date;
  createTime: Date;
}

// export interface User {
//   id: number;
//   username: string;
//   nickname: string;
//   deptId: number;
//   postIds: string[];
//   email: string;
//   mobile: string;
//   sex: number;
//   avatar: string;
//   loginIp: string;
//   status: number;
//   remark: string;
//   loginDate: Date;
//   createTime: Date;
// }

export interface UserReqVO extends PageParam {
  username?: string;
  status?: number;
  mobile?: string;
  createTime?: Date;
  deptId?: number;
}

// export interface UserReq extends PageParam {
//   username?: string;
//   status?: number;
//   mobile?: string;
//   createTime?: Date;
//   deptId?: number;
// }

// 查询用户管理列表

export const getUserPage = (params: UserReqVO) => {
  return request("/system/user/page", {
    method: "GET",
    params,
  });
};

// export const getUserPage = (params: UserReq) => {
//   return request.get({ url: "/system/user/page", params });
// };

// 查询用户详情
export const getUser = (id: number) => {
  return request("/system/user/get", {
    method: "GET",
    params: { id },
  });
};

// export const getUser = (id: number) => {
//   return request.get({ url: "/system/user/get?id=" + id });
// };

// 新增用户
export const createUser = (data: UserVO) => {
  return request("/system/user/create", {
    method: "POST",
    data,
  });
};

// export const createUser = (data: User) => {
//   return request.post({ url: "/system/user/create", data });
// };

// 修改用户

export const updateUser = (data: UserVO) => {
  return request("/system/user/update", {
    method: "PUT",
    data,
  });
};
// export const updateUser = (data: User) => {
//   return request.put({ url: "/system/user/update", data });
// };

// 删除用户

export const deleteUser = (id: number) => {
  return request("/system/user/delete", {
    method: "DELETE",
    params: { id },
  });
};
// export const deleteUser = (id: number) => {
//   return request.delete({ url: "/system/user/delete?id=" + id });
// };

// 用户密码重置

export const resetUserPassword = (id: number, password: string) => {
  return request("/system/user/reset-password", {
    method: "PUT",
    params: { id, password },
  });
};
// export const resetUserPassword = (id: number, password: string) => {
//   const data = {
//     id,
//     password
//   };
//   return request.put({ url: "/system/user/update-password", data: data });
// };

// 用户状态修改
export const updateUserStatus = (id: number, status: number) => {
  return request("/system/user/update-status", {
    method: "PUT",
    data: { id, status },
  });
};
// export const updateUserStatus = (id: number, status: number) => {
//   const data = {
//     id,
//     status
//   };
//   return request.put({ url: "/system/user/update-status", data: data });
// };

// 获取用户精简信息列表
export const getSimpleUserList = () => {
  return request("/system/user/simple-list", {
    method: "GET",
  });
};
// export const getSimpleUserList = (): Promise<User[]> => {
//   return request.get({ url: "/system/user/simple-list" });
// };
