import { request } from '@/service/request';

// 参数接口
export interface DepartmentParams {
  id?: number;
  depname?: string;
  address?: string;
  phone?: string;
  email?: string;
  manager?: string;
  createTime?: Record<string, unknown>;
  modifyTime?: Record<string, unknown>;
  createUid?: number;
  disabled?: string;
}

// 响应接口
export interface Res {
  status: boolean;
  msg: string;
  data: Record<string, unknown>;
  total: number;
}

/**
 * 查询部门
 * @param {string} pageNum
 * @param {string} pageSize
 * @param {object} params EasSysDepartment
 * @param {number} params.id
 * @param {string} params.depname 部门名称
 * @param {string} params.address 部门地址
 * @param {string} params.phone 部门电话
 * @param {string} params.email 部门电子邮箱
 * @param {string} params.manager 部门负责人
 * @param {object} params.createTime 创建时间
 * @param {object} params.modifyTime 修改时间
 * @param {number} params.createUid 创建用户ID
 * @param {string} params.disabled 状态
 * @returns
 */
export function queryDepartment(
  pageNum: number,
  pageSize: number,
  params: DepartmentParams
): Promise<Service.RequestResult<DepartmentParams[]>> {
  return request.post(`/department/query?pageNum=${pageNum}&pageSize=${pageSize}`, params);
}

export function addDepartment(params: DepartmentParams): Promise<Service.RequestResult<Res>> {
  return request.post(`/department/add`, params);
}

export function editDepartment(params: DepartmentParams): Promise<Service.RequestResult<Res>> {
  return request.put(`/department/update`, params);
}

export function delDepartment(id: number): Promise<Service.RequestResult<Res>> {
  return request.delete(`/department/delete?id=${id}`);
}
