Initial COmmit WIP

This commit is contained in:
Julius Haertl
2016-06-05 15:07:47 +02:00
commit e10fe82afb
55 changed files with 6366 additions and 0 deletions

26
db/board.php Normal file
View File

@@ -0,0 +1,26 @@
<?php
// db/author.php
namespace OCA\Deck\Db;
use JsonSerializable;
use OCP\AppFramework\Db\Entity;
class Board extends Entity implements JsonSerializable {
public $id;
protected $title;
protected $owner;
protected $color;
protected $archived;
public function __construct() {
$this->addType('id','integer');
}
public function jsonSerialize() {
return [
'id' => $this->id,
'title' => $this->title,
'owner' => $this->owner,
'color' => $this->color
];
}
}

33
db/boardmapper.php Normal file
View File

@@ -0,0 +1,33 @@
<?php
namespace OCA\Deck\Db;
use OCP\IDb;
use OCP\AppFramework\Db\Mapper;
class BoardMapper extends Mapper {
public function __construct(IDb $db) {
parent::__construct($db, 'deck_boards', '\OCA\Deck\Db\Board');
}
/**
* @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_boards` ' .
'WHERE `id` = ?';
return $this->findEntity($sql, [$id]);
}
public function findAll($userId, $limit=null, $offset=null) {
$sql = 'SELECT * FROM `*PREFIX*deck_boards` WHERE `owner` = ? ORDER BY `title`';
return $this->findEntities($sql, [$userId], $limit, $offset);
}
}

28
db/stack.php Normal file
View File

@@ -0,0 +1,28 @@
<?php
// db/author.php
namespace OCA\Deck\Db;
use JsonSerializable;
use OCP\AppFramework\Db\Entity;
class Stack extends Entity implements JsonSerializable {
public $id;
protected $title;
protected $boardId;
protected $order;
public function __construct() {
$this->addType('id','integer');
$this->addType('boardId','integer');
$this->addType('order','integer');
}
public function jsonSerialize() {
return [
'id' => $this->id,
'title' => $this->title,
'order' => $this->order,
'boardId' => $this->boardId
];
}
}

33
db/stackmapper.php Normal file
View File

@@ -0,0 +1,33 @@
<?php
namespace OCA\Deck\Db;
use OCP\IDb;
use OCP\AppFramework\Db\Mapper;
class StackMapper extends Mapper {
public function __construct(IDb $db) {
parent::__construct($db, 'deck_stacks', '\OCA\Deck\Db\Stack');
}
/**
* @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_stacks` ' .
'WHERE `id` = ?';
return $this->findEntity($sql, [$id]);
}
public function findAll($boardId, $limit=null, $offset=null) {
$sql = 'SELECT * FROM `*PREFIX*deck_stacks` WHERE `board_id` = ? ORDER BY `order`';
return $this->findEntities($sql, [$boardId], $limit, $offset);
}
}