mirror of
https://github.com/certd/certd.git
synced 2026-04-24 12:27:25 +08:00
fix: 修复编辑通知勾选默认,导致出现多个默认通知的bug
This commit is contained in:
@@ -45,6 +45,23 @@ export class NotificationService extends BaseService<NotificationEntity> {
|
|||||||
return notificationRegistry.getDefine(type);
|
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> {
|
async getById(id: number, userId: number): Promise<NotificationInstanceConfig> {
|
||||||
if (!id) {
|
if (!id) {
|
||||||
throw new ValidateException('id不能为空');
|
throw new ValidateException('id不能为空');
|
||||||
|
|||||||
Reference in New Issue
Block a user