Added getClusters api endpoint
This commit is contained in:
@@ -114,6 +114,15 @@ class ADBNetzgebietModel {
|
||||
private static function getSqlFilter($filter) {
|
||||
$where = "1=1 ";
|
||||
|
||||
if(array_key_exists("netzgebiet_id", $filter)) {
|
||||
$netzgebiet_id = $filter['netzgebiet_id'];
|
||||
if(is_numeric($netzgebiet_id)) {
|
||||
$where .= " AND Netzgebiet.netzgebiet_id=$netzgebiet_id";
|
||||
} elseif(is_array($netzgebiet_id) && count($netzgebiet_id)) {
|
||||
$where .= " AND Netzgebiet.id IN (". implode(",", $netzgebiet_id).")";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("name", $filter)) {
|
||||
$name = FronkDB::singleton()->escape($filter['name']);
|
||||
if($name) {
|
||||
|
||||
@@ -11,6 +11,7 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
protected function init() {
|
||||
$db = $this->db(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
|
||||
$this->addRoute("/addressdb/getClusters", "getClusters", "GET");
|
||||
$this->addRoute("/addressdb/findAddress", "find", "GET");
|
||||
$this->addRoute("/addressdb/findAddress", "find", "POST");
|
||||
$this->addRoute("/addressdb/searchAddress", "search", "GET");
|
||||
@@ -71,6 +72,23 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
|
||||
}
|
||||
|
||||
protected function getClusters() {
|
||||
$cluster_search = [];
|
||||
if(count($this->filter_salescluster_ids)) {
|
||||
$cluster_search['netzgebiet_id'] = $this->filter_salescluster_ids;
|
||||
}
|
||||
$clusters = [];
|
||||
foreach(ADBNetzgebietModel::search($cluster_search) as $cluster) {
|
||||
$c = [];
|
||||
$c['id'] = $cluster->extref;
|
||||
$c['name'] = $cluster->name;
|
||||
$clusters[] = $c;
|
||||
}
|
||||
|
||||
return mfResponse::Ok(["clusters" => $clusters]);
|
||||
|
||||
}
|
||||
|
||||
protected function findCity() {
|
||||
// unofficially supporting GET and POST in v1
|
||||
$get = array_merge($this->post, $this->get);
|
||||
|
||||
Reference in New Issue
Block a user