Lost Keys

This commit is contained in:
Bastian Wagner
2025-01-03 13:39:47 +01:00
parent c8c2ee18cb
commit 92f0c10bd8
35 changed files with 569 additions and 42 deletions

View File

@@ -1,14 +1,17 @@
import { Injectable } from "@nestjs/common";
import { Inject, Injectable } from "@nestjs/common";
import { User, Cylinder, Key } from "src/model/entitites";
import { KeySystem } from "src/model/entitites/system.entity";
import { KeySystemRepository, CylinderRepository, KeyRepository } from "src/model/repositories";
import { Cache } from "@nestjs/cache-manager";
@Injectable()
export class ManageHelperService {
export class HelperService {
constructor(
private readonly systemRepository: KeySystemRepository,
private readonly cylinderRepository: CylinderRepository,
private readonly keyRepo: KeyRepository,
private cacheManager: Cache
) {}
@@ -35,4 +38,24 @@ export class ManageHelperService {
});
return keys;
}
async getSystemOfKey(key: Key): Promise<KeySystem> {
const k = await this.keyRepo.findOne({
where: { id: key.id },
relations: ['cylinder', 'cylinder.system'],
withDeleted: true,
});
this.cache()
const found = k.cylinder.find(c => c.system != null);
return found.system;
}
async cache() {
const value = await this.cacheManager.store.keys()
console.log(value)
}
async deleteKeyArchiveCache() {
await this.cacheManager.del('/key/archive');
}
}