This commit is contained in:
Bastian Wagner
2024-10-25 12:32:26 +02:00
parent d4f1fbbf39
commit b4e264eda9
40 changed files with 538 additions and 66 deletions

View File

@@ -1,5 +1,4 @@
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
import { CreateKeySystemDto } from 'src/model/dto';
import { Cylinder, Key, User } from 'src/model/entitites';
import { IUser } from 'src/model/interface';
import {
@@ -68,17 +67,6 @@ export class KeyService {
});
}
async createKeySystem(user: User, systemDTO: CreateKeySystemDto) {
const sys = this.systemRepo.create(systemDTO);
sys.managers = [user];
try {
const res = await this.systemRepo.save(sys);
return res;
} catch (e) {
throw new HttpException(e.code, HttpStatus.UNPROCESSABLE_ENTITY);
}
}
async handoverKey(user: IUser, data: any, keyID: string) {
const key: Key = await this.keyrepository.findOneOrFail({
where: { id: keyID, cylinder: { system: { managers: { id: user.id } } } },