import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ComDeptVO, ComDeptForm, ComDeptQuery } from '@/api/company/comDept/types';

/**
 * 查询企业部门列表
 * @param query
 * @returns {*}
 */

export const listComDept = (query?: ComDeptQuery): AxiosPromise<ComDeptVO[]> => {
  return request({
    url: '/system/comDept/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询企业部门详细
 * @param id
 */
export const getComDept = (id: string | number): AxiosPromise<ComDeptVO> => {
  return request({
    url: '/system/comDept/' + id,
    method: 'get'
  });
};

/**
 * 新增企业部门
 * @param data
 */
export const addComDept = (data: ComDeptForm) => {
  return request({
    url: '/system/comDept',
    method: 'post',
    data: data
  });
};

/**
 * 修改企业部门
 * @param data
 */
export const updateComDept = (data: ComDeptForm) => {
  return request({
    url: '/system/comDept',
    method: 'put',
    data: data
  });
};

/**
 * 删除企业部门
 * @param id
 */
export const delComDept = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/comDept/' + id,
    method: 'delete'
  });
};

export function changeStatus(id: string | number, status: string) {
  const data = {
    id,
    status
  };
  return request({
    url: '/system/comDept/changeStatus',
    method: 'put',
    data: data
  });
}
