docs
This commit is contained in:
@@ -13,7 +13,6 @@ export class SystemService {
|
|||||||
constructor(
|
constructor(
|
||||||
private systemRepo: KeySystemRepository,
|
private systemRepo: KeySystemRepository,
|
||||||
private userRepo: UserRepository,
|
private userRepo: UserRepository,
|
||||||
// private systemActivityRepo: ActivityRepository,
|
|
||||||
private mailService: MailService,
|
private mailService: MailService,
|
||||||
private readonly configService: ConfigService,
|
private readonly configService: ConfigService,
|
||||||
private readonly activityService: ActivityHelperService
|
private readonly activityService: ActivityHelperService
|
||||||
@@ -66,7 +65,6 @@ export class SystemService {
|
|||||||
return this.systemRepo.findOne({ where: { id: id } });
|
return this.systemRepo.findOne({ where: { id: id } });
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
||||||
async update(user: User, updateSystemDto: UpdateSystemDto) {
|
async update(user: User, updateSystemDto: UpdateSystemDto) {
|
||||||
if (!user || !user.id || !updateSystemDto.id) { throw new HttpException('forbidden', HttpStatus.FORBIDDEN); }
|
if (!user || !user.id || !updateSystemDto.id) { throw new HttpException('forbidden', HttpStatus.FORBIDDEN); }
|
||||||
const system = await this.systemRepo.findOne({ where: { id: updateSystemDto.id, managers: { id: user.id } }, withDeleted: true });
|
const system = await this.systemRepo.findOne({ where: { id: updateSystemDto.id, managers: { id: user.id } }, withDeleted: true });
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ export class ActivityHelperService {
|
|||||||
async logCylinderRestored(user: User, cylinder: Cylinder) {
|
async logCylinderRestored(user: User, cylinder: Cylinder) {
|
||||||
let msg = `Zylinder ${cylinder.name} wiederhergestellt`;
|
let msg = `Zylinder ${cylinder.name} wiederhergestellt`;
|
||||||
|
|
||||||
const system: KeySystem = await this.helper.getSystemOCylinder(cylinder);
|
const system: KeySystem = await this.helper.getSystemOfCylinder(cylinder);
|
||||||
|
|
||||||
this.activityRepo.save(
|
this.activityRepo.save(
|
||||||
this.activityRepo.create({
|
this.activityRepo.create({
|
||||||
@@ -142,7 +142,7 @@ export class ActivityHelperService {
|
|||||||
|
|
||||||
async logCylinderCreated(user: User, cylinder: Cylinder) {
|
async logCylinderCreated(user: User, cylinder: Cylinder) {
|
||||||
const msg = `Zylinder ${cylinder.name} angelegt`;
|
const msg = `Zylinder ${cylinder.name} angelegt`;
|
||||||
const system: KeySystem = await this.helper.getSystemOCylinder(cylinder);
|
const system: KeySystem = await this.helper.getSystemOfCylinder(cylinder);
|
||||||
this.activityRepo.save(
|
this.activityRepo.save(
|
||||||
this.activityRepo.create({
|
this.activityRepo.create({
|
||||||
system,
|
system,
|
||||||
@@ -154,7 +154,7 @@ export class ActivityHelperService {
|
|||||||
async logCylinderDeleted(user: User, cylinder: Cylinder) {
|
async logCylinderDeleted(user: User, cylinder: Cylinder) {
|
||||||
let msg = `Zylinder ${cylinder.name} gelöscht`;
|
let msg = `Zylinder ${cylinder.name} gelöscht`;
|
||||||
|
|
||||||
const system: KeySystem = await this.helper.getSystemOCylinder(cylinder);
|
const system: KeySystem = await this.helper.getSystemOfCylinder(cylinder);
|
||||||
|
|
||||||
this.activityRepo.save(
|
this.activityRepo.save(
|
||||||
this.activityRepo.create({
|
this.activityRepo.create({
|
||||||
|
|||||||
@@ -39,6 +39,11 @@ export class HelperService {
|
|||||||
return keys;
|
return keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sucht das System eines Schlüssels und gibt es als Promise zurück
|
||||||
|
* @param key key
|
||||||
|
* @returns system: KeySystem
|
||||||
|
*/
|
||||||
async getSystemOfKey(key: Key): Promise<KeySystem> {
|
async getSystemOfKey(key: Key): Promise<KeySystem> {
|
||||||
const k = await this.keyRepo.findOne({
|
const k = await this.keyRepo.findOne({
|
||||||
where: { id: key.id },
|
where: { id: key.id },
|
||||||
@@ -50,7 +55,12 @@ export class HelperService {
|
|||||||
return found.system;
|
return found.system;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getSystemOCylinder(cylinder: Cylinder): Promise<KeySystem> {
|
/**
|
||||||
|
* Gibt das System eines Zylinders und gibt es als Promise zurück
|
||||||
|
* @param cylinder Zylinder
|
||||||
|
* @returns Promise<KeySystem>
|
||||||
|
*/
|
||||||
|
async getSystemOfCylinder(cylinder: Cylinder): Promise<KeySystem> {
|
||||||
const k = await this.cylinderRepository.findOne({
|
const k = await this.cylinderRepository.findOne({
|
||||||
where: { id: cylinder.id },
|
where: { id: cylinder.id },
|
||||||
relations: ['system'],
|
relations: ['system'],
|
||||||
|
|||||||
Reference in New Issue
Block a user