import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { QuestionsConfigVO, QuestionsConfigForm, QuestionsConfigQuery } from '@/api/safety/questionsConfig/types';

/**
 * 查询题库配置列表
 * @param query
 * @returns {*}
 */

export const listQuestionsConfig = (query?: QuestionsConfigQuery): AxiosPromise<QuestionsConfigVO[]> => {
  return request({
    url: '/safety/questionsConfig/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询题库配置详细
 * @param id
 */
export const getQuestionsConfig = (id: string | number): AxiosPromise<QuestionsConfigVO> => {
  return request({
    url: '/safety/questionsConfig/' + id,
    method: 'get'
  });
};

/**
 * 新增题库配置
 * @param data
 */
export const addQuestionsConfig = (data: QuestionsConfigForm) => {
  return request({
    url: '/safety/questionsConfig',
    method: 'post',
    data: data
  });
};

/**
 * 修改题库配置
 * @param data
 */
export const updateQuestionsConfig = (data: QuestionsConfigForm) => {
  return request({
    url: '/safety/questionsConfig',
    method: 'put',
    data: data
  });
};

/**
 * 删除题库配置
 * @param id
 */
export const delQuestionsConfig = (id: string | number | Array<string | number>) => {
  return request({
    url: '/safety/questionsConfig/' + id,
    method: 'delete'
  });
};
