Added /findDistrict to api docs; optimized findDistrict query
This commit is contained in:
@@ -123,22 +123,22 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
if(!$district) {
|
||||
$district = $search;
|
||||
}
|
||||
|
||||
/*
|
||||
if(!$city && !$zip && !$district) {
|
||||
return mfResponse::BadRequest(['message' => "No search parameters"]);
|
||||
}
|
||||
}*/
|
||||
|
||||
$where = "1=1";
|
||||
|
||||
if($district) {
|
||||
if($district && $district != "%") {
|
||||
$city_search = ['ortschaft%' => $district];
|
||||
$where .= " AND ortschaft like '$district%'";
|
||||
}
|
||||
if($city) {
|
||||
if($city && $city != "%") {
|
||||
$city_search = ['name%' => $city];
|
||||
$where .= " AND gemeinde like '$city%'";
|
||||
}
|
||||
if($zip) {
|
||||
if($zip && $zip != "%") {
|
||||
$city_search['plz%'] = $zip;
|
||||
$where .= " AND plz like '$zip%'";
|
||||
}
|
||||
@@ -150,7 +150,8 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
|
||||
$cities = [];
|
||||
|
||||
$sql = "SELECT gemeinde, ortschaft FROM view_hausnummer WHERE $where GROUP BY gemeinde,ortschaft_id";
|
||||
$sql = "SELECT gemeinde, ortschaft FROM view_hausnummer WHERE $where GROUP BY gemeinde,ortschaft_id ORDER BY gemeinde, ortschaft";
|
||||
//echo $sql;exit;
|
||||
$res = $this->db()->query($sql);
|
||||
if($this->db()->num_rows($res)) {
|
||||
while($data = $this->db()->fetch_object($res)) {
|
||||
|
||||
@@ -203,6 +203,48 @@ paths:
|
||||
Parameter missing or malformed
|
||||
'401':
|
||||
description: Unauthorized
|
||||
/addressdb/findDistrict:
|
||||
get:
|
||||
tags:
|
||||
- addressdb
|
||||
summary: Ortsteile suchen
|
||||
description: Sucht nach Ortsteilen
|
||||
operationId: findDistrict
|
||||
parameters:
|
||||
- name: zip
|
||||
description: Postleitzahl Suchbegriff
|
||||
in: query
|
||||
schema:
|
||||
type: string
|
||||
- name: city
|
||||
description: Gemeinde Suchbegriff
|
||||
in: query
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
'200':
|
||||
description: Successful operation
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
status:
|
||||
type: string
|
||||
description: Status string
|
||||
example: OK
|
||||
result:
|
||||
type: object
|
||||
properties:
|
||||
cities:
|
||||
$ref: '#/components/schemas/CityDistricts'
|
||||
'400':
|
||||
description: |
|
||||
Bad Request
|
||||
|
||||
Parameter missing or malformed
|
||||
'401':
|
||||
description: Unauthorized
|
||||
/preorder:
|
||||
post:
|
||||
tags:
|
||||
@@ -360,6 +402,18 @@ components:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
CityDistricts:
|
||||
type: object
|
||||
additionalProperties:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
example:
|
||||
Premstätten:
|
||||
- Hautzendorf
|
||||
- Laa
|
||||
- Oberpremstätten
|
||||
- Unterpremstätten
|
||||
Streets:
|
||||
type: array
|
||||
items:
|
||||
|
||||
Reference in New Issue
Block a user