perf: 优化证书申请成功通知发送方式

This commit is contained in:
xiaojunnuo
2024-11-27 12:36:28 +08:00
parent 7e5ea0cee0
commit 8002a56efc
24 changed files with 382 additions and 42 deletions

View File

@@ -69,7 +69,7 @@ export class HandleController extends BaseController {
// }
// }
const notification = newNotification(body.typeName, input, {
const notification = await newNotification(body.typeName, input, {
http,
logger,
utils,

View File

@@ -1,5 +1,5 @@
import { ALL, Body, Controller, Inject, Post, Provide, Query } from '@midwayjs/core';
import { Constants, CrudController } from '@certd/lib-server';
import { Constants, CrudController, ValidateException } from '@certd/lib-server';
import { NotificationService } from '../../modules/pipeline/service/notification-service.js';
import { AuthService } from '../../modules/sys/authority/service/auth-service.js';
@@ -84,8 +84,30 @@ export class NotificationController extends CrudController<NotificationService>
@Post('/simpleInfo', { summary: Constants.per.authOnly })
async simpleInfo(@Query('id') id: number) {
if (id === 0) {
//获取默认
const res = await this.service.getDefault(this.getUserId());
if (!res) {
throw new ValidateException('默认通知配置不存在');
}
const simple = await this.service.getSimpleInfo(res.id);
return this.ok(simple);
}
await this.authService.checkEntityUserId(this.ctx, this.service, id);
const res = await this.service.getSimpleInfo(id);
return this.ok(res);
}
@Post('/getDefaultId', { summary: Constants.per.authOnly })
async getDefaultId() {
const res = await this.service.getDefault(this.getUserId());
return this.ok(res?.id);
}
@Post('/setDefault', { summary: Constants.per.authOnly })
async setDefault(@Query('id') id: number) {
await this.service.checkUserId(id, this.getUserId());
const res = await this.service.setDefault(id, this.getUserId());
return this.ok(res);
}
}