feat(site): add contact fields

This commit is contained in:
Matthieu
2025-09-17 11:13:19 +02:00
parent e8aeaf98e9
commit 7671d4729d
8 changed files with 156 additions and 46 deletions

View File

@@ -1,8 +1,16 @@
export declare class CreateSiteDto {
name: string;
description?: string;
contactName: string;
contactPhone: string;
contactAddress: string;
contactPostalCode: string;
contactCity: string;
}
export declare class UpdateSiteDto {
name?: string;
description?: string;
contactName?: string;
contactPhone?: string;
contactAddress?: string;
contactPostalCode?: string;
contactCity?: string;
}

View File

@@ -13,7 +13,11 @@ exports.UpdateSiteDto = exports.CreateSiteDto = void 0;
const class_validator_1 = require("class-validator");
class CreateSiteDto {
name;
description;
contactName;
contactPhone;
contactAddress;
contactPostalCode;
contactCity;
}
exports.CreateSiteDto = CreateSiteDto;
__decorate([
@@ -21,13 +25,32 @@ __decorate([
__metadata("design:type", String)
], CreateSiteDto.prototype, "name", void 0);
__decorate([
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.IsString)(),
__metadata("design:type", String)
], CreateSiteDto.prototype, "description", void 0);
], CreateSiteDto.prototype, "contactName", void 0);
__decorate([
(0, class_validator_1.IsString)(),
__metadata("design:type", String)
], CreateSiteDto.prototype, "contactPhone", void 0);
__decorate([
(0, class_validator_1.IsString)(),
__metadata("design:type", String)
], CreateSiteDto.prototype, "contactAddress", void 0);
__decorate([
(0, class_validator_1.IsString)(),
__metadata("design:type", String)
], CreateSiteDto.prototype, "contactPostalCode", void 0);
__decorate([
(0, class_validator_1.IsString)(),
__metadata("design:type", String)
], CreateSiteDto.prototype, "contactCity", void 0);
class UpdateSiteDto {
name;
description;
contactName;
contactPhone;
contactAddress;
contactPostalCode;
contactCity;
}
exports.UpdateSiteDto = UpdateSiteDto;
__decorate([
@@ -39,5 +62,25 @@ __decorate([
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.IsString)(),
__metadata("design:type", String)
], UpdateSiteDto.prototype, "description", void 0);
], UpdateSiteDto.prototype, "contactName", void 0);
__decorate([
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.IsString)(),
__metadata("design:type", String)
], UpdateSiteDto.prototype, "contactPhone", void 0);
__decorate([
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.IsString)(),
__metadata("design:type", String)
], UpdateSiteDto.prototype, "contactAddress", void 0);
__decorate([
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.IsString)(),
__metadata("design:type", String)
], UpdateSiteDto.prototype, "contactPostalCode", void 0);
__decorate([
(0, class_validator_1.IsOptional)(),
(0, class_validator_1.IsString)(),
__metadata("design:type", String)
], UpdateSiteDto.prototype, "contactCity", void 0);
//# sourceMappingURL=site.dto.js.map

View File

@@ -1 +1 @@
{"version":3,"file":"site.dto.js","sourceRoot":"","sources":["../../../src/shared/dto/site.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAuD;AAEvD,MAAa,aAAa;IAExB,IAAI,CAAS;IAIb,WAAW,CAAU;CACtB;AAPD,sCAOC;AALC;IADC,IAAA,0BAAQ,GAAE;;2CACE;AAIb;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;kDACU;AAGvB,MAAa,aAAa;IAGxB,IAAI,CAAU;IAId,WAAW,CAAU;CACtB;AARD,sCAQC;AALC;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;2CACG;AAId;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;kDACU"}
{"version":3,"file":"site.dto.js","sourceRoot":"","sources":["../../../src/shared/dto/site.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAuD;AAEvD,MAAa,aAAa;IAExB,IAAI,CAAS;IAGb,WAAW,CAAS;IAGpB,YAAY,CAAS;IAGrB,cAAc,CAAS;IAGvB,iBAAiB,CAAS;IAG1B,WAAW,CAAS;CACrB;AAlBD,sCAkBC;AAhBC;IADC,IAAA,0BAAQ,GAAE;;2CACE;AAGb;IADC,IAAA,0BAAQ,GAAE;;kDACS;AAGpB;IADC,IAAA,0BAAQ,GAAE;;mDACU;AAGrB;IADC,IAAA,0BAAQ,GAAE;;qDACY;AAGvB;IADC,IAAA,0BAAQ,GAAE;;wDACe;AAG1B;IADC,IAAA,0BAAQ,GAAE;;kDACS;AAGtB,MAAa,aAAa;IAGxB,IAAI,CAAU;IAId,WAAW,CAAU;IAIrB,YAAY,CAAU;IAItB,cAAc,CAAU;IAIxB,iBAAiB,CAAU;IAI3B,WAAW,CAAU;CACtB;AAxBD,sCAwBC;AArBC;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;2CACG;AAId;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;kDACU;AAIrB;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;mDACW;AAItB;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;qDACa;AAIxB;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;wDACgB;AAI3B;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;kDACU"}

View File

@@ -4,20 +4,24 @@ export declare class SitesService {
private prisma;
constructor(prisma: PrismaService);
create(createSiteDto: CreateSiteDto): Promise<{
name: string;
description: string | null;
id: string;
name: string;
contactName: string;
contactPhone: string;
contactAddress: string;
contactPostalCode: string;
contactCity: string;
createdAt: Date;
updatedAt: Date;
}>;
findAll(): Promise<({
machines: ({
typeMachine: {
name: string;
description: string | null;
id: string;
name: string;
createdAt: Date;
updatedAt: Date;
description: string | null;
category: string | null;
maintenanceFrequency: string | null;
components: import("@prisma/client/runtime/library").JsonValue | null;
@@ -26,8 +30,8 @@ export declare class SitesService {
specifications: import("@prisma/client/runtime/library").JsonValue | null;
} | null;
pieces: {
name: string;
id: string;
name: string;
createdAt: Date;
updatedAt: Date;
reference: string | null;
@@ -40,15 +44,15 @@ export declare class SitesService {
}[];
composants: ({
typeComposant: {
name: string;
description: string | null;
id: string;
name: string;
createdAt: Date;
updatedAt: Date;
description: string | null;
} | null;
pieces: {
name: string;
id: string;
name: string;
createdAt: Date;
updatedAt: Date;
reference: string | null;
@@ -60,8 +64,8 @@ export declare class SitesService {
typePieceId: string | null;
}[];
sousComposants: {
name: string;
id: string;
name: string;
createdAt: Date;
updatedAt: Date;
reference: string | null;
@@ -69,12 +73,12 @@ export declare class SitesService {
prix: import("@prisma/client/runtime/library").Decimal | null;
emplacement: string | null;
machineId: string | null;
parentComposantId: string | null;
typeComposantId: string | null;
parentComposantId: string | null;
}[];
} & {
name: string;
id: string;
name: string;
createdAt: Date;
updatedAt: Date;
reference: string | null;
@@ -82,12 +86,12 @@ export declare class SitesService {
prix: import("@prisma/client/runtime/library").Decimal | null;
emplacement: string | null;
machineId: string | null;
parentComposantId: string | null;
typeComposantId: string | null;
parentComposantId: string | null;
})[];
} & {
name: string;
id: string;
name: string;
createdAt: Date;
updatedAt: Date;
reference: string | null;
@@ -98,20 +102,24 @@ export declare class SitesService {
typeMachineId: string | null;
})[];
} & {
name: string;
description: string | null;
id: string;
name: string;
contactName: string;
contactPhone: string;
contactAddress: string;
contactPostalCode: string;
contactCity: string;
createdAt: Date;
updatedAt: Date;
})[]>;
findOne(id: string): Promise<({
machines: ({
typeMachine: {
name: string;
description: string | null;
id: string;
name: string;
createdAt: Date;
updatedAt: Date;
description: string | null;
category: string | null;
maintenanceFrequency: string | null;
components: import("@prisma/client/runtime/library").JsonValue | null;
@@ -120,8 +128,8 @@ export declare class SitesService {
specifications: import("@prisma/client/runtime/library").JsonValue | null;
} | null;
pieces: {
name: string;
id: string;
name: string;
createdAt: Date;
updatedAt: Date;
reference: string | null;
@@ -134,15 +142,15 @@ export declare class SitesService {
}[];
composants: ({
typeComposant: {
name: string;
description: string | null;
id: string;
name: string;
createdAt: Date;
updatedAt: Date;
description: string | null;
} | null;
pieces: {
name: string;
id: string;
name: string;
createdAt: Date;
updatedAt: Date;
reference: string | null;
@@ -154,8 +162,8 @@ export declare class SitesService {
typePieceId: string | null;
}[];
sousComposants: {
name: string;
id: string;
name: string;
createdAt: Date;
updatedAt: Date;
reference: string | null;
@@ -163,12 +171,12 @@ export declare class SitesService {
prix: import("@prisma/client/runtime/library").Decimal | null;
emplacement: string | null;
machineId: string | null;
parentComposantId: string | null;
typeComposantId: string | null;
parentComposantId: string | null;
}[];
} & {
name: string;
id: string;
name: string;
createdAt: Date;
updatedAt: Date;
reference: string | null;
@@ -176,12 +184,12 @@ export declare class SitesService {
prix: import("@prisma/client/runtime/library").Decimal | null;
emplacement: string | null;
machineId: string | null;
parentComposantId: string | null;
typeComposantId: string | null;
parentComposantId: string | null;
})[];
} & {
name: string;
id: string;
name: string;
createdAt: Date;
updatedAt: Date;
reference: string | null;
@@ -192,23 +200,35 @@ export declare class SitesService {
typeMachineId: string | null;
})[];
} & {
name: string;
description: string | null;
id: string;
name: string;
contactName: string;
contactPhone: string;
contactAddress: string;
contactPostalCode: string;
contactCity: string;
createdAt: Date;
updatedAt: Date;
}) | null>;
update(id: string, updateSiteDto: UpdateSiteDto): Promise<{
name: string;
description: string | null;
id: string;
name: string;
contactName: string;
contactPhone: string;
contactAddress: string;
contactPostalCode: string;
contactCity: string;
createdAt: Date;
updatedAt: Date;
}>;
remove(id: string): Promise<{
name: string;
description: string | null;
id: string;
name: string;
contactName: string;
contactPhone: string;
contactAddress: string;
contactPostalCode: string;
contactCity: string;
createdAt: Date;
updatedAt: Date;
}>;

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,8 @@
-- Drop the obsolete description column and add contact-related fields to sites
ALTER TABLE "sites"
DROP COLUMN IF EXISTS "description",
ADD COLUMN "contactName" TEXT NOT NULL DEFAULT '',
ADD COLUMN "contactPhone" TEXT NOT NULL DEFAULT '',
ADD COLUMN "contactAddress" TEXT NOT NULL DEFAULT '',
ADD COLUMN "contactPostalCode" TEXT NOT NULL DEFAULT '',
ADD COLUMN "contactCity" TEXT NOT NULL DEFAULT '';

View File

@@ -14,7 +14,11 @@ datasource db {
model Site {
id String @id @default(cuid())
name String
description String?
contactName String @default("")
contactPhone String @default("")
contactAddress String @default("")
contactPostalCode String @default("")
contactCity String @default("")
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt

View File

@@ -4,9 +4,20 @@ export class CreateSiteDto {
@IsString()
name: string;
@IsOptional()
@IsString()
description?: string;
contactName: string;
@IsString()
contactPhone: string;
@IsString()
contactAddress: string;
@IsString()
contactPostalCode: string;
@IsString()
contactCity: string;
}
export class UpdateSiteDto {
@@ -16,5 +27,21 @@ export class UpdateSiteDto {
@IsOptional()
@IsString()
description?: string;
}
contactName?: string;
@IsOptional()
@IsString()
contactPhone?: string;
@IsOptional()
@IsString()
contactAddress?: string;
@IsOptional()
@IsString()
contactPostalCode?: string;
@IsOptional()
@IsString()
contactCity?: string;
}