Phase 1A done

This commit is contained in:
2026-05-03 21:16:52 +02:00
parent 49190c5d7e
commit b8995b3a1b
21 changed files with 1038 additions and 3 deletions
+50
View File
@@ -0,0 +1,50 @@
import crypto from "node:crypto";
import { asc, eq } from "drizzle-orm";
import { db } from "../client.js";
import { circuits } from "../schema/circuits.js";
export class CircuitRepository {
async listByCircuitList(circuitListId: string) {
return db
.select()
.from(circuits)
.where(eq(circuits.circuitListId, circuitListId))
.orderBy(asc(circuits.sortOrder), asc(circuits.equipmentIdentifier));
}
async create(input: {
circuitListId: string;
sectionId: string;
equipmentIdentifier: string;
displayName?: string;
sortOrder: number;
protectionType?: string;
protectionRatedCurrent?: number;
protectionCharacteristic?: string;
cableType?: string;
cableCrossSection?: string;
cableLength?: number;
voltage?: number;
remark?: string;
}) {
const id = crypto.randomUUID();
await db.insert(circuits).values({
id,
circuitListId: input.circuitListId,
sectionId: input.sectionId,
equipmentIdentifier: input.equipmentIdentifier,
displayName: input.displayName ?? null,
sortOrder: input.sortOrder,
protectionType: input.protectionType ?? null,
protectionRatedCurrent: input.protectionRatedCurrent ?? null,
protectionCharacteristic: input.protectionCharacteristic ?? null,
cableType: input.cableType ?? null,
cableCrossSection: input.cableCrossSection ?? null,
cableLength: input.cableLength ?? null,
voltage: input.voltage ?? null,
remark: input.remark ?? null,
});
return id;
}
}