API Konsolodierung: stv lists

This commit is contained in:
cgfhtw
2024-04-30 08:33:39 +02:00
parent c2ffd02907
commit c8009a8a6c
3 changed files with 69 additions and 102 deletions
@@ -29,7 +29,11 @@ class Lists extends FHCAPI_Controller
{
parent::__construct([
'getStudiensemester' => self::PERM_LOGGED,
'getStgs' => self::PERM_LOGGED
'getStgs' => self::PERM_LOGGED,
'getSprachen' => self::PERM_LOGGED,
'getGeschlechter' => self::PERM_LOGGED,
'getAusbildungen' => self::PERM_LOGGED,
'getOrgforms' => self::PERM_LOGGED
]);
}
@@ -62,4 +66,56 @@ class Lists extends FHCAPI_Controller
$this->terminateWithSuccess($data);
}
public function getSprachen()
{
$this->load->model('system/Sprache_model', 'SpracheModel');
$this->SpracheModel->addOrder('sprache');
$result = $this->SpracheModel->load();
$data = $this->getDataOrTerminateWithError($result);
$this->terminateWithSuccess($data);
}
public function getGeschlechter()
{
$this->load->model('person/Geschlecht_model', 'GeschlechtModel');
$this->GeschlechtModel->addOrder('sort');
$this->GeschlechtModel->addOrder('geschlecht');
$this->GeschlechtModel->addSelect('*');
$this->GeschlechtModel->addSelect("bezeichnung_mehrsprachig[(SELECT index FROM public.tbl_sprache WHERE sprache=" . $this->GeschlechtModel->escape(DEFAULT_LANGUAGE) . " LIMIT 1)] AS bezeichnung");
$result = $this->GeschlechtModel->load();
$data = $this->getDataOrTerminateWithError($result);
$this->terminateWithSuccess($data);
}
public function getAusbildungen()
{
$this->load->model('codex/Ausbildung_model', 'AusbildungModel');
$this->AusbildungModel->addOrder('ausbildungcode');
$result = $this->AusbildungModel->load();
$data = $this->getDataOrTerminateWithError($result);
$this->terminateWithSuccess($data);
}
public function getOrgforms()
{
$this->load->model('codex/Orgform_model', 'OrgformModel');
$this->OrgformModel->addOrder('bezeichnung');
$result = $this->OrgformModel->loadWhere(['rolle' => true]);
$data = $this->getDataOrTerminateWithError($result);
$this->terminateWithSuccess($data);
}
}
@@ -1,85 +0,0 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
class Lists extends FHC_Controller
{
public function __construct()
{
// TODO(chris): access!
parent::__construct();
}
public function getSprachen()
{
$this->load->model('system/Sprache_model', 'SpracheModel');
$this->SpracheModel->addOrder('sprache');
$result = $this->SpracheModel->load();
if (isError($result)) {
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
}
$this->outputJson($result);
}
public function getGeschlechter()
{
$this->load->model('person/Geschlecht_model', 'GeschlechtModel');
$this->GeschlechtModel->addOrder('sort');
$this->GeschlechtModel->addOrder('geschlecht');
$this->GeschlechtModel->addSelect('*');
$this->GeschlechtModel->addSelect("bezeichnung_mehrsprachig[(SELECT index FROM public.tbl_sprache WHERE sprache=" . $this->GeschlechtModel->escape(DEFAULT_LANGUAGE) . " LIMIT 1)] AS bezeichnung");
$result = $this->GeschlechtModel->load();
if (isError($result)) {
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
}
$this->outputJson($result);
}
public function getAusbildungen()
{
$this->load->model('codex/Ausbildung_model', 'AusbildungModel');
$this->AusbildungModel->addOrder('ausbildungcode');
$result = $this->AusbildungModel->load();
if (isError($result)) {
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
}
$this->outputJson($result);
}
public function getStgs()
{
$this->load->model('organisation/Studiengang_model', 'StudiengangModel');
$this->StudiengangModel->addSelect('*');
$this->StudiengangModel->addSelect('UPPER(typ || kurzbz) AS kuerzel');
$this->StudiengangModel->addOrder('typ');
$this->StudiengangModel->addOrder('kurzbz');
$result = $this->StudiengangModel->loadWhere(['aktiv' => true]);
if (isError($result)) {
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
}
$this->outputJson($result);
}
public function getOrgforms()
{
$this->load->model('codex/Orgform_model', 'OrgformModel');
$this->OrgformModel->addOrder('bezeichnung');
$result = $this->OrgformModel->loadWhere(['rolle' => true]);
if (isError($result)) {
$this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
}
$this->outputJson($result);
}
}
+12 -16
View File
@@ -128,25 +128,22 @@ export default {
this.lists.nations = result;
})
.catch(this.$fhcAlert.handleSystemError);
CoreRESTClient
.get('components/stv/Lists/getSprachen')
.then(result => CoreRESTClient.getData(result.data) || [])
this.$fhcApi
.get('api/frontend/v1/stv/lists/getSprachen')
.then(result => {
this.lists.sprachen = result;
this.lists.sprachen = result.data;
})
.catch(this.$fhcAlert.handleSystemError);
CoreRESTClient
.get('components/stv/Lists/getGeschlechter')
.then(result => CoreRESTClient.getData(result.data) || [])
this.$fhcApi
.get('api/frontend/v1/stv/lists/getGeschlechter')
.then(result => {
this.lists.geschlechter = result;
this.lists.geschlechter = result.data;
})
.catch(this.$fhcAlert.handleSystemError);
CoreRESTClient
.get('components/stv/Lists/getAusbildungen')
.then(result => CoreRESTClient.getData(result.data) || [])
this.$fhcApi
.get('api/frontend/v1/stv/lists/getAusbildungen')
.then(result => {
this.lists.ausbildungen = result;
this.lists.ausbildungen = result.data;
})
.catch(this.$fhcAlert.handleSystemError);
this.$fhcApi
@@ -156,11 +153,10 @@ export default {
this.lists.active_stgs = this.lists.stgs.filter(stg => stg.aktiv);
})
.catch(this.$fhcAlert.handleSystemError);
CoreRESTClient
.get('components/stv/Lists/getOrgforms')
.then(result => CoreRESTClient.getData(result.data) || [])
this.$fhcApi
.get('api/frontend/v1/stv/lists/getOrgforms')
.then(result => {
this.lists.orgforms = result;
this.lists.orgforms = result.data;
})
.catch(this.$fhcAlert.handleSystemError);
this.$fhcApi