import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { SmsConfigVO, SmsConfigForm, SmsConfigQuery, ControlStatusVO } from '@/api/business/smsConfig/types';

/**
 * 查询课件短信配置列表
 * @param query
 * @returns {*}
 */

export const listSmsConfig = (query?: SmsConfigQuery): AxiosPromise<SmsConfigVO[]> => {
  return request({
    url: '/business/smsConfig/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询课件短信配置详细
 * @param id
 */
export const getSmsConfig = (id: string | number): AxiosPromise<SmsConfigVO> => {
  return request({
    url: '/business/smsConfig/' + id,
    method: 'get'
  });
};

/**
 * 新增课件短信配置
 * @param data
 */
export const addSmsConfig = (data: SmsConfigForm) => {
  return request({
    url: '/business/smsConfig',
    method: 'post',
    data: data
  });
};

/**
 * 修改课件短信配置
 * @param data
 */
export const updateSmsConfig = (data: SmsConfigForm) => {
  return request({
    url: '/business/smsConfig',
    method: 'put',
    data: data
  });
};

/**
 * 删除课件短信配置
 * @param id
 */
export const delSmsConfig = (id: string | number | Array<string | number>) => {
  return request({
    url: '/business/smsConfig/' + id,
    method: 'delete'
  });
};


/**
 * 启用/禁用状态
 * @param data
 */
export const controlStatus = (data: ControlStatusVO) => {
  return request({
    url: '/business/smsConfig',
    method: 'put',
    data: data
  });
};

/**
 * 初始化短信设置
 */
export const initSmsConfig = () => {
  return request({
    url: '/business/smsConfig/init',
    method: 'get'
  });
};
