Add optional comment to Ad type and records #7409

This commit is contained in:
Romain Thouvenin
2024-02-28 14:50:59 +01:00
parent da4b30350b
commit a7b342c049
15 changed files with 36 additions and 3 deletions

View File

@@ -82,6 +82,7 @@ export class AdMapper
})),
}
: undefined,
comment: copy.comment,
};
return record;
};
@@ -128,6 +129,7 @@ export class AdMapper
},
},
})),
comment: record.comment,
},
});
return entity;
@@ -193,6 +195,7 @@ export class AdMapper
lon: waypoint.address.coordinates.lon,
lat: waypoint.address.coordinates.lat,
}));
response.comment = props.comment;
return response;
};
}

View File

@@ -15,6 +15,7 @@ export class CreateAdCommand extends Command {
readonly seatsRequested?: number;
readonly strict: boolean;
readonly waypoints: Waypoint[];
readonly comment?: string;
constructor(props: CommandProps<CreateAdCommand>) {
super(props);
@@ -29,5 +30,6 @@ export class CreateAdCommand extends Command {
this.seatsRequested = props.seatsRequested;
this.strict = props.strict;
this.waypoints = props.waypoints;
this.comment = props.comment;
}
}

View File

@@ -95,6 +95,7 @@ export class CreateAdService implements ICommandHandler {
},
},
})),
comment: command.comment,
});
try {

View File

@@ -47,6 +47,7 @@ export class AdEntity extends AggregateRoot<AdProps> {
lon: waypoint.address.coordinates.lon,
lat: waypoint.address.coordinates.lat,
})),
comment: props.comment,
}),
);
return ad;

View File

@@ -15,6 +15,7 @@ export interface AdProps {
seatsRequested: number;
strict: boolean;
waypoints: WaypointProps[];
comment?: string;
}
// Properties that are needed for an Ad creation
@@ -30,6 +31,7 @@ export interface CreateAdProps {
seatsRequested: number;
strict: boolean;
waypoints: WaypointProps[];
comment?: string;
}
export enum Frequency {

View File

@@ -12,6 +12,7 @@ export class AdCreatedDomainEvent extends DomainEvent {
readonly seatsRequested: number;
readonly strict: boolean;
readonly waypoints: Waypoint[];
readonly comment?: string;
constructor(props: DomainEventProps<AdCreatedDomainEvent>) {
super(props);
@@ -26,6 +27,7 @@ export class AdCreatedDomainEvent extends DomainEvent {
this.seatsRequested = props.seatsRequested;
this.strict = props.strict;
this.waypoints = props.waypoints;
this.comment = props.comment;
}
}

View File

@@ -24,6 +24,7 @@ export type AdBaseModel = {
seatsProposed: number;
seatsRequested: number;
strict: boolean;
comment?: string;
};
export type AdReadModel = AdBaseModel & {

View File

@@ -28,4 +28,5 @@ export class AdResponseDto extends ResponseBase {
lon: number;
lat: number;
}[];
comment?: string;
}

View File

@@ -36,6 +36,7 @@ message Ad {
int32 seatsRequested = 10;
bool strict = 11;
repeated Waypoint waypoints = 12;
optional string comment = 13;
}
message ScheduleItem {

View File

@@ -3,8 +3,10 @@ import {
IsBoolean,
IsInt,
IsEnum,
IsString,
ValidateNested,
ArrayMinSize,
Length,
IsUUID,
IsArray,
IsISO8601,
@@ -78,4 +80,9 @@ export class CreateAdRequestDto {
@HasValidPositionIndexes()
@ValidateNested({ each: true })
waypoints: WaypointDto[];
@Length(0, 2000)
@IsString()
@IsOptional()
comment?: string;
}