import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { KnowledgeAttachVO, KnowledgeAttachForm, KnowledgeAttachQuery } from '@/api/system/knowledgeAttach/types';

/**
 * 查询知识库附件列表
 * @param query
 * @returns {*}
 */

export const listKnowledgeAttach = (query?: KnowledgeAttachQuery): AxiosPromise<KnowledgeAttachVO[]> => {
  return request({
    url: '/system/knowledgeAttach/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询知识库附件详细
 * @param id
 */
export const getKnowledgeAttach = (id: string | number): AxiosPromise<KnowledgeAttachVO> => {
  return request({
    url: '/system/knowledgeAttach/' + id,
    method: 'get'
  });
};

/**
 * 新增知识库附件
 * @param data
 */
export const addKnowledgeAttach = (data: KnowledgeAttachForm) => {
  return request({
    url: '/system/knowledgeAttach',
    method: 'post',
    data: data
  });
};

/**
 * 修改知识库附件
 * @param data
 */
export const updateKnowledgeAttach = (data: KnowledgeAttachForm) => {
  return request({
    url: '/system/knowledgeAttach',
    method: 'put',
    data: data
  });
};

/**
 * 删除知识库附件
 * @param id
 */
export const delKnowledgeAttach = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/knowledgeAttach/' + id,
    method: 'delete'
  });
};
