mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-20 00:12:15 +00:00
filterPerson unrulyPerson api & person model
This commit is contained in:
@@ -23,7 +23,8 @@ class UnrulyPerson extends FHCAPI_Controller
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'updatePersonUnrulyStatus' => array('basis/mitarbeiter:rw', 'student/antragfreigabe:rw', 'student/studierendenantrag:rw')
|
||||
'updatePersonUnrulyStatus' => array('basis/mitarbeiter:rw', 'student/antragfreigabe:rw', 'student/studierendenantrag:rw'),
|
||||
'filterPerson' => array('basis/mitarbeiter:rw', 'student/antragfreigabe:rw', 'student/studierendenantrag:rw')
|
||||
]);
|
||||
|
||||
$this->_ci =& get_instance();
|
||||
@@ -46,4 +47,64 @@ class UnrulyPerson extends FHCAPI_Controller
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function filterPerson() {
|
||||
$payload = json_decode($this->input->raw_input_stream, TRUE);
|
||||
|
||||
$nachnameString = '';
|
||||
$vornameString = '';
|
||||
$filterUnruly = true;
|
||||
$birthdateString = null;
|
||||
|
||||
if(array_key_exists( 'nachname', $payload) ) {
|
||||
$nachnameString = $payload['nachname'];
|
||||
}
|
||||
|
||||
if(array_key_exists('vorname', $payload)) {
|
||||
$vornameString = $payload['vorname'];
|
||||
}
|
||||
|
||||
if(array_key_exists('unruly', $payload)){
|
||||
$filterUnruly = $payload['unruly'];
|
||||
}
|
||||
|
||||
if(array_key_exists('gebdatum', $payload)) {
|
||||
// TODO: enable if gebdatum filter for unrulys is desired
|
||||
// $birthdateString = $payload['gebdatum'];
|
||||
}
|
||||
|
||||
$parametersArray = array($nachnameString);
|
||||
$where ="p.nachname~* ? ";
|
||||
if (mb_strlen($nachnameString) == 2)
|
||||
{
|
||||
$where = "p.nachname=? ";
|
||||
}
|
||||
|
||||
if(isset($vorname) && $vorname != '')
|
||||
{
|
||||
$where.= " AND p.vorname~*?";
|
||||
$parametersArray[] = $vorname;
|
||||
}
|
||||
|
||||
if(isset($birthdate) && $birthdate != '')
|
||||
{
|
||||
$where.=" AND p.gebdatum=?";
|
||||
$parametersArray[] = $birthdate;
|
||||
}
|
||||
|
||||
if(isset($filterUnruly))
|
||||
{
|
||||
$where.=" AND p.unruly=?";
|
||||
$parametersArray[] = $filterUnruly;
|
||||
}
|
||||
|
||||
$result = $this->_ci->PersonModel->checkUnrulyWhere($where, $parametersArray);
|
||||
|
||||
if (isSuccess($result))
|
||||
$this->terminateWithSuccess($result);
|
||||
else
|
||||
$this->terminateWithError('Error when searching for person');
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -264,4 +264,4 @@ class Person extends API_Controller
|
||||
|
||||
return success('Input data are valid');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -387,6 +387,15 @@ class Person_model extends DB_Model
|
||||
return $this->execQuery($qry, [$vorname, $nachname, $gebdatum]);
|
||||
}
|
||||
|
||||
public function checkUnrulyWhere($where, $paramsArray)
|
||||
{
|
||||
$qry = 'SELECT *
|
||||
FROM tbl_person p
|
||||
WHERE '.$where.';';
|
||||
|
||||
return $this->execQuery($qry, $paramsArray);
|
||||
}
|
||||
|
||||
public function updateUnruly($person_id, $unruly)
|
||||
{
|
||||
$result = $this->update($person_id, array(
|
||||
|
||||
@@ -9,5 +9,16 @@ export default {
|
||||
throw error;
|
||||
}
|
||||
|
||||
},
|
||||
filterPerson(payload, base = ''){
|
||||
|
||||
try {
|
||||
const url = base + '/api/frontend/v1/unrulyperson/UnrulyPerson/filterPerson';
|
||||
return axios.post(url, payload)
|
||||
// return this.$fhcApi.post(url, payload, null);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user