41 lines
1.4 KiB
TypeScript
41 lines
1.4 KiB
TypeScript
import { Injectable, NotFoundException } from '@nestjs/common';
|
|
import { AggregateRepository } from './aggregate.repository';
|
|
import { VisualisierungenService } from '../visualisierungen/visualisierungen.service';
|
|
|
|
@Injectable()
|
|
export class AggregateService {
|
|
anlage ="testXXX"
|
|
constructor(
|
|
private readonly repo: AggregateRepository,
|
|
private readonly visuService:VisualisierungenService
|
|
) { }
|
|
|
|
async getAllAggregate(){
|
|
return this.repo.findAll(this.anlage)
|
|
}
|
|
|
|
async getVisualisierungen(id: number) {
|
|
const aggregat = await this.repo.findBy(this.anlage, { id });
|
|
if (!aggregat) throw new NotFoundException('Aggregat nicht gefunden');
|
|
return { aggregat, visualisierungen: await this.visuService.getVisuaWithXamlNames(aggregat.Id) };
|
|
}
|
|
|
|
async getById(id:number){
|
|
const agg = await this.repo.findBy(this.anlage,{id:id});
|
|
if(!agg) return {success:false,error:"Aggregat nicht gefunden"}
|
|
console.log(agg)
|
|
const visu = await this.visuService.getAllVisuaAggData(agg);
|
|
return visu;
|
|
}
|
|
|
|
async getByAntriebsId(id:number){
|
|
//return this.repo.findBy(this.anlage,{SPSAntriebId:id});
|
|
const agg = await this.repo.findBy(this.anlage,{SPSAntriebId:id});
|
|
if(!agg) return {success:false,error:"Aggregat nicht gefunden"}
|
|
console.log(agg)
|
|
const visu = await this.visuService.getAllVisuaAggData(agg);
|
|
return visu;
|
|
}
|
|
|
|
}
|