Skip to content
Snippets Groups Projects
Commit 48a3726e authored by Jérémie BRISON's avatar Jérémie BRISON
Browse files

fix(structure) : update coord when address structure change

parent 451e0041
Branches
Tags
3 merge requests!38Recette,!37Dev,!31fix(structure) : update coord when address structure change
...@@ -11,7 +11,7 @@ import { User } from '../../users/schemas/user.schema'; ...@@ -11,7 +11,7 @@ import { User } from '../../users/schemas/user.schema';
import { MailerService } from '../../mailer/mailer.service'; import { MailerService } from '../../mailer/mailer.service';
import { Cron, CronExpression } from '@nestjs/schedule'; import { Cron, CronExpression } from '@nestjs/schedule';
import { DateTime } from 'luxon'; import { DateTime } from 'luxon';
import * as _ from 'lodash';
@Injectable() @Injectable()
export class StructuresService { export class StructuresService {
constructor( constructor(
...@@ -104,6 +104,10 @@ export class StructuresService { ...@@ -104,6 +104,10 @@ export class StructuresService {
} }
public async update(idStructure: string, structure: structureDto): Promise<Structure> { 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(); const result = await this.structureModel.findByIdAndUpdate(Types.ObjectId(idStructure), structure).exec();
if (!result) { if (!result) {
throw new HttpException('Invalid structure id', HttpStatus.BAD_REQUEST); throw new HttpException('Invalid structure id', HttpStatus.BAD_REQUEST);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment