Add optional comment to Ad type and records #7409
This commit is contained in:
parent
da4b30350b
commit
a7b342c049
10
README.md
10
README.md
|
@ -115,7 +115,8 @@ The app exposes the following [gRPC](https://grpc.io/) services :
|
||||||
"postalCode": "75000",
|
"postalCode": "75000",
|
||||||
"country": "France"
|
"country": "France"
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"comment": "I'm flexible with the departure time"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -157,7 +158,8 @@ The app exposes the following [gRPC](https://grpc.io/) services :
|
||||||
"postalCode": "75000",
|
"postalCode": "75000",
|
||||||
"country": "France"
|
"country": "France"
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"comment": "I'm flexible with the departure time"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -207,7 +209,8 @@ The app exposes the following [gRPC](https://grpc.io/) services :
|
||||||
"postalCode": "75000",
|
"postalCode": "75000",
|
||||||
"country": "France"
|
"country": "France"
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"comment": "I'm flexible with the departure time"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -227,6 +230,7 @@ The app exposes the following [gRPC](https://grpc.io/) services :
|
||||||
- seatsRequested: number of seats requested as passenger (required if `passenger` is true)
|
- seatsRequested: number of seats requested as passenger (required if `passenger` is true)
|
||||||
- strict (boolean): if set to true, allow matching only with similar frequency ads
|
- strict (boolean): if set to true, allow matching only with similar frequency ads
|
||||||
- waypoints: an array of addresses that represent the waypoints of the journey (only first and last waypoints are used for passenger ads). Note that positions are **required** and **must** be consecutives
|
- waypoints: an array of addresses that represent the waypoints of the journey (only first and last waypoints are used for passenger ads). Note that positions are **required** and **must** be consecutives
|
||||||
|
- comment: optional freetext comment / description about the ad
|
||||||
|
|
||||||
## Messages
|
## Messages
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "ad" ADD COLUMN "comment" TEXT;
|
|
@ -27,6 +27,7 @@ model Ad {
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
updatedAt DateTime @default(now()) @updatedAt
|
updatedAt DateTime @default(now()) @updatedAt
|
||||||
waypoints Waypoint[]
|
waypoints Waypoint[]
|
||||||
|
comment String?
|
||||||
|
|
||||||
@@map("ad")
|
@@map("ad")
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,6 +82,7 @@ export class AdMapper
|
||||||
})),
|
})),
|
||||||
}
|
}
|
||||||
: undefined,
|
: undefined,
|
||||||
|
comment: copy.comment,
|
||||||
};
|
};
|
||||||
return record;
|
return record;
|
||||||
};
|
};
|
||||||
|
@ -128,6 +129,7 @@ export class AdMapper
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})),
|
})),
|
||||||
|
comment: record.comment,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
return entity;
|
return entity;
|
||||||
|
@ -193,6 +195,7 @@ export class AdMapper
|
||||||
lon: waypoint.address.coordinates.lon,
|
lon: waypoint.address.coordinates.lon,
|
||||||
lat: waypoint.address.coordinates.lat,
|
lat: waypoint.address.coordinates.lat,
|
||||||
}));
|
}));
|
||||||
|
response.comment = props.comment;
|
||||||
return response;
|
return response;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ export class CreateAdCommand extends Command {
|
||||||
readonly seatsRequested?: number;
|
readonly seatsRequested?: number;
|
||||||
readonly strict: boolean;
|
readonly strict: boolean;
|
||||||
readonly waypoints: Waypoint[];
|
readonly waypoints: Waypoint[];
|
||||||
|
readonly comment?: string;
|
||||||
|
|
||||||
constructor(props: CommandProps<CreateAdCommand>) {
|
constructor(props: CommandProps<CreateAdCommand>) {
|
||||||
super(props);
|
super(props);
|
||||||
|
@ -29,5 +30,6 @@ export class CreateAdCommand extends Command {
|
||||||
this.seatsRequested = props.seatsRequested;
|
this.seatsRequested = props.seatsRequested;
|
||||||
this.strict = props.strict;
|
this.strict = props.strict;
|
||||||
this.waypoints = props.waypoints;
|
this.waypoints = props.waypoints;
|
||||||
|
this.comment = props.comment;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,6 +95,7 @@ export class CreateAdService implements ICommandHandler {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})),
|
})),
|
||||||
|
comment: command.comment,
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -47,6 +47,7 @@ export class AdEntity extends AggregateRoot<AdProps> {
|
||||||
lon: waypoint.address.coordinates.lon,
|
lon: waypoint.address.coordinates.lon,
|
||||||
lat: waypoint.address.coordinates.lat,
|
lat: waypoint.address.coordinates.lat,
|
||||||
})),
|
})),
|
||||||
|
comment: props.comment,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
return ad;
|
return ad;
|
||||||
|
|
|
@ -15,6 +15,7 @@ export interface AdProps {
|
||||||
seatsRequested: number;
|
seatsRequested: number;
|
||||||
strict: boolean;
|
strict: boolean;
|
||||||
waypoints: WaypointProps[];
|
waypoints: WaypointProps[];
|
||||||
|
comment?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Properties that are needed for an Ad creation
|
// Properties that are needed for an Ad creation
|
||||||
|
@ -30,6 +31,7 @@ export interface CreateAdProps {
|
||||||
seatsRequested: number;
|
seatsRequested: number;
|
||||||
strict: boolean;
|
strict: boolean;
|
||||||
waypoints: WaypointProps[];
|
waypoints: WaypointProps[];
|
||||||
|
comment?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum Frequency {
|
export enum Frequency {
|
||||||
|
|
|
@ -12,6 +12,7 @@ export class AdCreatedDomainEvent extends DomainEvent {
|
||||||
readonly seatsRequested: number;
|
readonly seatsRequested: number;
|
||||||
readonly strict: boolean;
|
readonly strict: boolean;
|
||||||
readonly waypoints: Waypoint[];
|
readonly waypoints: Waypoint[];
|
||||||
|
readonly comment?: string;
|
||||||
|
|
||||||
constructor(props: DomainEventProps<AdCreatedDomainEvent>) {
|
constructor(props: DomainEventProps<AdCreatedDomainEvent>) {
|
||||||
super(props);
|
super(props);
|
||||||
|
@ -26,6 +27,7 @@ export class AdCreatedDomainEvent extends DomainEvent {
|
||||||
this.seatsRequested = props.seatsRequested;
|
this.seatsRequested = props.seatsRequested;
|
||||||
this.strict = props.strict;
|
this.strict = props.strict;
|
||||||
this.waypoints = props.waypoints;
|
this.waypoints = props.waypoints;
|
||||||
|
this.comment = props.comment;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ export type AdBaseModel = {
|
||||||
seatsProposed: number;
|
seatsProposed: number;
|
||||||
seatsRequested: number;
|
seatsRequested: number;
|
||||||
strict: boolean;
|
strict: boolean;
|
||||||
|
comment?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type AdReadModel = AdBaseModel & {
|
export type AdReadModel = AdBaseModel & {
|
||||||
|
|
|
@ -28,4 +28,5 @@ export class AdResponseDto extends ResponseBase {
|
||||||
lon: number;
|
lon: number;
|
||||||
lat: number;
|
lat: number;
|
||||||
}[];
|
}[];
|
||||||
|
comment?: string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ message Ad {
|
||||||
int32 seatsRequested = 10;
|
int32 seatsRequested = 10;
|
||||||
bool strict = 11;
|
bool strict = 11;
|
||||||
repeated Waypoint waypoints = 12;
|
repeated Waypoint waypoints = 12;
|
||||||
|
optional string comment = 13;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ScheduleItem {
|
message ScheduleItem {
|
||||||
|
|
|
@ -3,8 +3,10 @@ import {
|
||||||
IsBoolean,
|
IsBoolean,
|
||||||
IsInt,
|
IsInt,
|
||||||
IsEnum,
|
IsEnum,
|
||||||
|
IsString,
|
||||||
ValidateNested,
|
ValidateNested,
|
||||||
ArrayMinSize,
|
ArrayMinSize,
|
||||||
|
Length,
|
||||||
IsUUID,
|
IsUUID,
|
||||||
IsArray,
|
IsArray,
|
||||||
IsISO8601,
|
IsISO8601,
|
||||||
|
@ -78,4 +80,9 @@ export class CreateAdRequestDto {
|
||||||
@HasValidPositionIndexes()
|
@HasValidPositionIndexes()
|
||||||
@ValidateNested({ each: true })
|
@ValidateNested({ each: true })
|
||||||
waypoints: WaypointDto[];
|
waypoints: WaypointDto[];
|
||||||
|
|
||||||
|
@Length(0, 2000)
|
||||||
|
@IsString()
|
||||||
|
@IsOptional()
|
||||||
|
comment?: string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,6 +111,7 @@ const adReadModel: AdReadModel = {
|
||||||
strict: false,
|
strict: false,
|
||||||
seatsProposed: 3,
|
seatsProposed: 3,
|
||||||
seatsRequested: 1,
|
seatsRequested: 1,
|
||||||
|
comment: '',
|
||||||
createdAt: now,
|
createdAt: now,
|
||||||
updatedAt: now,
|
updatedAt: now,
|
||||||
};
|
};
|
||||||
|
|
|
@ -39,6 +39,7 @@ const baseCreateAdProps = {
|
||||||
seatsRequested: 1,
|
seatsRequested: 1,
|
||||||
strict: false,
|
strict: false,
|
||||||
waypoints: [originWaypointProps, destinationWaypointProps],
|
waypoints: [originWaypointProps, destinationWaypointProps],
|
||||||
|
comment: "J'accepte les chiens mais pas les chats",
|
||||||
};
|
};
|
||||||
const punctualCreateAdProps = {
|
const punctualCreateAdProps = {
|
||||||
fromDate: '2023-06-21',
|
fromDate: '2023-06-21',
|
||||||
|
@ -134,6 +135,9 @@ describe('Ad entity create', () => {
|
||||||
expect(punctualPassengerAd.getProps().schedule[0].time).toBe('08:30');
|
expect(punctualPassengerAd.getProps().schedule[0].time).toBe('08:30');
|
||||||
expect(punctualPassengerAd.getProps().driver).toBeFalsy();
|
expect(punctualPassengerAd.getProps().driver).toBeFalsy();
|
||||||
expect(punctualPassengerAd.getProps().passenger).toBeTruthy();
|
expect(punctualPassengerAd.getProps().passenger).toBeTruthy();
|
||||||
|
expect(punctualPassengerAd.getProps().comment).toBe(
|
||||||
|
"J'accepte les chiens mais pas les chats",
|
||||||
|
);
|
||||||
});
|
});
|
||||||
it('should create a new punctual driver ad entity', async () => {
|
it('should create a new punctual driver ad entity', async () => {
|
||||||
const punctualDriverAd: AdEntity = AdEntity.create(
|
const punctualDriverAd: AdEntity = AdEntity.create(
|
||||||
|
|
Loading…
Reference in New Issue