Files
certd/packages/ui/certd-server/src/controller/user/mine/email-controller.ts
T

52 lines
1.7 KiB
TypeScript
Raw Normal View History

2026-05-31 01:41:33 +08:00
import { Body, Controller, Inject, Post, Provide } from "@midwayjs/core";
import { BaseController } from "@certd/lib-server";
import { Constants } from "@certd/lib-server";
import { EmailService } from "../../../modules/basic/service/email-service.js";
import { ApiTags } from "@midwayjs/swagger";
2026-07-12 02:29:54 +08:00
import { AuditType } from "../../../modules/sys/enterprise/service/audit-constants.js";
2023-06-25 15:30:18 +08:00
/**
*/
@Provide()
2026-05-31 01:41:33 +08:00
@Controller("/api/mine/email")
@ApiTags(["mine"])
2023-06-25 15:30:18 +08:00
export class EmailController extends BaseController {
@Inject()
emailService: EmailService;
2026-07-12 02:29:54 +08:00
getAuditType(): string {
2026-07-13 00:53:19 +08:00
return AuditType.mine.value;
2026-07-12 02:29:54 +08:00
}
2026-05-31 01:41:33 +08:00
@Post("/test", { description: Constants.per.authOnly, summary: "测试邮件发送" })
public async test(@Body("receiver") receiver) {
2023-06-25 15:30:18 +08:00
const userId = super.getUserId();
await this.emailService.test(userId, receiver);
2026-07-12 02:29:54 +08:00
this.auditLog({ content: "测试了邮件发送" });
2023-06-25 15:30:18 +08:00
return this.ok({});
}
2025-05-31 00:45:54 +08:00
2026-05-31 01:41:33 +08:00
@Post("/list", { description: Constants.per.authOnly, summary: "查询邮件列表" })
2025-12-14 23:19:32 +08:00
public async list() {
const userId = super.getUserId();
const res = await this.emailService.list(userId);
return this.ok(res);
}
2025-05-31 00:45:54 +08:00
2026-05-31 01:41:33 +08:00
@Post("/add", { description: Constants.per.authOnly, summary: "添加邮件" })
public async add(@Body("email") email) {
2025-12-14 23:19:32 +08:00
const userId = super.getUserId();
await this.emailService.add(userId, email);
2026-07-12 02:29:54 +08:00
this.auditLog({ content: "添加了邮件" });
2025-12-14 23:19:32 +08:00
return this.ok({});
}
2025-05-31 00:45:54 +08:00
2026-05-31 01:41:33 +08:00
@Post("/delete", { description: Constants.per.authOnly, summary: "删除邮件" })
public async delete(@Body("email") email) {
2025-12-14 23:19:32 +08:00
const userId = super.getUserId();
await this.emailService.delete(userId, email);
2026-07-12 02:29:54 +08:00
this.auditLog({ content: "删除了邮件" });
2025-12-14 23:19:32 +08:00
return this.ok({});
}
2023-06-25 15:30:18 +08:00
}