-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
078537f
commit ad40a56
Showing
13 changed files
with
246 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/backend/src/controllers/hebergement/getByDepartements.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
const { adresse } = require("../../controllers/geo"); | ||
const { getNameByUuid } = require("../Document"); | ||
module.exports.queryGetFields = ` | ||
H.NOM AS "nom", | ||
H.EMAIL AS "email", | ||
H.ADRESSE_ID AS "adresseId", | ||
H.TELEPHONE_1 AS "numTelephone1", | ||
H.TELEPHONE_2 AS "numTelephone2", | ||
H.NOM_GESTIONNAIRE AS "nomGestionnaire", | ||
( | ||
SELECT | ||
VALUE | ||
FROM | ||
FRONT.HEBERGEMENT_TYPE | ||
WHERE | ||
ID = H.TYPE_ID | ||
) AS "type", | ||
( | ||
SELECT | ||
VALUE | ||
FROM | ||
FRONT.HEBERGEMENT_TYPE_PENSION | ||
WHERE | ||
ID = H.TYPE_PENSION_ID | ||
) AS "typePension", | ||
H.NOMBRE_LITS AS "nombreLits", | ||
H.LIT_DESSUS AS "litDessus", | ||
H.NOMBRE_LITS_SUPERPOSES AS "nombreLitsSuperposes", | ||
H.NOMBRE_MAX_PERSONNES_COUCHAGE AS "nombreMaxPersonnesCouchage", | ||
H.VISITE_LOCAUX AS "visiteLocaux", | ||
H.VISITE_LOCAUX_AT AS "visiteLocauxAt", | ||
H.ACCESSIBILITE_ID AS "accessibiliteId", | ||
( | ||
SELECT | ||
VALUE | ||
FROM | ||
FRONT.HEBERGEMENT_ACCESSIBILITE | ||
WHERE | ||
ID = H.ACCESSIBILITE_ID | ||
) AS "accessibilite", | ||
H.ACCESSIBILITE_PRECISION AS "accessibilitePrecision", | ||
H.CHAMBRES_DOUBLES AS "chambresDoubles", | ||
H.CHAMBRES_UNISEXES AS "chambresUnisexes", | ||
H.REGLEMENTATION_ERP AS "reglementationErp", | ||
H.COUCHAGE_INDIVIDUEL AS "couchageIndividuel", | ||
H.RANGEMENT_INDIVIDUEL AS "rangementIndividuel", | ||
H.AMENAGEMENTS_SPECIFIQUES AS "amenagementsSpecifiques", | ||
H.AMENAGEMENTS_SPECIFIQUES_PRECISION AS "amenagementsSpecifiquesPrecision", | ||
H.DESCRIPTION_LIEU_HEBERGEMENT AS "descriptionLieuHebergement", | ||
H.EXCURSION_DESCRIPTION AS "excursionDescription", | ||
H.DEPLACEMENT_PROXIMITE_DESCRIPTION AS "deplacementProximiteDescription", | ||
H.VEHICULES_ADAPTES AS "vehiculesAdaptes", | ||
H.FILE_REPONSE_EXPLOITANT_OU_PROPRIETAIRE AS "fileReponseExploitantOuProprietaire", | ||
H.FILE_DERNIER_ARRETE_AUTORISATION_MAIRE AS "fileDernierArreteAutorisationMaire", | ||
H.FILE_DERNIERE_ATTESTATION_SECURITE AS "fileDerniereAttestationSecurite", | ||
( | ||
SELECT | ||
ARRAY_AGG(HPH.VALUE) | ||
FROM | ||
FRONT.HEBERGEMENT_TO_PRESTATIONS_HOTELIERES HTPH | ||
LEFT JOIN FRONT.HEBERGEMENT_PRESTATIONS_HOTELIERES HPH ON HPH.ID = HTPH.PRESTATION_ID | ||
WHERE | ||
HEBERGEMENT_ID = H.ID | ||
) AS "prestationsHoteliere" | ||
`; | ||
|
||
const mapHebergementToCoordonnees = (hebergement, adresse) => { | ||
return { | ||
adresse: { | ||
codeInsee: adresse.codeInsee, | ||
codePostal: adresse.codePostal, | ||
coordinates: [adresse.long, adresse.lat], | ||
departement: adresse.departement, | ||
label: adresse.label, | ||
}, | ||
email: hebergement.email, | ||
nomGestionnaire: hebergement.nomGestionnaire, | ||
numTelephone1: hebergement.numTelephone1, | ||
numTelephone2: hebergement.numTelephone2, | ||
}; | ||
}; | ||
|
||
const mapHebergementToInformationsLocaux = async (hebergement) => { | ||
return { | ||
type: hebergement.type, | ||
pension: hebergement.typePension, | ||
litsDessus: hebergement.litDessus, | ||
nombreLits: hebergement.nombreLits, | ||
nombreLitsSuperposes: hebergement.nombreLitsSuperposes, | ||
visiteLocaux: hebergement.visiteLocaux, | ||
accessibilite: hebergement.accessibilite, | ||
accessibilitePrecision: hebergement.accessibilitePrecision, | ||
visiteLocauxAt: hebergement.visiteLocauxAt, | ||
chambresDoubles: hebergement.chambresDoubles, | ||
chambresUnisexes: hebergement.chambresUnisexes, | ||
reglementationErp: hebergement.reglementationErp, | ||
couchageIndividuel: hebergement.couchageIndividuel, | ||
rangementIndividuel: hebergement.rangementIndividuel, | ||
prestationsHotelieres: hebergement.prestationsHoteliere, | ||
amenagementsSpecifiques: hebergement.amenagementsSpecifiques, | ||
descriptionLieuHebergement: hebergement.descriptionLieuHebergement, | ||
nombreMaxPersonnesCouchage: hebergement.nombreMaxPersonnesCouchage, | ||
precisionAmenagementsSpecifiques: | ||
hebergement.amenagementsSpecifiquesPrecision, | ||
fileDerniereAttestationSecurite: await getNameByUuid( | ||
hebergement.fileDerniereAttestationSecurite, | ||
), | ||
fileDernierArreteAutorisationMaire: await getNameByUuid( | ||
hebergement.fileDernierArreteAutorisationMaire, | ||
), | ||
fileReponseExploitantOuProprietaire: await getNameByUuid( | ||
hebergement.fileReponseExploitantOuProprietaire, | ||
), | ||
}; | ||
}; | ||
|
||
const mapHebergementToInformationsTransport = (hebergement) => { | ||
return { | ||
excursion: hebergement.excursionDescription, | ||
vehiculesAdaptes: hebergement.vehiculesAdaptes, | ||
deplacementProximite: hebergement.deplacementProximiteDescription, | ||
}; | ||
}; | ||
|
||
const mapDBHebergement = async (hebergement, adresse) => { | ||
return { | ||
id: hebergement.id, | ||
nom: hebergement.nom, | ||
coordonnees: mapHebergementToCoordonnees(hebergement, adresse), | ||
informationsLocaux: await mapHebergementToInformationsLocaux(hebergement), | ||
informationsTransport: mapHebergementToInformationsTransport(hebergement), | ||
}; | ||
}; | ||
|
||
module.exports.mapDBHebergement = mapDBHebergement; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
packages/migrations/src/migrations/20241119135647_vehiculesAdaptes-type.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* @param { import("knex").Knex } knex | ||
* @returns { Promise<void> } | ||
*/ | ||
exports.up = function (knex) { | ||
return knex.raw( | ||
` | ||
ALTER TABLE FRONT.HEBERGEMENT | ||
RENAME COLUMN VEHICULES_ADAPTES TO VEHICULES_ADAPTES_DEPRECATED; | ||
ALTER TABLE FRONT.HEBERGEMENT | ||
ADD COLUMN VEHICULES_ADAPTES BOOLEAN; | ||
UPDATE FRONT.HEBERGEMENT | ||
SET | ||
VEHICULES_ADAPTES = CASE | ||
WHEN VEHICULES_ADAPTES_DEPRECATED = 'true' THEN TRUE | ||
ELSE FALSE | ||
END; | ||
`, | ||
); | ||
}; | ||
|
||
/** | ||
* @param { import("knex").Knex } knex | ||
* @returns { Promise<void> } | ||
*/ | ||
exports.down = function (knex) { | ||
return knex.raw( | ||
` | ||
ALTER TABLE FRONT.HEBERGEMENT | ||
DROP COLUMN VEHICULES_ADAPTES; | ||
ALTER TABLE FRONT.HEBERGEMENT | ||
RENAME COLUMN VEHICULES_ADAPTES_DEPRECATED TO VEHICULES_ADAPTES; | ||
`, | ||
); | ||
}; |