changes
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace OCA\Deck\Db;
|
||||
|
||||
use OCP\AppFramework\Db\Entity;
|
||||
use OCP\IDb;
|
||||
use OCP\AppFramework\Db\Mapper;
|
||||
|
||||
@@ -29,5 +30,8 @@ class BoardMapper extends Mapper {
|
||||
return $this->findEntities($sql, [$userId], $limit, $offset);
|
||||
}
|
||||
|
||||
|
||||
public function delete(Entity $entity) {
|
||||
// FIXME: delete linked elements, because owncloud doesn't support foreign keys for apps
|
||||
return parent::delete($entity);
|
||||
}
|
||||
}
|
||||
36
db/card.php
Normal file
36
db/card.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
// db/author.php
|
||||
namespace OCA\Deck\Db;
|
||||
|
||||
use JsonSerializable;
|
||||
use OCP\AppFramework\Db\Entity;
|
||||
|
||||
class Card extends Entity implements JsonSerializable {
|
||||
|
||||
public $id;
|
||||
protected $title;
|
||||
protected $stackId;
|
||||
protected $type;
|
||||
protected $lastModified;
|
||||
protected $createdAt;
|
||||
protected $owner;
|
||||
protected $order;
|
||||
public function __construct() {
|
||||
$this->addType('id','integer');
|
||||
$this->addType('stackId','integer');
|
||||
$this->addType('order','integer');
|
||||
}
|
||||
|
||||
public function jsonSerialize() {
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'title' => $this->title,
|
||||
'type' => $this->type,
|
||||
'lastModified' => $this->lastModified,
|
||||
'createdAt' => $this->createdAt,
|
||||
'owner' => $this->owner,
|
||||
'order' => $this->order,
|
||||
'stackId' => $this->stackId,
|
||||
];
|
||||
}
|
||||
}
|
||||
39
db/cardmapper.php
Normal file
39
db/cardmapper.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace OCA\Deck\Db;
|
||||
|
||||
use OCP\AppFramework\Db\Entity;
|
||||
use OCP\IDb;
|
||||
use OCP\AppFramework\Db\Mapper;
|
||||
|
||||
|
||||
|
||||
class CardMapper extends Mapper {
|
||||
|
||||
public function __construct(IDb $db) {
|
||||
parent::__construct($db, 'deck_cards', '\OCA\Deck\Db\Card');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @throws \OCP\AppFramework\Db\DoesNotExistException if not found
|
||||
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result
|
||||
*/
|
||||
public function find($id) {
|
||||
$sql = 'SELECT * FROM `*PREFIX*deck_cards` ' .
|
||||
'WHERE `id` = ?';
|
||||
return $this->findEntity($sql, [$id]);
|
||||
}
|
||||
|
||||
|
||||
public function findAll($stackId, $limit=null, $offset=null) {
|
||||
$sql = 'SELECT * FROM `*PREFIX*deck_cards` WHERE `stack_id` = ? ORDER BY `order`';
|
||||
return $this->findEntities($sql, [$stackId], $limit, $offset);
|
||||
}
|
||||
|
||||
public function delete(Entity $entity) {
|
||||
// FIXME: delete linked elements, because owncloud doesn't support foreign keys for apps
|
||||
return parent::delete($entity);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,6 +10,7 @@ class Stack extends Entity implements JsonSerializable {
|
||||
public $id;
|
||||
protected $title;
|
||||
protected $boardId;
|
||||
protected $cards = array();
|
||||
protected $order;
|
||||
public function __construct() {
|
||||
$this->addType('id','integer');
|
||||
@@ -17,12 +18,16 @@ class Stack extends Entity implements JsonSerializable {
|
||||
$this->addType('order','integer');
|
||||
|
||||
}
|
||||
public function setCards($cards) {
|
||||
$this->cards = $cards;
|
||||
}
|
||||
public function jsonSerialize() {
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'title' => $this->title,
|
||||
'order' => $this->order,
|
||||
'boardId' => $this->boardId
|
||||
'boardId' => $this->boardId,
|
||||
'cards' => $this->cards,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -2,14 +2,18 @@
|
||||
|
||||
namespace OCA\Deck\Db;
|
||||
|
||||
use OCP\AppFramework\Db\Entity;
|
||||
use OCP\IDb;
|
||||
use OCP\AppFramework\Db\Mapper;
|
||||
|
||||
|
||||
class StackMapper extends Mapper {
|
||||
|
||||
public function __construct(IDb $db) {
|
||||
private $cardMapper;
|
||||
|
||||
public function __construct(IDb $db, CardMapper $cardMapper) {
|
||||
parent::__construct($db, 'deck_stacks', '\OCA\Deck\Db\Stack');
|
||||
$this->cardMapper = $cardMapper;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,5 +33,8 @@ class StackMapper extends Mapper {
|
||||
return $this->findEntities($sql, [$boardId], $limit, $offset);
|
||||
}
|
||||
|
||||
|
||||
public function delete(Entity $entity) {
|
||||
// FIXME: delete linked elements, because owncloud doesn't support foreign keys for apps
|
||||
return parent::delete($entity);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user