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 83c48a25995b9c7ce714c8dce9635e69d4aa3e1a..17918751abed8f7552d043346160db161696d8c7 100644 --- a/src/structures/services/structures.service.ts +++ b/src/structures/services/structures.service.ts @@ -11,7 +11,7 @@ import { User } from '../../users/schemas/user.schema'; import { MailerService } from '../../mailer/mailer.service'; import { Cron, CronExpression } from '@nestjs/schedule'; import { DateTime } from 'luxon'; - +import * as _ from 'lodash'; @Injectable() export class StructuresService { constructor( @@ -104,6 +104,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);