Compare commits
No commits in common. "ec485fb03df8d8de8754ffd4def6976505649008" and "0334c7022d361d7b9cbfe9ae7366840db6f084ad" have entirely different histories.
ec485fb03d
...
0334c7022d
@ -10,6 +10,13 @@ final class FingerprintPostController extends AbstractController
|
|||||||
'userId',
|
'userId',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function __construct(string $url)
|
||||||
|
{
|
||||||
|
parent::__construct($url);
|
||||||
|
|
||||||
|
$this->response = new ApiJsonResponse();
|
||||||
|
}
|
||||||
|
|
||||||
public function handle(): void
|
public function handle(): void
|
||||||
{
|
{
|
||||||
parent::handle();
|
parent::handle();
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
final class SharingDeleteController extends AbstractController
|
|
||||||
{
|
|
||||||
protected string $route = '/api/v1/sharing/{sharingId}';
|
|
||||||
|
|
||||||
private int $sharingId;
|
|
||||||
|
|
||||||
public function __construct(string $url)
|
|
||||||
{
|
|
||||||
parent::__construct($url);
|
|
||||||
|
|
||||||
$this->sharingId = (int)$this->getUrlParamInt('sharingId');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handle(): void
|
|
||||||
{
|
|
||||||
parent::handle();
|
|
||||||
|
|
||||||
if ($this->response->getStatus() !== ServerStatus::OK) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
$sharing = new Sharing($this->sharingId);
|
|
||||||
$sharing->Delete();
|
|
||||||
|
|
||||||
$this->response = new ApiJsonResponse();
|
|
||||||
$this->response->setParameter('success', true);
|
|
||||||
} catch (Throwable $e) {
|
|
||||||
$this->response = new ApiJsonResponse(ServerStatus::BAD_REQUEST);
|
|
||||||
$this->response->setParameter('success', false);
|
|
||||||
$this->response->setMessage($e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,38 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
final class SharingGetController extends AbstractController
|
|
||||||
{
|
|
||||||
protected string $route = '/api/v1/sharing/{sharingId}';
|
|
||||||
|
|
||||||
private int $sharingId;
|
|
||||||
|
|
||||||
public function __construct(string $url)
|
|
||||||
{
|
|
||||||
parent::__construct($url);
|
|
||||||
|
|
||||||
$this->sharingId = (int)$this->getUrlParamInt('sharingId');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handle(): void
|
|
||||||
{
|
|
||||||
parent::handle();
|
|
||||||
|
|
||||||
if ($this->response->getStatus() !== ServerStatus::OK) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
$sharing = new Sharing($this->sharingId);
|
|
||||||
|
|
||||||
$this->response = new ApiJsonResponse();
|
|
||||||
$this->response->setParameter('success', true);
|
|
||||||
$this->response->setResult($sharing);
|
|
||||||
} catch (Throwable $e) {
|
|
||||||
$this->response = new ApiJsonResponse(ServerStatus::BAD_REQUEST);
|
|
||||||
$this->response->setParameter('success', false);
|
|
||||||
$this->response->setMessage($e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
final class SharingPostController extends AbstractController
|
|
||||||
{
|
|
||||||
protected string $route = '/api/v1/sharing';
|
|
||||||
protected array $mandatoryAttributes = [
|
|
||||||
'userId',
|
|
||||||
'userSharedId',
|
|
||||||
];
|
|
||||||
|
|
||||||
public function handle(): void
|
|
||||||
{
|
|
||||||
parent::handle();
|
|
||||||
|
|
||||||
if ($this->response->getStatus() !== ServerStatus::OK) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$json = json_decode($this->requestBody);
|
|
||||||
|
|
||||||
try {
|
|
||||||
$sharing = new Sharing();
|
|
||||||
$sharing->setUserId($json->userId);
|
|
||||||
$sharing->setUserShared($json->userSharedId);
|
|
||||||
$sharing->Save();
|
|
||||||
|
|
||||||
$this->response = new ApiJsonResponse();
|
|
||||||
$this->response->setParameter('sharingId', $sharing->getSharingId());
|
|
||||||
} catch (Throwable $e) {
|
|
||||||
$this->response = new ApiJsonResponse(ServerStatus::BAD_REQUEST);
|
|
||||||
$this->response->setMessage($e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
final class Sharing extends MySqlTable implements JsonSerializable
|
final class Sharing extends MySqlTable
|
||||||
{
|
{
|
||||||
public const FIELD_USER = 'User';
|
public const FIELD_USER = 'User';
|
||||||
public const FIELD_USER_SHARED = 'UserShared';
|
public const FIELD_USER_SHARED = 'UserShared';
|
||||||
@ -40,13 +40,4 @@ final class Sharing extends MySqlTable implements JsonSerializable
|
|||||||
{
|
{
|
||||||
$this->setField(self::FIELD_USER_SHARED, $userShared);
|
$this->setField(self::FIELD_USER_SHARED, $userShared);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function jsonSerialize()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'sharingId' => $this->getSharingId(),
|
|
||||||
'userId' => $this->getUserId(),
|
|
||||||
'userSharedId' => $this->getUserShared(),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user