mirror of
https://gitlab.com/mobicoop/v3/service/territory.git
synced 2026-03-22 16:55:50 +00:00
basic insert
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { AutoMap } from '@automapper/classes';
|
||||
import { IsNotEmpty, IsOptional, IsString } from 'class-validator';
|
||||
import { Geometry } from 'geojson';
|
||||
|
||||
export class UpdateTerritoryRequest {
|
||||
@IsString()
|
||||
@@ -15,5 +16,5 @@ export class UpdateTerritoryRequest {
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
@AutoMap()
|
||||
shape?: string;
|
||||
shape?: Geometry;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ export class CreateTerritoryUseCase {
|
||||
);
|
||||
|
||||
try {
|
||||
const territory = await this._repository.create(entity);
|
||||
const territory = await this._repository.createTerritory(entity);
|
||||
this._territoryMessager.publish('create', JSON.stringify(territory));
|
||||
this._loggingMessager.publish(
|
||||
'territory.create.info',
|
||||
|
||||
@@ -12,7 +12,20 @@ import { TerritoryProfile } from '../../mappers/territory.profile';
|
||||
|
||||
const newTerritoryRequest: CreateTerritoryRequest = {
|
||||
name: 'Grand Est',
|
||||
shape: 'grand-est-binary-shape',
|
||||
shape: {
|
||||
type: 'MultiPolygon',
|
||||
coordinates: [
|
||||
[
|
||||
[
|
||||
[838383.2, 6570485.8],
|
||||
[838483.8, 6570697.7],
|
||||
[838688.1, 6571298.4],
|
||||
[838809.5, 6571599.9],
|
||||
[838383.2, 6570485.8],
|
||||
],
|
||||
],
|
||||
],
|
||||
},
|
||||
};
|
||||
const newTerritoryCommand: CreateTerritoryCommand = new CreateTerritoryCommand(
|
||||
newTerritoryRequest,
|
||||
|
||||
@@ -9,17 +9,56 @@ const mockTerritories = [
|
||||
{
|
||||
uuid: 'bb281075-1b98-4456-89d6-c643d3044a91',
|
||||
name: 'Grand Est',
|
||||
shape: 'grand-est-binary-shape',
|
||||
shape: {
|
||||
type: 'MultiPolygon',
|
||||
coordinates: [
|
||||
[
|
||||
[
|
||||
[838383.2, 6570485.8],
|
||||
[838483.8, 6570697.7],
|
||||
[838688.1, 6571298.4],
|
||||
[838809.5, 6571599.9],
|
||||
[838383.2, 6570485.8],
|
||||
],
|
||||
],
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
uuid: 'bb281075-1b98-4456-89d6-c643d3044a92',
|
||||
name: 'Nouvelle Aquitaine',
|
||||
shape: 'nouvelle-aquitaine-binary-shape',
|
||||
shape: {
|
||||
type: 'MultiPolygon',
|
||||
coordinates: [
|
||||
[
|
||||
[
|
||||
[838383.2, 6570485.8],
|
||||
[838483.8, 6570697.7],
|
||||
[838688.1, 6571298.4],
|
||||
[838809.5, 6571599.9],
|
||||
[838383.2, 6570485.8],
|
||||
],
|
||||
],
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
uuid: 'bb281075-1b98-4456-89d6-c643d3044a93',
|
||||
name: 'Occitanie',
|
||||
shape: 'occitanie-binary-shape',
|
||||
shape: {
|
||||
type: 'MultiPolygon',
|
||||
coordinates: [
|
||||
[
|
||||
[
|
||||
[838383.2, 6570485.8],
|
||||
[838483.8, 6570697.7],
|
||||
[838688.1, 6571298.4],
|
||||
[838809.5, 6571599.9],
|
||||
[838383.2, 6570485.8],
|
||||
],
|
||||
],
|
||||
],
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
@@ -16,17 +16,56 @@ const mockTerritories = [
|
||||
{
|
||||
uuid: 'bb281075-1b98-4456-89d6-c643d3044a91',
|
||||
name: 'Grand Est',
|
||||
shape: 'grand-est-binary-shape',
|
||||
shape: {
|
||||
type: 'MultiPolygon',
|
||||
coordinates: [
|
||||
[
|
||||
[
|
||||
[838383.2, 6570485.8],
|
||||
[838483.8, 6570697.7],
|
||||
[838688.1, 6571298.4],
|
||||
[838809.5, 6571599.9],
|
||||
[838383.2, 6570485.8],
|
||||
],
|
||||
],
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
uuid: 'bb281075-1b98-4456-89d6-c643d3044a92',
|
||||
name: 'Nouvelle Aquitaine',
|
||||
shape: 'nouvelle-aquitaine-binary-shape',
|
||||
shape: {
|
||||
type: 'MultiPolygon',
|
||||
coordinates: [
|
||||
[
|
||||
[
|
||||
[838383.2, 6570485.8],
|
||||
[838483.8, 6570697.7],
|
||||
[838688.1, 6571298.4],
|
||||
[838809.5, 6571599.9],
|
||||
[838383.2, 6570485.8],
|
||||
],
|
||||
],
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
uuid: 'bb281075-1b98-4456-89d6-c643d3044a93',
|
||||
name: 'Occitanie',
|
||||
shape: 'occitanie-binary-shape',
|
||||
shape: {
|
||||
type: 'MultiPolygon',
|
||||
coordinates: [
|
||||
[
|
||||
[
|
||||
[838383.2, 6570485.8],
|
||||
[838483.8, 6570697.7],
|
||||
[838688.1, 6571298.4],
|
||||
[838809.5, 6571599.9],
|
||||
[838383.2, 6570485.8],
|
||||
],
|
||||
],
|
||||
],
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
@@ -9,7 +9,20 @@ import { FindTerritoryByUuidQuery } from '../../queries/find-territory-by-uuid.q
|
||||
const mockTerritory = {
|
||||
uuid: 'bb281075-1b98-4456-89d6-c643d3044a91',
|
||||
name: 'Grand Est',
|
||||
shape: 'grand-est-binary-shape',
|
||||
shape: {
|
||||
type: 'MultiPolygon',
|
||||
coordinates: [
|
||||
[
|
||||
[
|
||||
[838383.2, 6570485.8],
|
||||
[838483.8, 6570697.7],
|
||||
[838688.1, 6571298.4],
|
||||
[838809.5, 6571599.9],
|
||||
[838383.2, 6570485.8],
|
||||
],
|
||||
],
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
const mockTerritoriesRepository = {
|
||||
|
||||
Reference in New Issue
Block a user