feat: 邮箱管理相关 api
parent
bca7938c6f
commit
ba82401cd4
|
@ -0,0 +1,78 @@
|
|||
import type { PageParam } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace SystemMailAccountApi {
|
||||
export interface MailAccountVO {
|
||||
id: number;
|
||||
mail: string;
|
||||
username: string;
|
||||
password: string;
|
||||
host: string;
|
||||
port: number;
|
||||
sslEnable: boolean;
|
||||
starttlsEnable: boolean;
|
||||
status: number;
|
||||
createTime: Date;
|
||||
remark: string;
|
||||
}
|
||||
}
|
||||
|
||||
// 查询邮箱账号列表
|
||||
export const getMailAccountPage = async (params: PageParam) => {
|
||||
return await requestClient.get<{
|
||||
list: SystemMailAccountApi.MailAccountVO[];
|
||||
total: number;
|
||||
}>('/system/mail-account/page', { params });
|
||||
};
|
||||
|
||||
// 查询邮箱账号详情
|
||||
export const getMailAccount = async (id: number) => {
|
||||
return await requestClient.get<SystemMailAccountApi.MailAccountVO>(
|
||||
'/system/mail-account/get',
|
||||
{
|
||||
params: { id },
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
// 新增邮箱账号
|
||||
export const createMailAccount = async (
|
||||
data: SystemMailAccountApi.MailAccountVO,
|
||||
) => {
|
||||
return await requestClient.post<SystemMailAccountApi.MailAccountVO>(
|
||||
'/system/mail-account/create',
|
||||
data,
|
||||
);
|
||||
};
|
||||
|
||||
// 修改邮箱账号
|
||||
export const updateMailAccount = async (
|
||||
data: SystemMailAccountApi.MailAccountVO,
|
||||
) => {
|
||||
return await requestClient.put<SystemMailAccountApi.MailAccountVO>(
|
||||
'/system/mail-account/update',
|
||||
data,
|
||||
);
|
||||
};
|
||||
|
||||
// 删除邮箱账号
|
||||
export const deleteMailAccount = async (id: number) => {
|
||||
return await requestClient.delete<boolean>('/system/mail-account/delete', {
|
||||
params: { id },
|
||||
});
|
||||
};
|
||||
|
||||
// 获得邮箱账号精简列表
|
||||
export const getSimpleMailAccountList = async () => {
|
||||
return await requestClient.get<SystemMailAccountApi.MailAccountVO[]>(
|
||||
'/system/mail-account/simple-list',
|
||||
);
|
||||
};
|
||||
|
||||
// 测试邮箱连接
|
||||
export const testMailAccount = async (id: number) => {
|
||||
return await requestClient.post<boolean>('/system/mail-account/test', null, {
|
||||
params: { id },
|
||||
});
|
||||
};
|
|
@ -0,0 +1,57 @@
|
|||
import type { PageParam } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace SystemMailLogApi {
|
||||
export interface MailLogVO {
|
||||
id: number;
|
||||
userId: number;
|
||||
userType: number;
|
||||
toMail: string;
|
||||
accountId: number;
|
||||
fromMail: string;
|
||||
templateId: number;
|
||||
templateCode: string;
|
||||
templateNickname: string;
|
||||
templateTitle: string;
|
||||
templateContent: string;
|
||||
templateParams: string;
|
||||
sendStatus: number;
|
||||
sendTime: Date;
|
||||
sendMessageId: string;
|
||||
sendException: string;
|
||||
createTime: Date;
|
||||
}
|
||||
}
|
||||
|
||||
// 查询邮件日志列表
|
||||
export const getMailLogPage = async (params: PageParam) => {
|
||||
return await requestClient.get<{
|
||||
list: SystemMailLogApi.MailLogVO[];
|
||||
total: number;
|
||||
}>('/system/mail-log/page', { params });
|
||||
};
|
||||
|
||||
// 查询邮件日志详情
|
||||
export const getMailLog = async (id: number) => {
|
||||
return await requestClient.get<SystemMailLogApi.MailLogVO>(
|
||||
'/system/mail-log/get',
|
||||
{
|
||||
params: { id },
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
// 重新发送邮件
|
||||
export const resendMail = async (id: number) => {
|
||||
return await requestClient.put<boolean>('/system/mail-log/resend', null, {
|
||||
params: { id },
|
||||
});
|
||||
};
|
||||
|
||||
// 批量删除邮件日志
|
||||
export const deleteMailLogs = async (ids: number[]) => {
|
||||
return await requestClient.delete<boolean>('/system/mail-log/delete', {
|
||||
data: { ids },
|
||||
});
|
||||
};
|
|
@ -0,0 +1,78 @@
|
|||
import type { PageParam } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace SystemMailTemplateApi {
|
||||
export interface MailTemplateVO {
|
||||
id: number;
|
||||
name: string;
|
||||
code: string;
|
||||
accountId: number;
|
||||
nickname: string;
|
||||
title: string;
|
||||
content: string;
|
||||
params: string;
|
||||
status: number;
|
||||
remark: string;
|
||||
createTime: Date;
|
||||
}
|
||||
|
||||
export interface MailSendReqVO {
|
||||
mail: string;
|
||||
templateCode: string;
|
||||
templateParams: Record<string, any>;
|
||||
}
|
||||
}
|
||||
|
||||
// 查询邮件模版列表
|
||||
export const getMailTemplatePage = async (params: PageParam) => {
|
||||
return await requestClient.get<{
|
||||
list: SystemMailTemplateApi.MailTemplateVO[];
|
||||
total: number;
|
||||
}>('/system/mail-template/page', { params });
|
||||
};
|
||||
|
||||
// 查询邮件模版详情
|
||||
export const getMailTemplate = async (id: number) => {
|
||||
return await requestClient.get<SystemMailTemplateApi.MailTemplateVO>(
|
||||
'/system/mail-template/get',
|
||||
{
|
||||
params: { id },
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
// 新增邮件模版
|
||||
export const createMailTemplate = async (
|
||||
data: SystemMailTemplateApi.MailTemplateVO,
|
||||
) => {
|
||||
return await requestClient.post<SystemMailTemplateApi.MailTemplateVO>(
|
||||
'/system/mail-template/create',
|
||||
data,
|
||||
);
|
||||
};
|
||||
|
||||
// 修改邮件模版
|
||||
export const updateMailTemplate = async (
|
||||
data: SystemMailTemplateApi.MailTemplateVO,
|
||||
) => {
|
||||
return await requestClient.put<SystemMailTemplateApi.MailTemplateVO>(
|
||||
'/system/mail-template/update',
|
||||
data,
|
||||
);
|
||||
};
|
||||
|
||||
// 删除邮件模版
|
||||
export const deleteMailTemplate = async (id: number) => {
|
||||
return await requestClient.delete<boolean>('/system/mail-template/delete', {
|
||||
params: { id },
|
||||
});
|
||||
};
|
||||
|
||||
// 发送邮件
|
||||
export const sendMail = async (data: SystemMailTemplateApi.MailSendReqVO) => {
|
||||
return await requestClient.post<boolean>(
|
||||
'/system/mail-template/send-mail',
|
||||
data,
|
||||
);
|
||||
};
|
Loading…
Reference in New Issue