mirror of
https://gitlab.com/mobicoop/v3/service/territory.git
synced 2026-03-28 03:25:50 +00:00
basic requirements
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
import { IsNotEmpty, IsNumber } from 'class-validator';
|
||||
|
||||
export class FindForPointRequest {
|
||||
@IsNumber()
|
||||
@IsNotEmpty()
|
||||
lon: number;
|
||||
|
||||
@IsNumber()
|
||||
@IsNotEmpty()
|
||||
lat: number;
|
||||
}
|
||||
9
src/modules/territories/domain/entities/territory.ts
Normal file
9
src/modules/territories/domain/entities/territory.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { AutoMap } from '@automapper/classes';
|
||||
|
||||
export class Territory {
|
||||
@AutoMap()
|
||||
uuid: string;
|
||||
|
||||
@AutoMap()
|
||||
name: string;
|
||||
}
|
||||
12
src/modules/territories/domain/interfaces/message-broker.ts
Normal file
12
src/modules/territories/domain/interfaces/message-broker.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export abstract class IMessageBroker {
|
||||
exchange: string;
|
||||
|
||||
constructor(exchange: string) {
|
||||
this.exchange = exchange;
|
||||
}
|
||||
|
||||
abstract publish(routingKey: string, message: string): void;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { QueryHandler } from '@nestjs/cqrs';
|
||||
import { ICollection } from 'src/modules/database/src/interfaces/collection.interface';
|
||||
import { TerritoriesRepository } from '../../adapters/secondaries/territories.repository';
|
||||
import { FindForPointQuery } from '../../queries/find-for-point.query';
|
||||
import { Territory } from '../entities/territory';
|
||||
|
||||
@QueryHandler(FindForPointQuery)
|
||||
export class FindForPointUseCase {
|
||||
constructor(private readonly _repository: TerritoriesRepository) {}
|
||||
|
||||
async execute(
|
||||
findForPointQuery: FindForPointQuery,
|
||||
): Promise<ICollection<Territory>> {
|
||||
return this._repository.findAll(1, 999999, {
|
||||
lon: findForPointQuery.lon,
|
||||
lat: findForPointQuery.lat,
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user