diff --git a/src/structures/dto/structure.dto.ts b/src/structures/dto/structure.dto.ts index 485cdf3ddd603c9e06cd1554b89de842c3e80d26..b4e417214280f76147dde7e07c55efc70d2a0100 100644 --- a/src/structures/dto/structure.dto.ts +++ b/src/structures/dto/structure.dto.ts @@ -7,6 +7,7 @@ export class structureDto { numero: string; createdAt: string; updatedAt: string; + deletedAt: Date; @IsNotEmpty() structureName: string; diff --git a/src/structures/services/structures.service.ts b/src/structures/services/structures.service.ts index 6a67a5367fbaee90330da8b911caf7501f75819d..5d584b07585316f844c9fa1f94b6b8331bb4668a 100644 --- a/src/structures/services/structures.service.ts +++ b/src/structures/services/structures.service.ts @@ -12,6 +12,7 @@ import { MailerService } from '../../mailer/mailer.service'; import { Cron, CronExpression } from '@nestjs/schedule'; import { DateTime } from 'luxon'; import { IUser } from '../../users/interfaces/user.interface'; +import * as _ from 'lodash'; @Injectable() export class StructuresService { @@ -105,6 +106,10 @@ export class StructuresService { } public async update(idStructure: string, structure: structureDto): Promise<Structure> { + const oldStructure = await this.findOne(idStructure); + if (!_.isEqual(oldStructure.address, structure.address)) { + await this.getStructurePosition(structure).then(); + } const result = await this.structureModel.findByIdAndUpdate(Types.ObjectId(idStructure), structure).exec(); if (!result) { throw new HttpException('Invalid structure id', HttpStatus.BAD_REQUEST);