import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ComStaffVO, ComStaffForm, ComStaffQuery } from '@/api/company/comStaff/types';

/**
 * 查询人员信息列表
 * @param query
 * @returns {*}
 */

export const listComStaff = (query?: ComStaffQuery): AxiosPromise<ComStaffVO[]> => {
  return request({
    url: '/system/comStaff/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询人员信息详细
 * @param staffId
 */
export const getComStaff = (staffId: string | number): AxiosPromise<ComStaffVO> => {
  return request({
    url: '/system/comStaff/' + staffId,
    method: 'get'
  });
};

/**
 * 新增人员信息
 * @param data
 */
export const addComStaff = (data: ComStaffForm) => {
  return request({
    url: '/system/comStaff',
    method: 'post',
    data: data
  });
};

/**
 * 修改人员信息
 * @param data
 */
export const updateComStaff = (data: ComStaffForm) => {
  return request({
    url: '/system/comStaff',
    method: 'put',
    data: data
  });
};

/**
 * 删除人员信息
 * @param staffId
 */
export const delComStaff = (staffId: string | number | Array<string | number>) => {
  return request({
    url: '/system/comStaff/' + staffId,
    method: 'delete'
  });
};

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