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

44 lines
1.4 KiB
TypeScript
Raw Normal View History

2024-07-15 00:30:33 +08:00
import { Body, Controller, Inject, Post, Provide } from '@midwayjs/core';
2024-10-03 22:03:49 +08:00
import { BaseController } from '@certd/lib-server';
import { Constants } from '@certd/lib-server';
2025-01-19 01:07:20 +08:00
import { EmailService } from '../../../modules/basic/service/email-service.js';
2026-03-15 14:01:34 +08:00
import { ApiTags } from '@midwayjs/swagger';
2023-06-25 15:30:18 +08:00
/**
*/
@Provide()
2025-01-19 01:07:20 +08:00
@Controller('/api/mine/email')
2026-03-15 14:01:34 +08:00
@ApiTags(['mine'])
2023-06-25 15:30:18 +08:00
export class EmailController extends BaseController {
@Inject()
emailService: EmailService;
2026-03-15 18:26:49 +08:00
@Post('/test', { description: Constants.per.authOnly, summary: "测试邮件发送" })
2024-12-11 11:30:32 +08:00
public async test(@Body('receiver') receiver) {
2023-06-25 15:30:18 +08:00
const userId = super.getUserId();
await this.emailService.test(userId, receiver);
return this.ok({});
}
2025-05-31 00:45:54 +08:00
2026-03-15 18:26:49 +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-03-15 18:26:49 +08:00
@Post('/add', { description: Constants.per.authOnly, summary: "添加邮件" })
2025-12-14 23:19:32 +08:00
public async add(@Body('email') email) {
const userId = super.getUserId();
await this.emailService.add(userId, email);
return this.ok({});
}
2025-05-31 00:45:54 +08:00
2026-03-15 18:26:49 +08:00
@Post('/delete', { description: Constants.per.authOnly, summary: "删除邮件" })
2025-12-14 23:19:32 +08:00
public async delete(@Body('email') email) {
const userId = super.getUserId();
await this.emailService.delete(userId, email);
return this.ok({});
}
2023-06-25 15:30:18 +08:00
}