fix: 修复编辑通知勾选默认,导致出现多个默认通知的bug

pull/361/head
xiaojunnuo 2025-03-26 12:06:20 +08:00
parent c3c5006daa
commit 6cd7bddc37
1 changed files with 17 additions and 0 deletions

View File

@ -45,6 +45,23 @@ export class NotificationService extends BaseService<NotificationEntity> {
return notificationRegistry.getDefine(type);
}
async add(bean: NotificationEntity) {
const res = await super.add(bean);
if(bean.isDefault){
await this.setDefault(res.id, bean.userId);
}
return res
}
async update(bean: NotificationEntity) {
const res = await super.update(bean);
if(bean.isDefault){
const old = await this.info(bean.id);
await this.setDefault(bean.id, old.userId);
}
return res
}
async getById(id: number, userId: number): Promise<NotificationInstanceConfig> {
if (!id) {
throw new ValidateException('id不能为空');