import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { DmsKnowledgeMaintVO, DmsKnowledgeMaintForm, DmsKnowledgeMaintQuery } from '@/api/dms/dmsKnowledgeMaint/types';

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

export const listDmsKnowledgeMaint = (query?: DmsKnowledgeMaintQuery): AxiosPromise<DmsKnowledgeMaintVO[]> => {
  return request({
    url: '/dms/dmsKnowledgeMaint/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询保养知识库详细
 * @param knowledgeMaintId
 */
export const getDmsKnowledgeMaint = (knowledgeMaintId: string | number): AxiosPromise<DmsKnowledgeMaintVO> => {
  return request({
    url: '/dms/dmsKnowledgeMaint/' + knowledgeMaintId,
    method: 'get'
  });
};

/**
 * 新增保养知识库
 * @param data
 */
export const addDmsKnowledgeMaint = (data: DmsKnowledgeMaintForm) => {
  return request({
    url: '/dms/dmsKnowledgeMaint',
    method: 'post',
    data: data
  });
};

/**
 * 修改保养知识库
 * @param data
 */
export const updateDmsKnowledgeMaint = (data: DmsKnowledgeMaintForm) => {
  return request({
    url: '/dms/dmsKnowledgeMaint',
    method: 'put',
    data: data
  });
};

/**
 * 删除保养知识库
 * @param knowledgeMaintId
 */
export const delDmsKnowledgeMaint = (knowledgeMaintId: string | number | Array<string | number>) => {
  return request({
    url: '/dms/dmsKnowledgeMaint/' + knowledgeMaintId,
    method: 'delete'
  });
};


/**
 * 下拉框查询保养知识库列表
 * @param query
 * @returns {*}
 */
export function getDmsKnowledgeMaintList (query) {
    return request({
        url: '/dms/dmsKnowledgeMaint/getDmsKnowledgeMaintList',
        method: 'get',
        params: query
    });
};
