-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathRowController.php
More file actions
105 lines (93 loc) 路 2.56 KB
/
Copy pathRowController.php
File metadata and controls
105 lines (93 loc) 路 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
/**
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Tables\Controller;
use OCA\Tables\AppInfo\Application;
use OCA\Tables\Middleware\Attribute\RequirePermission;
use OCA\Tables\Service\RowService;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\DataResponse;
use OCP\IRequest;
use Psr\Log\LoggerInterface;
class RowController extends Controller {
use Errors;
public function __construct(
IRequest $request,
protected LoggerInterface $logger,
private RowService $service,
private ?string $userId,
) {
parent::__construct(Application::APP_ID, $request);
}
#[NoAdminRequired]
#[RequirePermission(permission: Application::PERMISSION_READ, type: Application::NODE_TYPE_TABLE, idParam: 'tableId')]
public function index(int $tableId): DataResponse {
return $this->handleError(function () use ($tableId) {
return $this->service->findAllByTable($tableId, $this->userId);
});
}
#[NoAdminRequired]
#[RequirePermission(permission: Application::PERMISSION_READ, type: Application::NODE_TYPE_VIEW, idParam: 'viewId')]
public function indexView(int $viewId): DataResponse {
return $this->handleError(function () use ($viewId) {
return $this->service->findAllByView($viewId, $this->userId);
});
}
#[NoAdminRequired]
public function show(int $id): DataResponse {
return $this->handleError(function () use ($id) {
return $this->service->find($id);
});
}
#[NoAdminRequired]
public function update(
int $id,
int $columnId,
?int $tableId,
?int $viewId,
string $data
): DataResponse {
return $this->handleError(function () use (
$id,
$tableId,
$viewId,
$columnId,
$data
) {
return $this->service->updateSet($id, $viewId, ['columnId' => $columnId, 'value' => $data], $this->userId);
});
}
#[NoAdminRequired]
public function updateSet(
int $id,
?int $viewId,
array $data
): DataResponse {
return $this->handleError(function () use (
$id,
$viewId,
$data
) {
return $this->service->updateSet(
$id,
$viewId,
$data,
$this->userId);
});
}
#[NoAdminRequired]
public function destroy(int $id): DataResponse {
return $this->handleError(function () use ($id) {
return $this->service->delete($id, null, $this->userId);
});
}
#[NoAdminRequired]
public function destroyByView(int $id, int $viewId): DataResponse {
return $this->handleError(function () use ($id, $viewId) {
return $this->service->delete($id, $viewId, $this->userId);
});
}
}