import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MessageSettingVO, MessageSettingForm, MessageSettingQuery } from '@/api/setting/messageSetting/types';

/**
 * 查询短信设置列表
 * @param query
 * @returns {*}
 */

export const listMessageSetting = (query?: MessageSettingQuery): AxiosPromise<MessageSettingVO[]> => {
  return request({
    url: '/system/messageSetting/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询短信设置详细
 * @param id
 */
export const getMessageSetting = (id: string | number): AxiosPromise<MessageSettingVO> => {
  return request({
    url: '/system/messageSetting/' + id,
    method: 'get'
  });
};

/**
 * 新增短信设置
 * @param data
 */
export const addMessageSetting = (data: MessageSettingForm) => {
  return request({
    url: '/system/messageSetting',
    method: 'post',
    data: data
  });
};

/**
 * 修改短信设置
 * @param data
 */
export const updateMessageSetting = (data: MessageSettingForm) => {
  return request({
    url: '/system/messageSetting',
    method: 'put',
    data: data
  });
};

/**
 * 删除短信设置
 * @param id
 */
export const delMessageSetting = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/messageSetting/' + id,
    method: 'delete'
  });
};

export const getMsgSettingData = (): AxiosPromise<MessageSettingVO> => {
  return request({
    url: '/system/messageSetting/getOneMsgSetting',
    method: 'get'
  });
};
