Initial commit

This commit is contained in:
2026-07-05 21:52:31 +02:00
commit 93259f5b6d
35 changed files with 2389 additions and 0 deletions
+103
View File
@@ -0,0 +1,103 @@
<?php
namespace OCA\MoneyPlanner\Controller;
use Exception;
use OCP\IRequest;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Controller;
use OCA\MoneyPlanner\Service\TransactionService;
class TransactionController extends Controller {
private $service;
private $userId;
use Errors;
public function __construct(string $AppName, IRequest $request, TransactionService $service, $UserId){
parent::__construct($AppName, $request);
$this->service = $service;
$this->userId = $UserId;
}
/**
* @NoAdminRequired
*/
public function index() {
return new DataResponse($this->service->findAll($this->userId));
}
/**
* @NoAdminRequired
*
* @param int $id
*/
public function show(int $id) {
return $this->handleNotFound(function () use ($id) {
return $this->service->find($id, $this->userId);
});
}
/**
* @NoAdminRequired
*/
public function create(
$accountFrom,
$accountTo,
$group,
$category,
$balance,
$date,
$freqNum,
$freqType
) {
return $this->service->create(
$accountFrom, $accountTo, $group, $category,
$balance, $date, $freqNum, $freqType,
$this->userId
);
}
/**
* @NoAdminRequired
*/
public function update(
int $id,
$accountFrom,
$accountTo,
$group,
$category,
$balance,
$date,
$freqNum,
$freqType
) {
return $this->handleNotFound(function () use (
$id, $accountFrom, $accountTo, $group, $category,
$balance, $date, $freqNum, $freqType
) {
return $this->service->update(
$id, $accountFrom, $accountTo, $group, $category,
$balance, $date, $freqNum, $freqType,
$this->userId
);
});
}
/**
* @NoAdminRequired
*
* @param int $id
*/
public function destroy(int $id) {
return $this->handleNotFound(function () use ($id) {
return $this->service->delete($id, $this->userId);
});
}
}
?>