import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { KnowledgeInfoVO, KnowledgeInfoForm, KnowledgeInfoQuery } from '@/api/system/knowledgeInfo/types';
import {KnowledgeAttachForm, KnowledgeAttachQuery, KnowledgeAttachVO} from "@/api/system/knowledgeAttach/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'
  });
};
/**
 * 查询知识片段列表
 * @param query
 * @returns {*}
 */

export const listKnowledgeFragment = (query?: KnowledgeFragmentQuery): AxiosPromise<KnowledgeFragmentVO[]> => {
  return request({
    url: '/system/knowledgeFragment/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询知识片段详细
 * @param id
 */
export const getKnowledgeFragment = (id: string | number): AxiosPromise<KnowledgeFragmentVO> => {
  return request({
    url: '/system/knowledgeFragment/' + id,
    method: 'get'
  });
};

/**
 * 新增知识片段
 * @param data
 */
export const addKnowledgeFragment = (data: KnowledgeFragmentForm) => {
  return request({
    url: '/system/knowledgeFragment',
    method: 'post',
    data: data
  });
};

/**
 * 修改知识片段
 * @param data
 */
export const updateKnowledgeFragment = (data: KnowledgeFragmentForm) => {
  return request({
    url: '/system/knowledgeFragment',
    method: 'put',
    data: data
  });
};

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

/**
 * 查询知识库附件列表
 * @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'
  });
};