Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 47 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 1 |
FeedbacksEntityDao | |
0.00% |
0 / 47 |
|
0.00% |
0 / 5 |
30 | |
0.00% |
0 / 1 |
selectExistsFeedbacksBySequence | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
selectFeedbacksPageTotalCount | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
selectFeedbacksPageItems | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
2 | |||
insertFeedbacks | |
0.00% |
0 / 20 |
|
0.00% |
0 / 1 |
2 | |||
deleteFeedbacksBySequence | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace PeServer\App\Models\Dao\Entities; |
6 | |
7 | use PeServer\App\Models\Data\Dto\FeedbackDetailDto; |
8 | use PeServer\App\Models\Data\Dto\FeedbackListItemDto; |
9 | use PeServer\App\Models\Data\FeedbackDetail; |
10 | use PeServer\App\Models\Data\FeedbackListItem; |
11 | use PeServer\Core\Binary; |
12 | use PeServer\Core\Collection\Collections; |
13 | use PeServer\Core\Database\DaoBase; |
14 | use PeServer\Core\Database\DaoTrait; |
15 | use PeServer\Core\Database\DatabaseRowResult; |
16 | use PeServer\Core\Database\DatabaseTableResult; |
17 | use PeServer\Core\Database\IDatabaseContext; |
18 | use PeServer\Core\Serialization\Mapper; |
19 | |
20 | class FeedbacksEntityDao extends DaoBase |
21 | { |
22 | use DaoTrait; |
23 | |
24 | #region function |
25 | |
26 | /** |
27 | * フィードバックを主キー検索で有無確認。 |
28 | * |
29 | * @param int $sequence |
30 | * @return bool |
31 | */ |
32 | public function selectExistsFeedbacksBySequence(int $sequence): bool |
33 | { |
34 | return 1 === $this->context->selectSingleCount( |
35 | <<<SQL |
36 | |
37 | select |
38 | count(*) |
39 | from |
40 | feedbacks |
41 | where |
42 | sequence = :sequence |
43 | |
44 | SQL, |
45 | [ |
46 | 'sequence' => $sequence, |
47 | ] |
48 | ); |
49 | } |
50 | |
51 | /** |
52 | * フィードバック ページ 全件数取得。 |
53 | * |
54 | * @return int |
55 | * @phpstan-return non-negative-int |
56 | */ |
57 | public function selectFeedbacksPageTotalCount(): int |
58 | { |
59 | return $this->context->selectSingleCount( |
60 | <<<SQL |
61 | |
62 | select |
63 | count(*) |
64 | from |
65 | feedbacks |
66 | feedbacks |
67 | |
68 | SQL |
69 | ); |
70 | } |
71 | |
72 | |
73 | /** |
74 | * フィードバック ページ 表示データ取得。 |
75 | * |
76 | * @param int $index |
77 | * @phpstan-param non-negative-int $index |
78 | * @param int $count |
79 | * @phpstan-param non-negative-int $count |
80 | * @return FeedbackListItemDto[] |
81 | */ |
82 | public function selectFeedbacksPageItems(int $index, int $count): array |
83 | { |
84 | $result = $this->context->selectOrdered( |
85 | <<<SQL |
86 | |
87 | select |
88 | feedbacks.sequence, |
89 | feedbacks.timestamp, |
90 | feedbacks.version, |
91 | feedbacks.kind, |
92 | feedbacks.subject |
93 | from |
94 | feedbacks |
95 | order by |
96 | feedbacks.timestamp desc, |
97 | feedbacks.sequence desc |
98 | limit |
99 | :count |
100 | offset |
101 | :index |
102 | |
103 | SQL, |
104 | [ |
105 | 'index' => $index, |
106 | 'count' => $count, |
107 | ] |
108 | ); |
109 | |
110 | return $result->mapping(FeedbackListItemDto::class); |
111 | } |
112 | |
113 | public function insertFeedbacks( |
114 | string $ipAddress, |
115 | string $version, |
116 | string $revision, |
117 | string $build, |
118 | string $userId, |
119 | string $firstExecuteTimestamp, |
120 | string $firstExecuteVersion, |
121 | string $process, |
122 | string $platform, |
123 | string $os, |
124 | string $clr, |
125 | string $kind, |
126 | string $subject, |
127 | string $content |
128 | ): void { |
129 | $this->context->insertSingle( |
130 | <<<SQL |
131 | |
132 | insert into |
133 | feedbacks |
134 | ( |
135 | [timestamp], |
136 | [ip_address], |
137 | |
138 | [version], |
139 | [revision], |
140 | [build], |
141 | [user_id], |
142 | |
143 | [first_execute_timestamp], |
144 | [first_execute_version], |
145 | |
146 | [process], |
147 | [platform], |
148 | [os], |
149 | [clr], |
150 | |
151 | [kind], |
152 | [subject], |
153 | [content] |
154 | ) |
155 | values |
156 | ( |
157 | CURRENT_TIMESTAMP, |
158 | :ip_address, |
159 | |
160 | :version, |
161 | :revision, |
162 | :build, |
163 | :user_id, |
164 | |
165 | :first_execute_timestamp, |
166 | :first_execute_version, |
167 | |
168 | :process, |
169 | :platform, |
170 | :os, |
171 | :clr, |
172 | |
173 | :kind, |
174 | :subject, |
175 | :content |
176 | ) |
177 | |
178 | SQL, |
179 | [ |
180 | 'ip_address' => $ipAddress, |
181 | |
182 | 'version' => $version, |
183 | 'revision' => $revision, |
184 | 'build' => $build, |
185 | 'user_id' => $userId, |
186 | |
187 | 'first_execute_timestamp' => $firstExecuteTimestamp, |
188 | 'first_execute_version' => $firstExecuteVersion, |
189 | |
190 | 'process' => $process, |
191 | 'platform' => $platform, |
192 | 'os' => $os, |
193 | 'clr' => $clr, |
194 | |
195 | 'kind' => $kind, |
196 | 'subject' => $subject, |
197 | 'content' => $content, |
198 | ] |
199 | ); |
200 | } |
201 | |
202 | public function deleteFeedbacksBySequence(int $sequence): void |
203 | { |
204 | $this->context->deleteByKey( |
205 | <<<SQL |
206 | |
207 | delete |
208 | from |
209 | feedbacks |
210 | where |
211 | sequence = :sequence |
212 | |
213 | SQL, |
214 | [ |
215 | 'sequence' => $sequence, |
216 | ] |
217 | ); |
218 | } |
219 | |
220 | #endregion |
221 | } |