mirror of
https://gitlab.com/mobicoop/v3/service/matcher.git
synced 2026-01-01 10:12:40 +00:00
40 lines
1.4 KiB
TypeScript
40 lines
1.4 KiB
TypeScript
import { Mapper } from '@mobicoop/ddd-library';
|
|
import { Injectable } from '@nestjs/common';
|
|
import { RouteEntity } from './core/domain/route.entity';
|
|
import { RouteResponseDto } from './interface/dtos/route.response.dto';
|
|
|
|
/**
|
|
* Mapper constructs objects that are used in different layers:
|
|
* Record is an object that is stored in a database,
|
|
* Entity is an object that is used in application domain layer,
|
|
* and a ResponseDTO is an object returned to a user (usually as json).
|
|
*/
|
|
|
|
@Injectable()
|
|
export class RouteMapper
|
|
implements Mapper<RouteEntity, undefined, undefined, RouteResponseDto>
|
|
{
|
|
toPersistence = (): undefined => {
|
|
return undefined;
|
|
};
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
toDomain = (): undefined => {
|
|
return undefined;
|
|
};
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
toResponse = (entity: RouteEntity): RouteResponseDto => {
|
|
const response = new RouteResponseDto();
|
|
response.driverDistance = entity.getProps().driverDistance;
|
|
response.driverDuration = entity.getProps().driverDuration;
|
|
response.passengerDistance = entity.getProps().passengerDistance;
|
|
response.passengerDuration = entity.getProps().passengerDuration;
|
|
response.fwdAzimuth = entity.getProps().fwdAzimuth;
|
|
response.backAzimuth = entity.getProps().backAzimuth;
|
|
response.distanceAzimuth = entity.getProps().distanceAzimuth;
|
|
response.points = entity.getProps().points;
|
|
return response;
|
|
};
|
|
}
|