Added parameters to addressdb api endpoints and changed them to POST
This commit is contained in:
@@ -91,10 +91,12 @@ class ADBGemeindeModel {
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT Gemeinde.* FROM Gemeinde
|
||||
LEFT JOIN Plz ON (Plz.gemeinde_id = Gemeinde.id)
|
||||
WHERE $where
|
||||
GROUP BY Gemeinde.id
|
||||
ORDER BY name,code,kennziffer";
|
||||
|
||||
//mfLoghandler::singleton()->debug($sql);
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
if(is_array($limit) && count($limit)) {
|
||||
if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
|
||||
$sql .= " LIMIT ".$limit['start'].", ".$limit['count'];
|
||||
@@ -148,6 +150,20 @@ class ADBGemeindeModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("plz", $filter)) {
|
||||
$plz = FronkDB::singleton()->escape($filter['plz']);
|
||||
if($plz) {
|
||||
$where .= " AND Plz.plzstring = '$plz'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("plz%", $filter)) {
|
||||
$plz = FronkDB::singleton()->escape($filter['plz%']);
|
||||
if($plz) {
|
||||
$where .= " AND Plz.plzstring like '%$plz%'";
|
||||
}
|
||||
}
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
}
|
||||
|
||||
@@ -93,10 +93,14 @@ class ADBStrasseModel {
|
||||
$where = self::getSqlFilter($filter);
|
||||
//$sql = "SELECT MIN(id) as id, MIN(ortschaft_id) as ortschaft_id, gemeinde_id, MIN(kennziffer) as kennziffer, MIN(name) as name, MIN(`create`) as `create`, MIN(`edit`) as `edit` FROM Strasse
|
||||
$sql = "SELECT Strasse.* FROM Strasse
|
||||
LEFT JOIN Hausnummer ON (Hausnummer.strasse_id = Strasse.id)
|
||||
LEFT JOIN Plz ON (Plz.id = Hausnummer.plz_id)
|
||||
LEFT JOIN Gemeinde ON (Gemeinde.id = Strasse.gemeinde_id)
|
||||
WHERE $where
|
||||
GROUP BY Strasse.id
|
||||
ORDER BY gemeinde_id,name,kennziffer";
|
||||
|
||||
//mfLoghandler::singleton()->debug($sql);
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
if(is_array($limit) && count($limit)) {
|
||||
if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
|
||||
$sql .= " LIMIT ".$limit['start'].", ".$limit['count'];
|
||||
@@ -159,6 +163,34 @@ class ADBStrasseModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("gemeinde", $filter)) {
|
||||
$gemeinde = FronkDB::singleton()->escape($filter['gemeinde']);
|
||||
if($gemeinde) {
|
||||
$where .= " AND Gemeinde.`name` = '$gemeinde'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("gemeinde%", $filter)) {
|
||||
$gemeinde = FronkDB::singleton()->escape($filter['gemeinde%']);
|
||||
if($gemeinde) {
|
||||
$where .= " AND Gemeinde.`name` like '%$gemeinde%'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("plz", $filter)) {
|
||||
$plz = FronkDB::singleton()->escape($filter['plz']);
|
||||
if($plz) {
|
||||
$where .= " AND Plz.`plzstring` = '$plz'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("plz%", $filter)) {
|
||||
$plz = FronkDB::singleton()->escape($filter['plz%']);
|
||||
if($plz) {
|
||||
$where .= " AND Plz.`plzstring` like '%$plz%'";
|
||||
}
|
||||
}
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
}
|
||||
|
||||
@@ -6,9 +6,13 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
protected function init() {
|
||||
$db = $this->db(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
|
||||
$this->addRoute("/addressdb/findAddress", "find", "GET");
|
||||
$this->addRoute("/addressdb/findAddress", "find", "POST");
|
||||
$this->addRoute("/addressdb/findStreet", "findStreet", "GET");
|
||||
$this->addRoute("/addressdb/findStreet", "findStreet", "POST");
|
||||
$this->addRoute("/addressdb/findZip", "findZip", "GET");
|
||||
$this->addRoute("/addressdb/findZip", "findZip", "POST");
|
||||
$this->addRoute("/addressdb/findCity", "findCity", "GET");
|
||||
$this->addRoute("/addressdb/findCity", "findCity", "POST");
|
||||
|
||||
$this->allowMissingOrigin = true;
|
||||
@@ -31,21 +35,23 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
}
|
||||
|
||||
protected function findCity() {
|
||||
$search = $this->db()->escape(trim($this->post['search']));
|
||||
$city = $this->db()->escape(trim($this->post['city']));
|
||||
$zip = $this->db()->escape(trim($this->post['zip']));
|
||||
$get = array_merge($this->post, $this->get);
|
||||
|
||||
if($city) {
|
||||
$search = $city;
|
||||
$search = trim($get['search']);
|
||||
$city = trim($get['city']);
|
||||
$zip = trim($get['zip']);
|
||||
|
||||
if(!$city) {
|
||||
$city = $search;
|
||||
}
|
||||
|
||||
if(!$search) {
|
||||
return mfResponse::BadRequest(['message' => "Searchstring cannot be empty!"]);
|
||||
if(!$city && !$zip) {
|
||||
return mfResponse::BadRequest(['message' => "No search parameters"]);
|
||||
}
|
||||
|
||||
$city_search = ['name%' => $search];
|
||||
$city_search = ['name%' => $city];
|
||||
if($zip) {
|
||||
$city_search['zip'] = $zip;
|
||||
$city_search['plz%'] = $zip;
|
||||
}
|
||||
|
||||
$results = ADBGemeindeModel::search($city_search);
|
||||
@@ -61,12 +67,20 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
}
|
||||
|
||||
protected function findZip() {
|
||||
$search = $this->db()->escape(trim($this->post['search']));
|
||||
if(!$search) {
|
||||
$get = array_merge($this->post, $this->get);
|
||||
|
||||
$search = trim($get['search']);
|
||||
$zip = trim($get['zip']);
|
||||
|
||||
if(!$search && !$zip) {
|
||||
return mfResponse::BadRequest(['message' => "Searchstring cannot be empty!"]);
|
||||
}
|
||||
|
||||
$results = ADBPlzModel::search(['plzstring%' => $search]);
|
||||
if(!$zip) {
|
||||
$zip = $search;
|
||||
}
|
||||
|
||||
$results = ADBPlzModel::search(['plzstring%' => $zip]);
|
||||
|
||||
|
||||
$zips = [];
|
||||
@@ -79,12 +93,30 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
}
|
||||
|
||||
protected function findStreet() {
|
||||
$search = $this->db()->escape(trim($this->post['search']));
|
||||
if(!$search) {
|
||||
return mfResponse::BadRequest(['message' => "Searchstring cannot be empty!"]);
|
||||
$get = array_merge($this->post, $this->get);
|
||||
|
||||
$search = trim($get['search']);
|
||||
$street = trim($get['street']);
|
||||
$city = trim($get['city']);
|
||||
$zip = trim($get['zip']);
|
||||
|
||||
if(!$search && !$street && !$city && !$zip) {
|
||||
return mfResponse::BadRequest(['message' => "No search parameters"]);
|
||||
}
|
||||
|
||||
$results = ADBStrasseModel::search(['name%' => $search]);
|
||||
if(!$street) {
|
||||
$street = $search;
|
||||
}
|
||||
|
||||
$street_search = ["name%" => $street];
|
||||
if($city) {
|
||||
$street_search['gemeinde%'] = $city;
|
||||
}
|
||||
if($zip) {
|
||||
$street_search['plz%'] = $zip;
|
||||
}
|
||||
|
||||
$results = ADBStrasseModel::search($street_search);
|
||||
|
||||
|
||||
$streets = [];
|
||||
@@ -97,10 +129,12 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
}
|
||||
|
||||
protected function find() {
|
||||
$search_street = $this->db()->escape(trim($this->post['street']));
|
||||
$search_zip = $this->db()->escape(trim($this->post['zip']));
|
||||
$search_city = $this->db()->escape(trim($this->post['city']));
|
||||
$search_housenumber = $this->db()->escape(trim($this->post['housenumber']));
|
||||
$get = array_merge($this->post, $this->get);
|
||||
|
||||
$search_street = $this->db()->escape(trim($get['street']));
|
||||
$search_zip = $this->db()->escape(trim($get['zip']));
|
||||
$search_city = $this->db()->escape(trim($get['city']));
|
||||
$search_housenumber = $this->db()->escape(trim($get['housenumber']));
|
||||
|
||||
|
||||
if(!$search_street) {
|
||||
@@ -109,7 +143,7 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
|
||||
$addresses = [];
|
||||
|
||||
$where = "1 = 1";
|
||||
$where = "1=1";
|
||||
|
||||
if($search_zip) {
|
||||
$where .= " AND plz like '%$search_zip%'";
|
||||
@@ -124,9 +158,7 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
$where .= " AND hausnummer like '%$search_housenumber%'";
|
||||
}
|
||||
|
||||
//$res = $this->db()->select("view_wohneinheit_plz", "*", $where);
|
||||
$sql = "SELECT * FROM view_wohneinheit WHERE $where ORDER BY plz, gemeinde, ortschaft, strasse, LENGTH(hausnummer), hausnummer, block, stiege, stock, LENGTH(tuer), tuer";
|
||||
//echo $sql;exit;
|
||||
$res = $this->db()->query($sql);
|
||||
|
||||
if($this->db()->num_rows($res)) {
|
||||
|
||||
@@ -2,9 +2,6 @@ openapi: 3.0.1
|
||||
info:
|
||||
title: thetool Preorder API
|
||||
description: API Dokumentation für thetool Vorbestellung
|
||||
contact:
|
||||
name: thetool Development Team
|
||||
email: thetool-api-support@xinon.at
|
||||
license:
|
||||
name: Apache 2.0 License
|
||||
url: http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
@@ -14,34 +11,38 @@ servers:
|
||||
- url: https://thetool.xinon.at/api/v1
|
||||
tags:
|
||||
- name: addressdb
|
||||
description: Abfrage von GWR Daten
|
||||
description: Abfrage von GWR-Daten
|
||||
- name: preorder
|
||||
description: Informationen zum Netzgebiet und Speichern von Vorbestellungen
|
||||
paths:
|
||||
/addressdb/findAddress:
|
||||
post:
|
||||
get:
|
||||
tags:
|
||||
- addressdb
|
||||
summary: Adressen suchen
|
||||
description: Sucht nach Adressen
|
||||
description: Sucht nach Adressen. Retourniert Adressen mit Wohneinheiten
|
||||
operationId: findAddresses
|
||||
requestBody:
|
||||
description: |
|
||||
addressSearchRequest object
|
||||
|
||||
Parameter müssen mindestens 3 Zeichen lang sein
|
||||
|
||||
`street` ist erforderlich
|
||||
|
||||
`zip` muss mindestens 2 Zeichen lang sein
|
||||
required: true
|
||||
content:
|
||||
'application/json':
|
||||
schema:
|
||||
$ref: '#/components/schemas/Address'
|
||||
'application/x-www-form-urlencoded':
|
||||
schema:
|
||||
$ref: '#/components/schemas/Address'
|
||||
parameters:
|
||||
- name: street
|
||||
description: Straße Suchbegriff
|
||||
in: query
|
||||
schema:
|
||||
type: string
|
||||
- name: zip
|
||||
description: Postleitzahl Suchbegriff
|
||||
in: query
|
||||
schema:
|
||||
type: string
|
||||
- name: city
|
||||
description: Stadt Suchbegriff
|
||||
in: query
|
||||
schema:
|
||||
type: string
|
||||
- name: housenumber
|
||||
description: Hausnummer Suchbegriff
|
||||
in: query
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
'200':
|
||||
description: Successful operation
|
||||
@@ -67,22 +68,28 @@ paths:
|
||||
'401':
|
||||
description: Unauthorized
|
||||
/addressdb/findStreet:
|
||||
post:
|
||||
get:
|
||||
tags:
|
||||
- addressdb
|
||||
summary: Straßen suchen
|
||||
description: Sucht nach Straßen
|
||||
operationId: findStreets
|
||||
requestBody:
|
||||
description: addressComponentSearchRequest object. Parameter `search` muss mindestens 3 Zeichen lang sein.
|
||||
required: true
|
||||
content:
|
||||
'application/json':
|
||||
schema:
|
||||
$ref: '#/components/schemas/addressComponentSearchRequest'
|
||||
'application/x-www-form-urlencoded':
|
||||
schema:
|
||||
$ref: '#/components/schemas/addressComponentSearchRequest'
|
||||
parameters:
|
||||
- name: street
|
||||
description: Straße Suchbegriff
|
||||
in: query
|
||||
schema:
|
||||
type: string
|
||||
- name: zip
|
||||
description: Postleitzahl Suchbegriff
|
||||
in: query
|
||||
schema:
|
||||
type: string
|
||||
- name: city
|
||||
description: Stadt Suchbegriff
|
||||
in: query
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
'200':
|
||||
description: Successful operation
|
||||
@@ -108,22 +115,18 @@ paths:
|
||||
'401':
|
||||
description: Unauthorized
|
||||
/addressdb/findZip:
|
||||
post:
|
||||
get:
|
||||
tags:
|
||||
- addressdb
|
||||
summary: Postleitzahlen suchen
|
||||
description: Sucht nach Postleitzahlen
|
||||
operationId: findZips
|
||||
requestBody:
|
||||
description: zipSearchRequest object. Parameter `search` muss mindestens 2 Zeichen lang sein.
|
||||
required: true
|
||||
content:
|
||||
'application/json':
|
||||
schema:
|
||||
$ref: '#/components/schemas/zipComponentSearchRequest'
|
||||
'application/x-www-form-urlencoded':
|
||||
schema:
|
||||
$ref: '#/components/schemas/zipComponentSearchRequest'
|
||||
parameters:
|
||||
- name: zip
|
||||
description: Postleitzahl Suchbegriff
|
||||
in: query
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
'200':
|
||||
description: Successful operation
|
||||
@@ -149,22 +152,23 @@ paths:
|
||||
'401':
|
||||
description: Unauthorized
|
||||
/addressdb/findCity:
|
||||
post:
|
||||
get:
|
||||
tags:
|
||||
- addressdb
|
||||
summary: Ortschaften suchen
|
||||
description: Sucht nach Ortschaften
|
||||
summary: Gemeinden suchen
|
||||
description: Sucht nach Gemeinden
|
||||
operationId: findCity
|
||||
requestBody:
|
||||
description: addressComponentSearchRequest object. Parameter `search` muss mindestens 3 Zeichen lang sein.
|
||||
required: true
|
||||
content:
|
||||
'application/json':
|
||||
schema:
|
||||
$ref: '#/components/schemas/addressComponentSearchRequest'
|
||||
'application/x-www-form-urlencoded':
|
||||
schema:
|
||||
$ref: '#/components/schemas/addressComponentSearchRequest'
|
||||
parameters:
|
||||
- name: zip
|
||||
description: Postleitzahl Suchbegriff
|
||||
in: query
|
||||
schema:
|
||||
type: string
|
||||
- name: city
|
||||
description: Stadt Suchbegriff
|
||||
in: query
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
'200':
|
||||
description: Successful operation
|
||||
@@ -315,20 +319,6 @@ paths:
|
||||
# description: Vorbestellung nicht gefunden
|
||||
components:
|
||||
schemas:
|
||||
addressComponentSearchRequest:
|
||||
type: object
|
||||
properties:
|
||||
search:
|
||||
type: string
|
||||
description: Suchbegriff von mindestens 3 Zeichen Länge
|
||||
minLength: 3
|
||||
zipComponentSearchRequest:
|
||||
type: object
|
||||
properties:
|
||||
search:
|
||||
type: string
|
||||
description: Suchbegriff von mindestens 2 Zeichen Länge
|
||||
minLength: 2
|
||||
Zips:
|
||||
type: array
|
||||
items:
|
||||
@@ -359,7 +349,7 @@ components:
|
||||
description: PLZ
|
||||
city:
|
||||
type: string
|
||||
description: Ortschaft
|
||||
description: Gemeinde
|
||||
required:
|
||||
- street
|
||||
addressResponse:
|
||||
@@ -434,7 +424,7 @@ components:
|
||||
| apartment | Wohneinheit in Mehrparteienhaus
|
||||
| business | Gewerbebetrieb |
|
||||
connectionCount:
|
||||
type: int
|
||||
type: integer
|
||||
default: 1
|
||||
description: Anzahl Anschlüsse für Rabatt bei mehreren Anschlüssen in Mehrfamilienhaus
|
||||
nullable: true
|
||||
@@ -558,13 +548,12 @@ components:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: int
|
||||
type: integer
|
||||
description: status ID
|
||||
example: 220
|
||||
text:
|
||||
type: string
|
||||
description: Statustext
|
||||
|
||||
example: Tiefbau abgeschlossen, Leitungsbau ausständig
|
||||
securitySchemes:
|
||||
api_key_header:
|
||||
|
||||
Reference in New Issue
Block a user