Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 18 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
AccountUserAuditLogLogic | |
0.00% |
0 / 18 |
|
0.00% |
0 / 3 |
42 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
validateImpl | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
executeImpl | |
0.00% |
0 / 16 |
|
0.00% |
0 / 1 |
20 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace PeServer\App\Models\Domain\Page\Account; |
6 | |
7 | use PeServer\App\Models\Dao\Entities\UserAuditLogsEntityDao; |
8 | use PeServer\App\Models\Domain\Page\PageLogicBase; |
9 | use PeServer\Core\Mvc\LogicCallMode; |
10 | use PeServer\Core\Mvc\LogicParameter; |
11 | use PeServer\Core\Mvc\Pagination; |
12 | use PeServer\Core\Throws\InvalidOperationException; |
13 | use PeServer\Core\TypeUtility; |
14 | |
15 | class AccountUserAuditLogLogic extends PageLogicBase |
16 | { |
17 | #region define |
18 | |
19 | public const ITEM_COUNT_IN_PAGE = 10; |
20 | |
21 | #endregion |
22 | |
23 | public function __construct(LogicParameter $parameter) |
24 | { |
25 | parent::__construct($parameter); |
26 | } |
27 | |
28 | #region PageLogicBase |
29 | |
30 | protected function validateImpl(LogicCallMode $callMode): void |
31 | { |
32 | //NOP |
33 | } |
34 | |
35 | protected function executeImpl(LogicCallMode $callMode): void |
36 | { |
37 | $userInfo = $this->getAuditUserInfo(); |
38 | if ($userInfo === null) { |
39 | throw new InvalidOperationException(); |
40 | } |
41 | $userId = $userInfo->getUserId(); |
42 | |
43 | $pageNumber = Pagination::FIRST_PAGE_NUMBER; |
44 | if ($callMode === LogicCallMode::Submit) { |
45 | $requestPageNumber = $this->getRequest('page_number'); |
46 | if (TypeUtility::tryParsePositiveInteger($requestPageNumber, $temp)) { |
47 | $pageNumber = $temp; |
48 | } |
49 | } |
50 | |
51 | $database = $this->openDatabase(); |
52 | $userAuditLogsEntityDao = new UserAuditLogsEntityDao($database); |
53 | |
54 | $totalCount = $userAuditLogsEntityDao->selectAuditLogsPageTotalCountFromUserId($userId); |
55 | $pagination = new Pagination($pageNumber, self::ITEM_COUNT_IN_PAGE, $totalCount); |
56 | $items = $userAuditLogsEntityDao->selectAuditLogsPageItemsFromUserId($userId, ($pagination->currentPageNumber - 1) * $pagination->itemCountInPage, $pagination->itemCountInPage); |
57 | |
58 | $this->setValue('items', $items); |
59 | $this->setValue('pager', $pagination); |
60 | } |
61 | |
62 | #endregion |
63 | } |