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

Merge branch 'dev' into 'feat/add-user-to-structure'

# Conflicts:
#   src/structures/services/structures.service.ts
parents 679f239e 88c02dc0
No related branches found
No related tags found
3 merge requests!38Recette,!37Dev,!34Feat/add user to structure
...@@ -7,6 +7,7 @@ export class structureDto { ...@@ -7,6 +7,7 @@ export class structureDto {
numero: string; numero: string;
createdAt: string; createdAt: string;
updatedAt: string; updatedAt: string;
deletedAt: Date;
@IsNotEmpty() @IsNotEmpty()
structureName: string; structureName: string;
......
...@@ -12,6 +12,7 @@ import { MailerService } from '../../mailer/mailer.service'; ...@@ -12,6 +12,7 @@ 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 { IUser } from '../../users/interfaces/user.interface'; import { IUser } from '../../users/interfaces/user.interface';
import * as _ from 'lodash';
@Injectable() @Injectable()
export class StructuresService { export class StructuresService {
...@@ -105,6 +106,10 @@ export class StructuresService { ...@@ -105,6 +106,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