Guillermo - add creatae log architecture [skip ci]

This commit is contained in:
AntonyAntonio 2016-12-29 02:04:35 -03:00
parent b718598f32
commit c7cdfd7318
4 changed files with 15 additions and 4 deletions

View File

@ -5,6 +5,7 @@ require_once 'system/edit-settings.php';
require_once 'system/add-department.php'; require_once 'system/add-department.php';
require_once 'system/edit-department.php'; require_once 'system/edit-department.php';
require_once 'system/delete-department.php'; require_once 'system/delete-department.php';
require_once 'system/get-logs.php';
$systemControllerGroup = new ControllerGroup(); $systemControllerGroup = new ControllerGroup();
$systemControllerGroup->setGroupPath('/system'); $systemControllerGroup->setGroupPath('/system');
@ -15,6 +16,6 @@ $systemControllerGroup->addController(new EditSettingsController);
$systemControllerGroup->addController(new AddDepartmentController); $systemControllerGroup->addController(new AddDepartmentController);
$systemControllerGroup->addController(new EditDepartmentController); $systemControllerGroup->addController(new EditDepartmentController);
$systemControllerGroup->addController(new DeleteDepartmentController); $systemControllerGroup->addController(new DeleteDepartmentController);
$systemControllerGroup->addController(new GetLogsController);
$systemControllerGroup->finalize(); $systemControllerGroup->finalize();

View File

@ -18,5 +18,8 @@ class GetLogsController extends Controller {
public function handler() { public function handler() {
$page =Controller::request('page'); $page =Controller::request('page');
$logList = Log::find('LIMIT ? OFFSET ?', [10, 10*($page-1)+1]);
Response::respondSuccess($logList->toArray());
} }
} }

View File

@ -7,7 +7,7 @@ class Log extends DataStore {
public static function getProps() { public static function getProps() {
return [ return [
'type', 'type',
'author', 'authorUser',
'authorStaff', 'authorStaff',
'to' 'to'
]; ];
@ -20,10 +20,17 @@ class Log extends DataStore {
$log->setProperties(array( $log->setProperties(array(
'type' => $type, 'type' => $type,
'author' => (!$author->isNull() && !$author->staff) ? $author : null, 'authorUser' => (!$author->isNull() && !$author->staff) ? $author : null,
'authorStaff' => (!$author->isNull() && $author->staff) ? $author : null, 'authorStaff' => (!$author->isNull() && $author->staff) ? $author : null,
'to' => $to, 'to' => $to,
)); ));
$log->store(); $log->store();
} }
public function toArray() {
return [
'type' => $this->type,
'to' => $this->to,
'author' => ($this->authorUser) ? $this->authorUser->toArray() : $this->authorStaff->toArray()
];
}
} }

View File

@ -7,7 +7,7 @@ class Scripts
}) })
if response['status'] === 'fail' if response['status'] === 'fail'
raise 'Could not create user' raise response['message']
end end
end end