Schließanlagen können gelöscht werden
This commit is contained in:
@@ -7,6 +7,7 @@ import { IUser } from 'src/model/interface';
|
||||
import { MailService } from '../mail/mail.service';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { ActivityHelperService } from 'src/shared/service/activity.logger.service';
|
||||
import { IsNull, Not } from 'typeorm';
|
||||
|
||||
@Injectable()
|
||||
export class SystemService {
|
||||
@@ -56,6 +57,20 @@ export class SystemService {
|
||||
return systems;
|
||||
}
|
||||
|
||||
async findDeleted(user: User) {
|
||||
let systems = await this.systemRepo.find({
|
||||
where: { managers: { id: user.id }, deletedAt: Not(IsNull()) },
|
||||
order: { name: { direction: 'ASC' } },
|
||||
withDeleted: true,
|
||||
});
|
||||
|
||||
if (this.isDevelopMode) {
|
||||
systems = systems.filter(s => s.name.toLocaleLowerCase().includes('develop'));
|
||||
}
|
||||
|
||||
return systems;
|
||||
}
|
||||
|
||||
findOne(id: string) {
|
||||
return this.systemRepo.findOne({ where: { id: id } });
|
||||
}
|
||||
@@ -136,4 +151,15 @@ export class SystemService {
|
||||
return sys.managers;
|
||||
|
||||
}
|
||||
|
||||
async restore(user: User, id: string) {
|
||||
const key = await this.systemRepo.findOneOrFail({
|
||||
where: { id: id, managers: { id: user.id } },
|
||||
withDeleted: true,
|
||||
});
|
||||
key.deletedAt = null;
|
||||
// await this.activityService.logKeyRestored(user, key);
|
||||
// await this.helper.deleteKeyArchiveCache();
|
||||
return this.systemRepo.save(key);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user