Studienjahr getAktNext endpoint

This commit is contained in:
chfhtw
2026-09-10 08:59:49 +02:00
parent f6efef36ef
commit 28b1269324
2 changed files with 55 additions and 1 deletions
@@ -24,7 +24,8 @@ class Studienjahr extends FHCAPI_Controller
parent::__construct(
array(
'getAll' => self::PERM_LOGGED,
'getNext' => self::PERM_LOGGED
'getNext' => self::PERM_LOGGED,
'getAktNext' => self::PERM_LOGGED
)
);
// Load model StudiensemesterModel
@@ -77,4 +78,32 @@ class Studienjahr extends FHCAPI_Controller
$this->terminateWithSuccess(current(getData($result)));
}
public function getAktNext()
{
$this->StudienjahrModel->addJoin('public.tbl_studiensemester', 'studienjahr_kurzbz');
$this->StudienjahrModel->addOrder('ende');
$this->StudienjahrModel->addLimit(1);
$result = $this->StudienjahrModel->loadWhere([
'start <=' => 'NOW()',
'ende >=' => 'NOW()'
]);
$data = $this->getDataOrTerminateWithError($result);
if (!$data) {
$this->StudienjahrModel->addJoin('public.tbl_studiensemester', 'studienjahr_kurzbz');
$this->StudienjahrModel->addOrder('ende');
$this->StudienjahrModel->addLimit(1);
$result = $this->StudienjahrModel->loadWhere([
'ende >=' => 'NOW()'
]);
$data = $this->getDataOrTerminateWithError($result);
}
$this->terminateWithSuccess(current($data));
}
}
+25
View File
@@ -0,0 +1,25 @@
/**
* Copyright (C) 2026 fhcomplete.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
export default {
getAktNext() {
return {
method: 'get',
url: '/api/frontend/v1/organisation/studienjahr/getAktNext',
};
},
};