import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ManagementVO, ManagementForm, ManagementQuery, ProjectMemberVO, ProjectMemberQuery } from '@/api/project/management/types';

/**
 * 查询项目管理列表
 * @param query
 * @returns {*}
 */

export const listManagement = (query?: ManagementQuery): AxiosPromise<ManagementVO[]> => {
  return request({
    url: '/project/management/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询项目管理详细
 * @param id
 */
export const getManagement = (id: string | number): AxiosPromise<ManagementVO> => {
  return request({
    url: '/project/management/' + id,
    method: 'get'
  });
};

/**
 * 新增项目管理
 * @param data
 */
export const addManagement = (data: ManagementForm) => {
  return request({
    url: '/project/management',
    method: 'post',
    data: data
  });
};

/**
 * 修改项目管理
 * @param data
 */
export const updateManagement = (data: ManagementForm) => {
  return request({
    url: '/project/management',
    method: 'put',
    data: data
  });
};

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

/**
 * 更新项目状态
 * @param id 项目ID
 * @param status 状态值
 */
export const updateStatus = (id: string | number, status: number) => {
  return request({
    url: '/project/management/updateStatus',
    method: 'put',
    data: { id, status }
  });
};

/**
 * 查询项目成员列表
 * @param query
 * @returns {*}
 */
export const queryProjectMember = (query: ProjectMemberQuery): AxiosPromise<ProjectMemberVO[]> => {
  return request({
    url: '/project/management/queryProjectMember',
    method: 'get',
    params: query
  });
};
