From 0534ab4ac2f183b2779eee3b1fde1db23aa89b94 Mon Sep 17 00:00:00 2001 From: cgfhtw Date: Thu, 25 Jul 2024 15:51:30 +0200 Subject: [PATCH] =?UTF-8?q?corrected=20Studienpl=C3=A4ne=20Query?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/frontend/v1/stv/Prestudent.php | 15 +++++------- .../models/organisation/Studienplan_model.php | 23 +++++++++---------- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/application/controllers/api/frontend/v1/stv/Prestudent.php b/application/controllers/api/frontend/v1/stv/Prestudent.php index 8e9e0bf0b..635358808 100644 --- a/application/controllers/api/frontend/v1/stv/Prestudent.php +++ b/application/controllers/api/frontend/v1/stv/Prestudent.php @@ -264,18 +264,15 @@ class Prestudent extends FHCAPI_Controller return $this->terminateWithSuccess(getData($result) ?: []); } - public function getStudienplaene($prestudent_ids) + public function getStudienplaene($prestudent_id) { - $prestudent_ids = urldecode($prestudent_ids); - + if (!is_int($prestudent_id)) + show_404(); $this->load->model('organisation/Studienplan_model', 'StudienplanModel'); - $result = $this->StudienplanModel->getStudienplaeneByPrestudents($prestudent_ids); + $result = $this->StudienplanModel->getStudienplaeneByPrestudents($prestudent_id); + $data = $this->getDataOrTerminateWithError($result); - if (isError($result)) - { - $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); - } - return $this->terminateWithSuccess(getData($result) ?: []); + return $this->terminateWithSuccess($data); } } diff --git a/application/models/organisation/Studienplan_model.php b/application/models/organisation/Studienplan_model.php index 3c6e0b2d2..e35ba52fb 100644 --- a/application/models/organisation/Studienplan_model.php +++ b/application/models/organisation/Studienplan_model.php @@ -120,19 +120,18 @@ class Studienplan_model extends DB_Model ]); } - public function getStudienplaeneByPrestudents($prestudentIds) + public function getStudienplaeneByPrestudents($prestudent_id) { - $prestudentIds = intVal($prestudentIds); + $this->addDistinct(); + $this->addSelect($this->dbTable . '.*'); + $this->addSelect('sem.start AS start_stsem'); + $this->addJoin('lehre.tbl_studienordnung o', 'studienordnung_id'); + $this->addJoin('public.tbl_prestudent p', 'studiengang_kz'); + $this->addJoin('public.tbl_studiensemester sem', 'sem.studiensemester_kurzbz = o.gueltigvon', 'LEFT'); + $this->addOrder('sem.start'); - $query = " - SELECT so.studienordnung_id, sp.bezeichnung - FROM public.tbl_prestudent ps - JOIN lehre.tbl_studienordnung so ON (ps.studiengang_kz = so.studiengang_kz) - JOIN lehre.tbl_studienplan sp ON (sp.studienordnung_id = so.studienordnung_id) - WHERE ps.prestudent_id IN (?) - ORDER BY so.studienordnung_id DESC - "; - - return $this->execQuery($query, array($prestudentIds)); + return $this->loadWhere([ + 'prestudent_id' => $prestudent_id + ]); } }