Commit dea428e0 authored by SpinShare's avatar SpinShare

added istournament to entity, added api simplification

parent e2ddfc93
...@@ -45,26 +45,10 @@ class APISongController extends AbstractController ...@@ -45,26 +45,10 @@ class APISongController extends AbstractController
$em->persist($result); $em->persist($result);
$em->flush(); $em->flush();
$data['id'] = $result->getId(); $data = $result->getJSON();
$data['title'] = $result->getTitle();
$data['subtitle'] = $result->getSubtitle();
$data['artist'] = $result->getArtist();
$data['charter'] = $result->getCharter();
$data['hasEasyDifficulty'] = $result->getHasEasyDifficulty();
$data['hasNormalDifficulty'] = $result->getHasNormalDifficulty();
$data['hasHardDifficulty'] = $result->getHasHardDifficulty();
$data['hasExtremeDifficulty'] = $result->getHasExtremeDifficulty();
$data['hasXDDifficulty'] = $result->getHasXDDifficulty();
$data['uploader'] = $result->getUploader();
$data['uploadDate'] = $result->getUploadDate();
$data['tags'] = $result->getTagsArray();
$data['fileReference'] = $result->getFileReference();
$data['paths']['ogg'] = $baseUrl."/uploads/audio/".$result->getFileReference()."_0.ogg"; $data['paths']['ogg'] = $baseUrl."/uploads/audio/".$result->getFileReference()."_0.ogg";
$data['paths']['cover'] = $baseUrl."/uploads/thumbnail/".$result->getFileReference().".jpg"; $data['paths']['cover'] = $baseUrl."/uploads/thumbnail/".$result->getFileReference().".jpg";
$data['paths']['zip'] = $this->generateUrl('api.songs.download', array('id' => $result->getId()), UrlGeneratorInterface::ABSOLUTE_URL); $data['paths']['zip'] = $this->generateUrl('api.songs.download', array('id' => $result->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
$data['description'] = $result->getDescription();
$data['views'] = $result->getViews();
$data['downloads'] = $result->getDownloads();
$response = new JsonResponse(['version' => $this->getParameter('api_version'), 'status' => 200, 'data' => $data]); $response = new JsonResponse(['version' => $this->getParameter('api_version'), 'status' => 200, 'data' => $data]);
$response->headers->set('Access-Control-Allow-Origin', '*'); $response->headers->set('Access-Control-Allow-Origin', '*');
......
...@@ -68,6 +68,11 @@ class Song ...@@ -68,6 +68,11 @@ class Song
*/ */
private $isExplicit; private $isExplicit;
/**
* @ORM\Column(type="boolean", nullable=true, options={"default": false})
*/
private $isTournament;
/** /**
* @ORM\Column(type="boolean") * @ORM\Column(type="boolean")
*/ */
...@@ -249,6 +254,18 @@ class Song ...@@ -249,6 +254,18 @@ class Song
return $this; return $this;
} }
public function getIsTournament(): ?bool
{
return $this->isTournament;
}
public function setIsTournament(bool $isTournament): self
{
$this->isTournament = $isTournament;
return $this;
}
public function getHasEasyDifficulty(): ?bool public function getHasEasyDifficulty(): ?bool
{ {
return $this->hasEasyDifficulty; return $this->hasEasyDifficulty;
...@@ -394,4 +411,30 @@ class Song ...@@ -394,4 +411,30 @@ class Song
return $this; return $this;
} }
public function getJSON() {
$response = array(
'id' => $this->id,
'title' => $this->title,
'subtitle' => $this->subtitle,
'artist' => $this->artist,
'charter' => $this->charter,
'uploader' => $this->uploader,
'fileReference' => $this->fileReference,
'tags' => $this->getTagsArray(),
'views' => $this->views,
'downloads' => $this->downloads,
'isExplicit' => $this->isExplicit,
'isTournament' => $this->isTournament,
'hasEasyDifficulty' => $this->hasEasyDifficulty,
'hasNormalDifficulty' => $this->hasNormalDifficulty,
'hasHardDifficulty' => $this->hasHardDifficulty,
'hasExtremeDifficulty' => $this->hasExtremeDifficulty,
'hasXDDifficulty' => $this->hasXDDifficulty,
'uploadDate' => $this->uploadDate,
'description' => $this->description
);
return $response;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment