74 lines
2.1 KiB
TypeScript
74 lines
2.1 KiB
TypeScript
import { Injectable } from "@nestjs/common";
|
|
import { ProConAggregateEntity } from "src/_sql/procon.Aggregat.entity";
|
|
import { ProConVisualisierungenAggEntity, ProConVisualisierungenEntity } from "src/_sql/procon.Visualisierung.entity";
|
|
import { SqlService } from "src/infrastructure/sql/sql.service";
|
|
|
|
@Injectable()
|
|
export class VisualisierungenRepository {
|
|
|
|
|
|
constructor(
|
|
private readonly db: SqlService,
|
|
) { }
|
|
|
|
async getVisuaOfAgg(anlage: string, aggId: number): Promise<ProConVisualisierungenAggEntity[]> {
|
|
const pool = await this.db.getPool(anlage);
|
|
|
|
let fields = `
|
|
Id,
|
|
Height,
|
|
PositionX,
|
|
PositionY,
|
|
Width,
|
|
Show,
|
|
Discriminator,
|
|
Text,
|
|
MainView,
|
|
AggregateId,
|
|
Number,
|
|
PositionZ`
|
|
const result = await pool.request().query(`SELECT ${fields} FROM Visualisierungen where AggregateId=${aggId}`);
|
|
|
|
return result.recordset;
|
|
}
|
|
|
|
async update(anlage: string, id: number, data: string[]) {
|
|
const pool = await this.db.getPool(anlage);
|
|
console.log(`UPDATE Visualisierungen SET ${data.join(',')} WHERE Id=${id}`);
|
|
const result = await pool.request().query(`UPDATE Visualisierungen SET ${data.join(',')} WHERE Id=${id}`);
|
|
|
|
return result;
|
|
}
|
|
|
|
async findAll(anlage: string) {
|
|
const pool = await this.db.getPool(anlage);
|
|
|
|
const result = await pool
|
|
.request()
|
|
.query("SELECT * FROM Visualisierungen where Id=19671");
|
|
|
|
const x: ProConVisualisierungenEntity = result.recordset[0];
|
|
const agg = await this.getAggregat(anlage,x.AggregateId);
|
|
return agg;
|
|
}
|
|
|
|
|
|
async getAggregate(anlage: string) {
|
|
const pool = await this.db.getPool(anlage);
|
|
const result = await pool.request().query("SELECT * FROM Aggregate ");
|
|
const r: ProConAggregateEntity[] = []
|
|
result.recordset.forEach(element => {
|
|
r.push(element)
|
|
});
|
|
return r;
|
|
}
|
|
|
|
async getAggregat(anlage: string, id: number): Promise<ProConAggregateEntity | undefined> {
|
|
const pool = await this.db.getPool(anlage);
|
|
const result = await pool.request().query(`SELECT * FROM Aggregate where SPSAntriebId=${id}`);
|
|
const r: ProConAggregateEntity = result.recordset[0];
|
|
return r;
|
|
}
|
|
|
|
|
|
} |