@@ 7-44 (lines=38) @@ | ||
4 | use OCP\AppFramework\Db\Mapper; |
|
5 | use OCP\IDb; |
|
6 | ||
7 | class ApiKeyMapper extends Mapper { |
|
8 | ||
9 | public function __construct(IDB $db) { |
|
10 | parent::__construct($db, 'maps_apikeys', '\OCA\Maps\Db\ApiKey'); |
|
11 | } |
|
12 | ||
13 | /** |
|
14 | * @param int $id |
|
15 | * @throws \OCP\AppFramework\Db\DoesNotExistException if not found |
|
16 | * @return ApiKey |
|
17 | */ |
|
18 | public function find($id) { |
|
19 | $sql = 'SELECT * FROM `*PREFIX*maps_apikeys` '. |
|
20 | 'WHERE `id` = ?'; |
|
21 | return $this->findEntity($sql, [$id]); |
|
22 | } |
|
23 | ||
24 | /** |
|
25 | * @param string $uid |
|
26 | * @throws \OCP\AppFramework\Db\DoesNotExistException if not found |
|
27 | * @return ApiKey |
|
28 | */ |
|
29 | public function findByUser($uid) { |
|
30 | $sql = 'SELECT * FROM `*PREFIX*maps_apikeys` '. |
|
31 | 'WHERE `user_id` = ?'; |
|
32 | return $this->findEntity($sql, [$uid]); |
|
33 | } |
|
34 | ||
35 | /** |
|
36 | * @param int $limit |
|
37 | * @param int $offset |
|
38 | * @return ApiKey[] |
|
39 | */ |
|
40 | public function findAll($limit=null, $offset=null) { |
|
41 | $sql = 'SELECT * FROM `*PREFIX*maps_apikeys`'; |
|
42 | return $this->findEntities($sql, $limit, $offset); |
|
43 | } |
|
44 | } |
|
45 |
@@ 7-49 (lines=43) @@ | ||
4 | use OCP\AppFramework\Db\Mapper; |
|
5 | use OCP\IDb; |
|
6 | ||
7 | class DeviceMapper extends Mapper { |
|
8 | ||
9 | public function __construct(IDB $db) { |
|
10 | parent::__construct($db, 'maps_location_track_users', '\OCA\Maps\Db\Device'); |
|
11 | } |
|
12 | ||
13 | /** |
|
14 | * @param string $hash |
|
15 | * @throws \OCP\AppFramework\Db\DoesNotExistException if not found |
|
16 | * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result |
|
17 | * @return Device |
|
18 | */ |
|
19 | public function findByHash($hash) { |
|
20 | $sql = 'SELECT * FROM `*PREFIX*maps_location_track_users` '. |
|
21 | 'WHERE `hash` = ?'; |
|
22 | return $this->findEntity($sql, [$hash]); |
|
23 | } |
|
24 | ||
25 | /** |
|
26 | * @param int $id |
|
27 | * @throws \OCP\AppFramework\Db\DoesNotExistException if not found |
|
28 | * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result |
|
29 | * @return Device |
|
30 | */ |
|
31 | public function findById($id) { |
|
32 | $sql = 'SELECT * FROM `*PREFIX*maps_location_track_users` '. |
|
33 | 'WHERE `id` = ?'; |
|
34 | return $this->findEntity($sql, [$id]); |
|
35 | } |
|
36 | ||
37 | /** |
|
38 | * @param string $userId |
|
39 | * @param int $limit |
|
40 | * @param int $offset |
|
41 | * @return Device[] |
|
42 | */ |
|
43 | public function findAll($userId, $limit=null, $offset=null) { |
|
44 | $sql = 'SELECT * FROM `*PREFIX*maps_location_track_users`'. |
|
45 | 'WHERE `user_id` = ?'; |
|
46 | return $this->findEntities($sql, [$userId], $limit, $offset); |
|
47 | } |
|
48 | ||
49 | } |
|
50 |