import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ConstructionUserForm, ConstructionUserQuery, ConstructionUserVO } from '@/api/project/constructionUser/types';

/**
 * 查询施工人员列表
 * @param query
 * @returns {*}
 */

export const listConstructionUser = (query?: ConstructionUserQuery): AxiosPromise<ConstructionUserVO[]> => {
  return request({
    url: '/project/constructionUser/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询施工人员详细
 * @param id
 */
export const getConstructionUser = (id: string | number): AxiosPromise<ConstructionUserVO> => {
  return request({
    url: '/project/constructionUser/' + id,
    method: 'get'
  });
};

/**
 * 新增施工人员
 * @param data
 */
export const addConstructionUser = (data: ConstructionUserForm): AxiosPromise<string | number> => {
  return request({
    url: '/project/constructionUser',
    method: 'post',
    data: data
  });
};

/**
 * 修改施工人员
 * @param data
 */
export const updateConstructionUser = (data: ConstructionUserForm) => {
  return request({
    url: '/project/constructionUser',
    method: 'put',
    data: data
  });
};

/**
 * 删除施工人员
 * @param id
 */
export const delConstructionUser = (id: string | number | Array<string | number>) => {
  return request({
    url: '/project/constructionUser/' + id,
    method: 'delete'
  });
};
