mirror of
https://gitlab.com/mobicoop/v3/service/matcher.git
synced 2026-01-01 08:32:41 +00:00
routeMapper tests
This commit is contained in:
39
src/modules/geography/route.mapper.ts
Normal file
39
src/modules/geography/route.mapper.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
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.spacetimePoints = entity.getProps().spacetimePoints;
|
||||
return response;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user