mirror of
https://gitlab.com/mobicoop/v3/service/territory.git
synced 2026-03-28 03:25:50 +00:00
find territories for a point
This commit is contained in:
9
src/modules/territories/domain/entities/point.ts
Normal file
9
src/modules/territories/domain/entities/point.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export class Point {
|
||||
lon: number;
|
||||
lat: number;
|
||||
|
||||
constructor(lon: number, lat: number) {
|
||||
this.lon = lon;
|
||||
this.lat = lat;
|
||||
}
|
||||
}
|
||||
@@ -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),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user