From d8651c778030b0e39dc75d03c6904093c693811f Mon Sep 17 00:00:00 2001 From: Jonathan Treffler Date: Sat, 2 Sep 2023 02:41:17 +0200 Subject: [PATCH] added DiffTask Entity and Mapper --- lib/Db/DiffTask.php | 28 ++++++++++++++++++++++++++++ lib/Db/DiffTaskMapper.php | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 lib/Db/DiffTask.php create mode 100644 lib/Db/DiffTaskMapper.php diff --git a/lib/Db/DiffTask.php b/lib/Db/DiffTask.php new file mode 100644 index 0000000..628b3c3 --- /dev/null +++ b/lib/Db/DiffTask.php @@ -0,0 +1,28 @@ +addType('id','integer'); + $this->addType('groupfolderId','integer'); + } + + public function jsonSerialize() { + return [ + 'id' => $this->id, + 'groupfolderId' => $this->groupfolderId, + 'snapshotId' => $this->snapshotId, + 'timestamp' => $this->timestamp, + ]; + } +} \ No newline at end of file diff --git a/lib/Db/DiffTaskMapper.php b/lib/Db/DiffTaskMapper.php new file mode 100644 index 0000000..b1811c6 --- /dev/null +++ b/lib/Db/DiffTaskMapper.php @@ -0,0 +1,37 @@ + + */ +class DiffTaskMapper extends QBMapper { + + public function __construct(IDBConnection $db) { + parent::__construct($db, 'groupfolder_snapshots_tasks', DiffTask::class); + } + + public function find(int $id, string $userId) { + $qb = $this->db->getQueryBuilder(); + + $qb->select('*') + ->from($this->getTableName()) + ->where($qb->expr()->eq('id', $qb->createNamedParameter($id))) + ->andWhere($qb->expr()->eq('user_id', $qb->createNamedParameter($userId))); + + return $this->findEntity($qb); + } + + public function findAll(string $userId) { + $qb = $this->db->getQueryBuilder(); + + $qb->select('*') + ->from($this->getTableName()) + ->where($qb->expr()->eq('user_id', $qb->createNamedParameter($userId))); + + return $this->findEntities($qb); + } + +} \ No newline at end of file