Skip to content
Snippets Groups Projects
Commit 88c02dc0 authored by Hugo SUBTIL's avatar Hugo SUBTIL
Browse files

Merge branch 'fix/structure-updateCoord' into 'dev'

fix(structure) : update coord when address structure change

See merge request web-et-numerique/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server!31
parents fd217907 0ea1ae7d
No related branches found
No related tags found
3 merge requests!38Recette,!37Dev,!31fix(structure) : update coord when address structure change
......@@ -7,6 +7,7 @@ export class structureDto {
numero: string;
createdAt: string;
updatedAt: string;
deletedAt: Date;
@IsNotEmpty()
structureName: string;
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment