import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { KnowledgeInfoVO, KnowledgeInfoForm, KnowledgeInfoQuery } from '@/api/system/knowledgeInfo/types';

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

export const listKnowledgeInfo = (query?: KnowledgeInfoQuery): AxiosPromise<KnowledgeInfoVO[]> => {
  return request({
    url: '/system/knowledgeInfo/list',
    method: 'get',
    params: query
  });
};

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

/**
 * 新增知识库
 * @param data
 */
export const addKnowledgeInfo = (data: KnowledgeInfoForm) => {
  return request({
    url: '/system/knowledgeInfo',
    method: 'post',
    data: data
  });
};

/**
 * 修改知识库
 * @param data
 */
export const updateKnowledgeInfo = (data: KnowledgeInfoForm) => {
  return request({
    url: '/system/knowledgeInfo',
    method: 'put',
    data: data
  });
};

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