import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { VersionVO, VersionForm, VersionQuery } from '@/api/msg/version/types';

/**
 * 查询短信模板版本管理列表
 * @param query
 * @returns {*}
 */

export const listVersion = (query?: VersionQuery): AxiosPromise<VersionVO[]> => {
  return request({
    url: '/msg/version/list',
    method: 'get',
    params: query
  });
};
export const listVersionByAudit = (query?: VersionQuery): AxiosPromise<VersionVO[]> => {
  return request({
    url: '/msg/version/listbyAudit',
    method: 'get',
    params: query
  });
};

/**
 * 查询短信模板版本管理详细
 * @param templateId
 */
export const getVersion = (templateId: string | number): AxiosPromise<VersionVO> => {
  return request({
    url: '/msg/version/' + templateId,
    method: 'get'
  });
};

/**
 * 新增短信模板版本管理
 * @param data
 */
export const addVersion = (data: VersionForm) => {
  return request({
    url: '/msg/version',
    method: 'post',
    data: data
  });
};

/**
 * 修改短信模板版本管理
 * @param data
 */
export const updateVersion = (data: VersionForm) => {
  return request({
    url: '/msg/version',
    method: 'put',
    data: data
  });
};

/**
 * 删除短信模板版本管理
 * @param templateId
 */
export const delVersion = (templateId: string | number | Array<string | number>) => {
  return request({
    url: '/msg/version/' + templateId,
    method: 'delete'
  });
};

export const changeMesVsersionStatus = (data) => {
  return request({
    url: '/msg/version/status',
    method: 'post',
    data: data
  });
};
export const getStatusApply = (data) => {
  return request({
    url: '/msg/version/getApply',
    method: 'post',
    data: data
  });
};

export const changeStatusApprove = (data) => {
  return request({
    url: '/msg/version/approve',
    method: 'post',
    data: data
  });
};

export const changeMesStatusApply = (data) => {
  return request({
    url: '/msg/version/apply',
    method: 'post',
    data: data
  });
};

export const getSmsSendChannels = () => {
  return request({
    url: '/msg/mestemp/smsSendChannels',
    method: 'post'
  });
};

export const saveSendChannels = (data) => {
  return request({
    url: '/msg/mestemp/saveSendChannels',
    method: 'post',
    data: data
  });
};
