import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { KnowledgeFragmentVO, KnowledgeFragmentForm, KnowledgeFragmentQuery } from '@/api/system/knowledgeFragment/types';

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