import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ReviewVO, ReviewForm, ReviewQuery } from '@/api/msg/review/types';

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

export const listReview = (query?: ReviewQuery): AxiosPromise<ReviewVO[]> => {
  return request({
    url: '/msg/review/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询短信模板配置详细
 * @param templateId
 */
export const getReview = (templateId: string | number): AxiosPromise<ReviewVO> => {
  return request({
    url: '/msg/review/' + templateId,
    method: 'get'
  });
};

/**
 * 新增短信模板配置
 * @param data
 */
export const addReview = (data: ReviewForm) => {
  return request({
    url: '/msg/review',
    method: 'post',
    data: data
  });
};

/**
 * 修改短信模板配置
 * @param data
 */
export const updateReview = (data: ReviewForm) => {
  return request({
    url: '/msg/review',
    method: 'put',
    data: data
  });
};

/**
 * 删除短信模板配置
 * @param templateId
 */
export const delReview = (templateId: string | number | Array<string | number>) => {
  return request({
    url: '/msg/review/' + templateId,
    method: 'delete'
  });
};
/**
 * 审核通过
 */
export const approvedMsgtemp = (templateId: string | number) => {
  const data = {
    templateId
  };
  return request({
    url: '/msg/review/approved',
    method: 'post',
    data: data
  });
};


/**
 * 审核回退
 *
 */
export const rejectedMsgtemp = (data: ReviewForm) =>{
  return request({
    url: '/msg/review/rejected',
    method: 'post',
    data: data
  });
};
