2025-04-04 12:54:03 +08:00
|
|
|
import type { PageParam, PageResult } from '@vben/request';
|
2025-04-03 18:12:51 +08:00
|
|
|
|
|
|
|
|
import { requestClient } from '#/api/request';
|
|
|
|
|
|
|
|
|
|
export namespace SystemMailTemplateApi {
|
2025-04-04 12:54:03 +08:00
|
|
|
/** 邮件模版信息 */
|
|
|
|
|
export interface MailTemplate {
|
2025-04-03 18:12:51 +08:00
|
|
|
id: number;
|
|
|
|
|
name: string;
|
|
|
|
|
code: string;
|
|
|
|
|
accountId: number;
|
|
|
|
|
nickname: string;
|
|
|
|
|
title: string;
|
|
|
|
|
content: string;
|
2025-04-03 23:33:23 +08:00
|
|
|
params: string[];
|
2025-04-03 18:12:51 +08:00
|
|
|
status: number;
|
|
|
|
|
remark: string;
|
|
|
|
|
createTime: Date;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-04 12:54:03 +08:00
|
|
|
/** 邮件发送信息 */
|
|
|
|
|
export interface MailSendReq {
|
2025-04-03 18:12:51 +08:00
|
|
|
mail: string;
|
|
|
|
|
templateCode: string;
|
|
|
|
|
templateParams: Record<string, any>;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-04 12:54:03 +08:00
|
|
|
/** 查询邮件模版列表 */
|
|
|
|
|
export const getMailTemplatePage = async (params: PageParam) => {
|
2025-04-03 21:31:03 +08:00
|
|
|
return await requestClient.get<
|
2025-04-04 12:54:03 +08:00
|
|
|
PageResult<SystemMailTemplateApi.MailTemplate>
|
2025-04-03 21:31:03 +08:00
|
|
|
>('/system/mail-template/page', { params });
|
2025-04-03 18:12:51 +08:00
|
|
|
};
|
|
|
|
|
|
2025-04-04 12:54:03 +08:00
|
|
|
/** 查询邮件模版详情 */
|
2025-04-03 18:12:51 +08:00
|
|
|
export const getMailTemplate = async (id: number) => {
|
2025-04-04 12:54:03 +08:00
|
|
|
return await requestClient.get<SystemMailTemplateApi.MailTemplate>(
|
2025-04-03 18:12:51 +08:00
|
|
|
'/system/mail-template/get',
|
|
|
|
|
{
|
|
|
|
|
params: { id },
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2025-04-04 12:54:03 +08:00
|
|
|
/** 新增邮件模版 */
|
2025-04-03 18:12:51 +08:00
|
|
|
export const createMailTemplate = async (
|
2025-04-04 12:54:03 +08:00
|
|
|
data: SystemMailTemplateApi.MailTemplate,
|
2025-04-03 18:12:51 +08:00
|
|
|
) => {
|
2025-04-04 12:54:03 +08:00
|
|
|
return await requestClient.post<SystemMailTemplateApi.MailTemplate>(
|
2025-04-03 18:12:51 +08:00
|
|
|
'/system/mail-template/create',
|
|
|
|
|
data,
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2025-04-04 12:54:03 +08:00
|
|
|
/** 修改邮件模版 */
|
2025-04-03 18:12:51 +08:00
|
|
|
export const updateMailTemplate = async (
|
2025-04-04 12:54:03 +08:00
|
|
|
data: SystemMailTemplateApi.MailTemplate,
|
2025-04-03 18:12:51 +08:00
|
|
|
) => {
|
2025-04-04 12:54:03 +08:00
|
|
|
return await requestClient.put<SystemMailTemplateApi.MailTemplate>(
|
2025-04-03 18:12:51 +08:00
|
|
|
'/system/mail-template/update',
|
|
|
|
|
data,
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2025-04-04 12:54:03 +08:00
|
|
|
/** 删除邮件模版 */
|
2025-04-03 18:12:51 +08:00
|
|
|
export const deleteMailTemplate = async (id: number) => {
|
|
|
|
|
return await requestClient.delete<boolean>('/system/mail-template/delete', {
|
|
|
|
|
params: { id },
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2025-04-04 12:54:03 +08:00
|
|
|
/** 发送邮件 */
|
|
|
|
|
export const sendMail = async (data: SystemMailTemplateApi.MailSendReq) => {
|
2025-04-03 18:12:51 +08:00
|
|
|
return await requestClient.post<boolean>(
|
|
|
|
|
'/system/mail-template/send-mail',
|
|
|
|
|
data,
|
|
|
|
|
);
|
|
|
|
|
};
|