Loading backend/src/place/place.service.ts +43 −3 Original line number Diff line number Diff line Loading @@ -81,16 +81,19 @@ export class PlaceService { 'place.closeAt AS closeAt', 'availableDate.startDate AS startDate', 'availableDate.endDate AS endDate', 'place.available AS available', 'place.idTown AS idTown', ]) .where('place.idTown = :idTown', { idTown: idTown }) .andWhere('placeTrad.language = :language', { language: lang }) .getRawMany(); const places: GetPlaceDto[] = res.map((place) => { return { idTown: place.idTown, idPlace: place.idPlace, available: place.available, description: place.description, coords: place.coords, idTown: place.idTown, imageName: `${ServerConstants.HOST}/places/${place.imageName}`, name: place.name, openAt: place.openAt, Loading @@ -103,7 +106,44 @@ export class PlaceService { } async findOne(id: number) { const place = await this.placeRepository.findOneBy({ idPlace: id }); return place; return await this.placeRepository.findOneBy({ idPlace: id }); } async findOneAndTradAndAvailable(idPlace: number) { const place: GetPlaceDto = await this.dataSource .getRepository(PlaceTraduction) .createQueryBuilder('placeTrad') .leftJoin('placeTrad.idPlace', 'place') .leftJoin('place.availableDates', 'availableDate') .select([ 'place.idPlace AS idPlace', 'place.name AS name', 'place.imageName AS imageName', 'placeTrad.language AS language', 'placeTrad.description AS description', 'place.coords AS coords', 'place.openAt AS openAt', 'place.closeAt AS closeAt', 'availableDate.startDate AS startDate', 'availableDate.endDate AS endDate', 'place.idTown AS idTown', 'place.available AS available', ]) .where('place.idPlace = :idPlace', { idPlace: idPlace }) .getRawOne(); return { idTown: place.idTown, idPlace: place.idPlace, available: place.available, description: place.description, coords: place.coords, imageName: `${ServerConstants.HOST}/places/${place.imageName}`, name: place.name, openAt: place.openAt, closeAt: place.closeAt, startDate: place.startDate, endDate: place.endDate, }; } } Loading
backend/src/place/place.service.ts +43 −3 Original line number Diff line number Diff line Loading @@ -81,16 +81,19 @@ export class PlaceService { 'place.closeAt AS closeAt', 'availableDate.startDate AS startDate', 'availableDate.endDate AS endDate', 'place.available AS available', 'place.idTown AS idTown', ]) .where('place.idTown = :idTown', { idTown: idTown }) .andWhere('placeTrad.language = :language', { language: lang }) .getRawMany(); const places: GetPlaceDto[] = res.map((place) => { return { idTown: place.idTown, idPlace: place.idPlace, available: place.available, description: place.description, coords: place.coords, idTown: place.idTown, imageName: `${ServerConstants.HOST}/places/${place.imageName}`, name: place.name, openAt: place.openAt, Loading @@ -103,7 +106,44 @@ export class PlaceService { } async findOne(id: number) { const place = await this.placeRepository.findOneBy({ idPlace: id }); return place; return await this.placeRepository.findOneBy({ idPlace: id }); } async findOneAndTradAndAvailable(idPlace: number) { const place: GetPlaceDto = await this.dataSource .getRepository(PlaceTraduction) .createQueryBuilder('placeTrad') .leftJoin('placeTrad.idPlace', 'place') .leftJoin('place.availableDates', 'availableDate') .select([ 'place.idPlace AS idPlace', 'place.name AS name', 'place.imageName AS imageName', 'placeTrad.language AS language', 'placeTrad.description AS description', 'place.coords AS coords', 'place.openAt AS openAt', 'place.closeAt AS closeAt', 'availableDate.startDate AS startDate', 'availableDate.endDate AS endDate', 'place.idTown AS idTown', 'place.available AS available', ]) .where('place.idPlace = :idPlace', { idPlace: idPlace }) .getRawOne(); return { idTown: place.idTown, idPlace: place.idPlace, available: place.available, description: place.description, coords: place.coords, imageName: `${ServerConstants.HOST}/places/${place.imageName}`, name: place.name, openAt: place.openAt, closeAt: place.closeAt, startDate: place.startDate, endDate: place.endDate, }; } }