import { defHttp } from '/@/utils/http/axios';
import {
  GetDepartmentListModel,
  GetDepartmentTreeModel,
  DeleteBatchesParams,
  DepartmentIdParams,
  AddDepartmentParams,
  EditDepartmentParams,
  GetDepartmentModel,
} from './model/departmentModel';

enum Api {
  DepartmentUrl = '/department/',
  DepartmentTreeUrl = '/department/menu',
}

/**
 * @description: GetDepartmentList
 */
export function getDepartmentList(params) {
  console.log('-------------------getDepartmentList---------------');
  return defHttp.request<GetDepartmentListModel>({
    url: Api.DepartmentUrl,
    method: 'GET',
    params,
  });
}

/**
 * @description: addDepartment
 */
export function addDepartment(params: AddDepartmentParams) {
  return defHttp.request<GetDepartmentListModel>({
    url: Api.DepartmentUrl,
    method: 'POST',
    params,
  });
}
/**
 * @description: 批量删除部门
 */
export function deleteBatchesDepartment(params: DeleteBatchesParams) {
  return defHttp.request<GetDepartmentListModel>({
    url: Api.DepartmentUrl,
    method: 'DELETE',
    params,
  });
}

/**
 * @description: 获取单个部门
 */
export function getDepartment(params: DepartmentIdParams) {
  return defHttp.request<GetDepartmentModel>({
    url: Api.DepartmentUrl + '/' + params.id,
    method: 'GET',
  });
}
/**
 * @description: 修改单个部门
 */
export function editDepartment(params: EditDepartmentParams) {
  return defHttp.request<GetDepartmentListModel>({
    url: Api.DepartmentUrl + '/' + params.id,
    method: 'PUT',
    params,
  });
}
/**
 * @description: 删除单个部门
 */
export function deleteDepartment(params: DepartmentIdParams) {
  return defHttp.request<GetDepartmentListModel>({
    url: Api.DepartmentUrl + '/' + params.id,
    method: 'DELETE',
  });
}

/**
 * @description: GetDepartmentTree
 */
export function getDepartmentTree(params) {
  console.log('-------------------getDepartmentTree---------------');
  return defHttp.request<GetDepartmentTreeModel>({
    url: Api.DepartmentTreeUrl + '/' + params.id,
    method: 'GET',
  });
}
