import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { FolderVO, FolderForm, FolderQuery, ProjectVO, ProjectQuery, FolderListVO } from '@/api/document/folder/types';

/**
 * 查询文件夹管理列表
 * @param query
 * @returns {*}
 */

export const listFolder = (query?: FolderQuery): AxiosPromise<FolderListVO[]> => {
  return request({
    url: '/document/folder/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询文件夹管理详细
 * @param id
 */
export const getFolder = (id: string | number): AxiosPromise<FolderVO> => {
  return request({
    url: '/document/folder/' + id,
    method: 'get'
  });
};

/**
 * 新增文件夹管理
 * @param data
 */
export const addFolder = (data: FolderForm) => {
  return request({
    url: '/document/folder',
    method: 'post',
    data: data
  });
};

/**
 * 修改文件夹管理
 * @param data
 */
export const updateFolder = (data: FolderForm) => {
  return request({
    url: '/document/folder',
    method: 'put',
    data: data
  });
};

/**
 * 删除文件夹管理
 * @param id
 */
export const delFolder = (id: string | number | Array<string | number>) => {
  return request({
    url: '/document/folder/' + id,
    method: 'delete'
  });
};

/**
 * 查询文件夹项目列表
 * @param query
 * @returns {*}
 */
export const listProject = (query?: ProjectQuery): AxiosPromise<ProjectVO[]> => {
  return request({
    url: '/document/folder/listProject',
    method: 'get',
    params: query
  });
};
