import {
  IdParam,
  DeptQueryParam,
  DeptPageResult,
  AddDeptFormData,
  UpdateDeptFormData,
  DeptItem
} from '@/types/api/system/dept';
import request from '@/utils/request';
import { AxiosPromise } from 'axios';

/**
 * "系统管理" => "部门管理"=>"所有部门"
 * @param data
 */
export function departmentManage(data: DeptQueryParam): AxiosPromise<DeptPageResult> {
  return request({
    url: 'admin/system/department/all',
    method: 'post',
    params: data
  });
}

/**
 * "系统管理" => "部门管理"->"添加部门信息"
 * @param data
 */
export function addAuditDepart(data: AddDeptFormData): any {
  return request({
    url: 'admin/system/department/merge',
    method: 'post',
    params: data
  });
}

/**
 * "系统管理" => "部门管理"->"修改部门信息"
 * @param data
 */
export function updateAuditDepart(data: UpdateDeptFormData): any {
  return request({
    url: 'admin/system/department/merge',
    method: 'post',
    params: data
  });
}

/**
 * "系统管理" => "部门管理"->"删除部门"
 * @param data
 */
export function delDepart(ids: any): any {
  return request({
    url: 'admin/system/department/deletes',
    method: 'post',
    params: ids
  });
}

/**
 * "系统管理" => "部门管理"->"查看部门详细信息"
 * @param data
 */
export function departDetail(data: IdParam): AxiosPromise<DeptItem> {
  return request({
    url: 'admin/system/department/detail',
    method: 'post',
    params: data
  });
}
