import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ProjectTeamForemanResp, ProjectTeamForm, ProjectTeamQuery, ProjectTeamVO } from '@/api/project/projectTeam/types';

/**
 * 查询项目班组列表
 * @param query
 * @returns {*}
 */

export const listProjectTeam = (query?: ProjectTeamQuery): AxiosPromise<ProjectTeamVO[]> => {
  return request({
    url: '/project/projectTeam/list',
    method: 'get',
    params: query
  });
};

/**
 * 根据项目id查询项目班组班组长信息列表
 * @param projectId
 */
export const listProjectTeamForeman = (projectId: string | number): AxiosPromise<ProjectTeamForemanResp[]> => {
  return request({
    url: '/project/projectTeam/listForeman/' + projectId,
    method: 'get'
  });
};

/**
 * 查询项目班组详细
 * @param id
 */
export const getProjectTeam = (id: string | number): AxiosPromise<ProjectTeamVO> => {
  return request({
    url: '/project/projectTeam/' + id,
    method: 'get'
  });
};

/**
 * 新增项目班组
 * @param data
 */
export const addProjectTeam = (data: ProjectTeamForm): AxiosPromise<string | number> => {
  return request({
    url: '/project/projectTeam',
    method: 'post',
    data: data
  });
};

/**
 * 修改项目班组
 * @param data
 */
export const updateProjectTeam = (data: ProjectTeamForm) => {
  return request({
    url: '/project/projectTeam',
    method: 'put',
    data: data
  });
};

/**
 * 删除项目班组
 * @param id
 */
export const delProjectTeam = (id: string | number | Array<string | number>) => {
  return request({
    url: '/project/projectTeam/' + id,
    method: 'delete'
  });
};
