This commit is contained in:
sbriat
2023-04-28 15:53:57 +02:00
parent 95310651d8
commit 1f9a9896e9
15 changed files with 129 additions and 65 deletions

View File

@@ -4,7 +4,8 @@ import { Injectable } from '@nestjs/common';
import { Ad } from '../domain/entities/ad';
import { AdPresenter } from '../adapters/primaries/ad.presenter';
import { CreateAdRequest } from '../domain/dtos/create-ad.request';
import { Coordinates } from 'src/modules/geography/domain/types/coordinates.type';
import { Coordinates } from '../../geography/domain/entities/coordinates';
import moment from 'moment-timezone';
@Injectable()
export class AdProfile extends AutomapperProfile {
@@ -21,16 +22,14 @@ export class AdProfile extends AutomapperProfile {
CreateAdRequest,
forMember(
(dest) => dest.waypoints,
mapFrom(
(source) =>
source.waypoints.map(
(waypoint) =>
new Coordinates(
waypoint.lon ?? undefined,
waypoint.lat ?? undefined,
),
),
// .filter((waypoint) => waypoint),
mapFrom((source) =>
source.waypoints.map(
(waypoint) =>
new Coordinates(
waypoint.lon ?? undefined,
waypoint.lat ?? undefined,
),
),
),
),
);
@@ -54,6 +53,18 @@ export class AdProfile extends AutomapperProfile {
(dest) => dest.updatedAt,
mapFrom((source) => new Date(source.updatedAt)),
),
// forMember(
// (dest) => dest.monTime,
// mapFrom((source) =>
// source.monTime
// ? new Date(
// moment
// .tz(`${source.fromDate} ${source.monTime}`, source.timezone)
// .format(),
// )
// : undefined,
// ),
// ),
);
};
}

View File

@@ -1,17 +0,0 @@
import { createMap, Mapper } from '@automapper/core';
import { AutomapperProfile, InjectMapper } from '@automapper/nestjs';
import { Injectable } from '@nestjs/common';
import { Coordinates } from '../../geography/domain/types/coordinates.type';
@Injectable()
export class CoordinatesProfile extends AutomapperProfile {
constructor(@InjectMapper() mapper: Mapper) {
super(mapper);
}
override get profile() {
return (mapper: any) => {
createMap(mapper, Coordinates, Coordinates);
};
}
}