perf: 支持企业微信群聊机器人通知

This commit is contained in:
xiaojunnuo
2024-11-23 23:58:31 +08:00
parent 5450246f06
commit b805a29259
19 changed files with 163 additions and 41 deletions
@@ -3,7 +3,7 @@ import { BaseService, ValidateException } from '@certd/lib-server';
import { InjectEntityModel } from '@midwayjs/typeorm';
import { Repository } from 'typeorm';
import { NotificationEntity } from '../entity/notification.js';
import { notificationRegistry } from '@certd/pipeline';
import { NotificationInstanceConfig, notificationRegistry } from '@certd/pipeline';
@Provide()
@Scope(ScopeEnum.Singleton)
@@ -35,4 +35,29 @@ export class NotificationService extends BaseService<NotificationEntity> {
getDefineByType(type: string) {
return notificationRegistry.getDefine(type);
}
async getById(id: number, userId: number): Promise<NotificationInstanceConfig> {
if (!id) {
throw new ValidateException('id不能为空');
}
if (!userId) {
throw new ValidateException('userId不能为空');
}
const res = await this.repository.findOne({
where: {
id,
userId,
},
});
if (!res) {
throw new ValidateException('通知配置不存在');
}
const setting = JSON.parse(res.setting);
return {
id: res.id,
type: res.type,
userId: res.userId,
setting,
};
}
}