find territories for a point

This commit is contained in:
sbriat
2023-02-06 16:12:40 +01:00
parent a743fefe94
commit 1da111bba9
10 changed files with 37 additions and 10 deletions

View File

@@ -0,0 +1,9 @@
export class Point {
lon: number;
lat: number;
constructor(lon: number, lat: number) {
this.lon = lon;
this.lat = lat;
}
}

View File

@@ -3,6 +3,7 @@ import { ICollection } from 'src/modules/database/src/interfaces/collection.inte
import { TerritoriesRepository } from '../../adapters/secondaries/territories.repository';
import { FindForPointQuery } from '../../queries/find-for-point.query';
import { Territory } from '../entities/territory';
import { Point } from '../entities/point';
@QueryHandler(FindForPointQuery)
export class FindForPointUseCase {
@@ -11,9 +12,8 @@ export class FindForPointUseCase {
async execute(
findForPointQuery: FindForPointQuery,
): Promise<ICollection<Territory>> {
return this._repository.findAll(1, 999999, {
lon: findForPointQuery.lon,
lat: findForPointQuery.lat,
});
return this._repository.findForPoint(
new Point(findForPointQuery.point.lon, findForPointQuery.point.lat),
);
}
}