import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { EmailtempForm, EmailtempQuery, EmailtempVO } from '@/api/msg/emailtemp/types';

/**
 * 查询申请、审核信息列表
 * @param query
 * @returns {*}
 */

export const listEmailAudit = (query?: EmailtempQuery): AxiosPromise<EmailtempVO[]> => {
  return request({
    url: '/msg/emailAudit/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询申请、审核信息详细
 * @param templateId
 */
export const getEmailAudit = (templateId: string | number): AxiosPromise<EmailtempVO> => {
  return request({
    url: '/msg/emailAudit/' + templateId,
    method: 'get'
  });
};

/**
 * 修改申请、审核信息
 * @param templateId
 */
export const updateEmailAuditPassed = (templateId: string | number) => {
  const data = {
    templateId
  };
  return request({
    url: '/msg/emailAudit/updateAuditPassed',
    method: 'post',
    data: data
  });
};

export const updateEmailAuditFailed = (data: EmailtempForm) => {
  return request({
    url: '/msg/emailAudit/updateAuditFailed',
    method: 'post',
    data: data
  });
};

/**
 * 删除申请、审核信息
 * @param auditId
 */
export const delEmailAudit = (auditId: string | number | Array<string | number>) => {
  return request({
    url: '/msg/emailAudit/' + auditId,
    method: 'delete'
  });
};
