From 05bbfe100dc62f0137875f9d02098144554b2269 Mon Sep 17 00:00:00 2001 From: Jonathan Treffler Date: Wed, 12 Jun 2024 01:50:04 +0200 Subject: [PATCH] added Subscription Entity and Mapper --- lib/Db/Subscription.php | 31 +++++++++++++++++++++++++++++++ lib/Db/SubscriptionMapper.php | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 lib/Db/Subscription.php create mode 100644 lib/Db/SubscriptionMapper.php diff --git a/lib/Db/Subscription.php b/lib/Db/Subscription.php new file mode 100644 index 0000000..2f47c06 --- /dev/null +++ b/lib/Db/Subscription.php @@ -0,0 +1,31 @@ +addType('creationTimestamp','integer'); + $this->addType('expirationTimestamp','integer'); + } + + public function jsonSerialize(): array { + return [ + 'id' => $this->id, + 'userId' => $this->userId, + 'collectionName' => $this->collectionName, + 'data' => $this->data, + 'creationTimestamp' => $this->creationTimestamp, + 'expirationTimestamp' => $this->expirationTimestampv + ]; + } +} \ No newline at end of file diff --git a/lib/Db/SubscriptionMapper.php b/lib/Db/SubscriptionMapper.php new file mode 100644 index 0000000..00e10dd --- /dev/null +++ b/lib/Db/SubscriptionMapper.php @@ -0,0 +1,35 @@ +db->getQueryBuilder(); + $qb->select('*') + ->from(self::TABLENAME) + ->where($qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT))) + ->andWhere($qb->expr()->eq('user_id', $qb->createNamedParameter($userId))); + + return $this->findEntity($qb); + } +} \ No newline at end of file