diff --git a/controllers/er/index.js b/controllers/er/index.js index 2a3ca1c..3039d22 100644 --- a/controllers/er/index.js +++ b/controllers/er/index.js @@ -29,8 +29,20 @@ function createErProxy(featureTypeName,typeSearch){ }); } params = _.omit(params,'apikey'); + + /** Gestion affichage des valeurs avec has_geometrie + * si true : affichage uniquement des résultats avec géométrie + * si false: affichage des résultats avec ou sans géométrie + */ + + if((params.admin == 'Y') && ((typeSearch == 'product') || (typeSearch == 'category'))) { + params.has_geometry=false; + } else { + params.has_geometry=true; + } + params = _.omit(params,'admin'); + /** Gestion de la requete product */ - if (typeSearch == 'product') { //For module Product utilisation parametre name pour la recherche if (params.name) { @@ -51,12 +63,8 @@ function createErProxy(featureTypeName,typeSearch){ }); } } - - if((params.has_geometry) &&(!((params.field_date) || (params._limit)))) { - params.has_geometry =true; - } + } - } //For _propertyNames, we need to transform the string in Array if(params._propertyNames) { params._propertyNames = params._propertyNames.split(';'); @@ -163,7 +171,7 @@ var productValidators = erValidators.concat([ check('publication_date').optional().isString(), check('date_maj_deb').optional().isString(), // Param ne servant que pour admin check('date_maj_fin').optional().isString(), // Param ne servant que pour admin - check('has_geometry').optional().isBoolean(), + check('admin').optional().isAlphanumeric().isLength({min:1,max:1}).withMessage('Le champ admin doit être Y ou N') ]); @@ -179,7 +187,8 @@ router.post('/product',cors(corsOptionsGlobal),productValidators, createErProxy( var categoryValidators = erValidators.concat([ check('name').optional().isString(), check('type').optional().isAlphanumeric().isLength({min:1,max:1}).withMessage('Le type est sur 1 caractère'), - check('category_id').optional().isString() + check('category_id').optional().isString(), + check('admin').optional().isAlphanumeric().isLength({min:1,max:1}).withMessage('Le champ admin doit être Y ou N') ]); router.get('/category', cors(corsOptionsGlobal),categoryValidators, createErProxy('PLAGE_ER_WFS:product_view' ,'category')); diff --git a/doc/er.yml b/doc/er.yml index 26c451d..cdc8d51 100644 --- a/doc/er.yml +++ b/doc/er.yml @@ -90,12 +90,6 @@ paths: type: string require: false - - name: has_geometry - in: query - description: Recherche uniquement valeur avec géométrie ou non - type: boolean - require: false - - name: _limit in: query description: Limite de résultats à afficher(chiffre entre 1 et 1000) diff --git a/lib/buildErCqlFilter.js b/lib/buildErCqlFilter.js index 184c179..8040bf1 100644 --- a/lib/buildErCqlFilter.js +++ b/lib/buildErCqlFilter.js @@ -46,7 +46,7 @@ function bboxToFilter(bbox){ if ( name.charAt(0) === '_' ){ continue; } - + if ( name == 'bbox' ){ parts.push(bboxToFilter(params['bbox'])) ; }else if ( name == 'geom' ){ @@ -65,7 +65,7 @@ function bboxToFilter(bbox){ } else if (name == 'namepr') { //Traiter le cas du produit avec le parametre name parts.push(' name ILIKE \'%'+ params[name] + '%\' OR name_complement ILIKE \'%'+ params[name] + '%\''); - } else if((name == 'has_geometry') && (params[name] =='false')){ + } else if((name == 'has_geometry') && (params[name] ==false)){ continue; //We do nothing when value has geometry = false to get all results. // Search in category @@ -81,8 +81,7 @@ function bboxToFilter(bbox){ chaineCategoryId = chaineCategoryId + chaineConnector + ' category_id='+valueCat[i]; } parts.push(chaineCategoryId); - } - + } } else { parts.push(name+'=\''+ params[name]+'\''); } diff --git a/package-lock.json b/package-lock.json index 0f519b2..5f15acd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "apicarto", - "version": "v2.4.0", + "version": "v2.4.2", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -7030,8 +7030,7 @@ }, "ansi-regex": { "version": "5.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", - "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", + "resolved": "", "dev": true }, "emoji-regex": { diff --git a/package.json b/package.json index 94969b8..a612584 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "apicarto", - "version": "v2.4.0", + "version": "v2.4.2", "main": "index.js", "scripts": { "import": "npm run import-inao-appellation",