Lost Keys
This commit is contained in:
@@ -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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user