mirror of
https://github.com/JanGross/quicknotes.git
synced 2025-12-01 07:37:18 +01:00
Initial release
This commit is contained in:
23
db/note.php
Normal file
23
db/note.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
namespace OCA\QuickNotes\Db;
|
||||
|
||||
use JsonSerializable;
|
||||
|
||||
use OCP\AppFramework\Db\Entity;
|
||||
|
||||
class Note extends Entity implements JsonSerializable {
|
||||
|
||||
protected $title;
|
||||
protected $content;
|
||||
protected $color;
|
||||
protected $userId;
|
||||
|
||||
public function jsonSerialize() {
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'title' => $this->title,
|
||||
'content' => $this->content,
|
||||
'color' => $this->color
|
||||
];
|
||||
}
|
||||
}
|
||||
23
db/notemapper.php
Normal file
23
db/notemapper.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
namespace OCA\QuickNotes\Db;
|
||||
|
||||
use OCP\IDb;
|
||||
use OCP\AppFramework\Db\Mapper;
|
||||
|
||||
class NoteMapper extends Mapper {
|
||||
|
||||
public function __construct(IDb $db) {
|
||||
parent::__construct($db, 'quicknotes_notes', '\OCA\QuickNotes\Db\Note');
|
||||
}
|
||||
|
||||
public function find($id, $userId) {
|
||||
$sql = 'SELECT * FROM *PREFIX*quicknotes_notes WHERE id = ? AND user_id = ?';
|
||||
return $this->findEntity($sql, [$id, $userId]);
|
||||
}
|
||||
|
||||
public function findAll($userId) {
|
||||
$sql = 'SELECT * FROM *PREFIX*quicknotes_notes WHERE user_id = ?';
|
||||
return $this->findEntities($sql, [$userId]);
|
||||
}
|
||||
|
||||
}
|
||||
24
db/task.php
Normal file
24
db/task.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
namespace OCA\QuickNotes\Db;
|
||||
|
||||
use JsonSerializable;
|
||||
|
||||
use OCP\AppFramework\Db\Entity;
|
||||
|
||||
class Note extends Entity implements JsonSerializable {
|
||||
|
||||
protected $description;
|
||||
protected $done;
|
||||
protected $ordering;
|
||||
protected $noteId;
|
||||
|
||||
public function jsonSerialize() {
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'description' => $this->description,
|
||||
'done' => $this->done,
|
||||
'ordering' => $this->ordering,
|
||||
'noteId' => $this->noteId
|
||||
];
|
||||
}
|
||||
}
|
||||
23
db/taskmapper.php
Normal file
23
db/taskmapper.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
namespace OCA\QuickNotes\Db;
|
||||
|
||||
use OCP\IDb;
|
||||
use OCP\AppFramework\Db\Mapper;
|
||||
|
||||
class TaskMapper extends Mapper {
|
||||
|
||||
public function __construct(IDb $db) {
|
||||
parent::__construct($db, 'quicknotes_tasks', '\OCA\QuickNotes\Db\Tasks');
|
||||
}
|
||||
|
||||
public function find($id, $noteId) {
|
||||
$sql = 'SELECT * FROM *PREFIX*quicknotes_tasks WHERE id = ? AND note_id = ?';
|
||||
return $this->findEntity($sql, [$id, $noteId]);
|
||||
}
|
||||
|
||||
public function findAll($noteId) {
|
||||
$sql = 'SELECT * FROM *PREFIX*quicknotes_tasks WHERE note_id = ?';
|
||||
return $this->findEntities($sql, [$noteId]);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user