70 lines
1.5 KiB
TypeScript
70 lines
1.5 KiB
TypeScript
import { Injectable } from "@nestjs/common";
|
|
import { ProConTextDto } from "src/_dto/procon/proconTexte.dto";
|
|
import { ProConAggregateEntity } from "src/_sql/procon.Aggregat.entity";
|
|
import { ProConTextEntity } from "src/_sql/procon.Texte.entity";
|
|
import { SqlService } from "src/infrastructure/sql/sql.service";
|
|
|
|
@Injectable()
|
|
export class TexteRepository {
|
|
|
|
constructor(
|
|
private readonly db: SqlService,
|
|
) { }
|
|
|
|
fields = [
|
|
"Id",
|
|
"Height",
|
|
"PositionX",
|
|
"PositionY",
|
|
"Width",
|
|
"Show",
|
|
"Discriminator",
|
|
"PositionZ",
|
|
"FontFamily",
|
|
"FontSize",
|
|
"FontWeight",
|
|
"Hintergrund",
|
|
"Nummer",
|
|
"TexteVisualisierung_Text",
|
|
"TextFarbe"
|
|
];
|
|
async findAll(anlageId: string): Promise<ProConTextEntity[]> {
|
|
const pool = await this.db.getPool(anlageId);
|
|
|
|
|
|
const result = await pool
|
|
.request()
|
|
.query(`
|
|
SELECT
|
|
${this.fields.join(',')}
|
|
|
|
FROM Visualisierungen
|
|
WHERE Discriminator='TexteVisualisierung'
|
|
`);
|
|
|
|
const data = result.recordset as ProConTextEntity[];
|
|
return data;
|
|
}
|
|
|
|
async findBy(anlageId: string, options: { id?: number, nummer?: number }): Promise<ProConTextDto | undefined> {
|
|
const pool = await this.db.getPool(anlageId);
|
|
|
|
let where = "";
|
|
if (options.id) where += `Id=${options.id}`;
|
|
if (options.nummer) where += `Nummer=${options.nummer}`;
|
|
|
|
if (where === "" || options.id && options.nummer) return undefined;
|
|
|
|
const result = await pool
|
|
.request()
|
|
.query(`
|
|
SELECT
|
|
${this.fields.join(',')}
|
|
FROM Visualisierungen
|
|
WHERE ${where}
|
|
`);
|
|
|
|
return result.recordset[0];
|
|
}
|
|
|
|
} |