import { ResPage, User } from "@/api/interface/index";
import { PORT1 } from "@/api/config/servicePort";
import http from "@/api";

/**
 * @name 用户管理模块
 */
// 获取用户列表
export const getUserList = (params: User.ReqUserParams) => {
  return http.get<ResPage<User.ResUserList>>(PORT1 + `/system/user/list`, params);
};

// 新增用户
export const addUser = (params: Partial<User.ResUserList>) => {
  return http.post(PORT1 + `/system/user`, params);
};

// 编辑用户
export const editUser = (params: Partial<User.ResUserList>) => {
  return http.put(PORT1 + `/system/user`, params);
};

// 删除用户
export const deleteUser = (ids: string[]) => {
  return http.delete(PORT1 + `/system/user/${ids.join(",")}`);
};

// 重置用户密码
export const resetUserPassWord = (params: { userId: string; password: string }) => {
  return http.put(PORT1 + `/system/user/resetPwd`, params);
};

// 获取用户部门列表
export const getUserDepartment = () => {
  return http.get<User.ResDepartment[]>(PORT1 + `/system/user/deptTree`);
};
// 根据id获取用户信息
export const getUserInfoById = (userId?: number) => {
  return http.get<User.ResUserDetail>(PORT1 + `/system/user/${userId || ""}`);
};
