2020-06-15 17:23:53 +02:00
|
|
|
<?php
|
2020-06-19 09:28:58 +02:00
|
|
|
|
2020-06-15 17:23:53 +02:00
|
|
|
namespace OCA\BigBlueButton\Db;
|
|
|
|
|
|
|
|
use OCP\AppFramework\Db\DoesNotExistException;
|
|
|
|
use OCP\AppFramework\Db\Entity;
|
|
|
|
use OCP\AppFramework\Db\QBMapper;
|
|
|
|
use OCP\DB\QueryBuilder\IQueryBuilder;
|
|
|
|
use OCP\IDBConnection;
|
|
|
|
|
2020-06-19 09:28:58 +02:00
|
|
|
class RoomShareMapper extends QBMapper {
|
|
|
|
public function __construct(IDBConnection $db) {
|
2020-06-15 17:23:53 +02:00
|
|
|
parent::__construct($db, 'bbb_room_shares', RoomShare::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param int $id
|
|
|
|
* @return Entity|RoomShare
|
|
|
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
|
|
|
* @throws DoesNotExistException
|
|
|
|
*/
|
2020-06-19 09:28:58 +02:00
|
|
|
public function find(int $id): RoomShare {
|
2020-06-15 17:23:53 +02:00
|
|
|
/* @var $qb IQueryBuilder */
|
|
|
|
$qb = $this->db->getQueryBuilder();
|
|
|
|
$qb->select('*')
|
|
|
|
->from('bbb_room_shares')
|
|
|
|
->where($qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT)));
|
|
|
|
return $this->findEntity($qb);
|
|
|
|
}
|
|
|
|
|
2020-06-19 09:28:58 +02:00
|
|
|
public function findByRoomAndEntity(int $roomId, string $shareWith, int $shareType): RoomShare {
|
2020-06-16 16:54:50 +02:00
|
|
|
/* @var $qb IQueryBuilder */
|
|
|
|
$qb = $this->db->getQueryBuilder();
|
|
|
|
$qb->select('*')
|
|
|
|
->from('bbb_room_shares')
|
|
|
|
->where($qb->expr()->eq('room_id', $qb->createNamedParameter($roomId, IQueryBuilder::PARAM_INT)))
|
|
|
|
->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($shareWith)))
|
|
|
|
->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter($shareType, IQueryBuilder::PARAM_INT)));
|
|
|
|
|
|
|
|
return $this->findEntity($qb);
|
|
|
|
}
|
|
|
|
|
2020-06-19 09:28:58 +02:00
|
|
|
public function findAll(int $roomId): array {
|
2020-06-15 17:23:53 +02:00
|
|
|
/* @var $qb IQueryBuilder */
|
|
|
|
$qb = $this->db->getQueryBuilder();
|
|
|
|
$qb->select('*')
|
|
|
|
->from('bbb_room_shares')
|
|
|
|
->where($qb->expr()->eq('room_id', $qb->createNamedParameter($roomId, IQueryBuilder::PARAM_INT)));
|
|
|
|
return $this->findEntities($qb);
|
|
|
|
}
|
|
|
|
}
|