This repository has been archived by the owner on Nov 2, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replace locationmanager with locationmapper and devicemapper
- Loading branch information
Showing
10 changed files
with
195 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
namespace OCA\Maps\Db; | ||
|
||
use OCP\AppFramework\Db\Entity; | ||
|
||
class Device extends Entity { | ||
public $userId; | ||
public $name; | ||
public $hash; | ||
public $created; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
namespace OCA\Maps\Db; | ||
|
||
use OCP\AppFramework\Db\Mapper; | ||
use OCP\IDBConnection; | ||
|
||
class DeviceMapper extends Mapper { | ||
|
||
public function __construct(IDBConnection $db) { | ||
parent::__construct($db, 'maps_location_track_users', '\OCA\Maps\Db\Device'); | ||
} | ||
|
||
/** | ||
* @param string $hash | ||
* @throws \OCP\AppFramework\Db\DoesNotExistException if not found | ||
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result | ||
* @return Device | ||
*/ | ||
public function findByHash($hash) { | ||
$sql = 'SELECT * FROM `*PREFIX*maps_location_track_users` '. | ||
'WHERE `hash` = ?'; | ||
return $this->findEntity($sql, [$hash]); | ||
} | ||
|
||
/** | ||
* @param int $id | ||
* @throws \OCP\AppFramework\Db\DoesNotExistException if not found | ||
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result | ||
* @return Device | ||
*/ | ||
public function findById($id) { | ||
$sql = 'SELECT * FROM `*PREFIX*maps_location_track_users` '. | ||
'WHERE `id` = ?'; | ||
return $this->findEntity($sql, [$id]); | ||
} | ||
|
||
/** | ||
* @param string $userId | ||
* @param int $limit | ||
* @param int $offset | ||
* @return Device[] | ||
*/ | ||
public function findAll($userId, $limit=null, $offset=null) { | ||
$sql = 'SELECT * FROM `*PREFIX*maps_location_track_users`'. | ||
'WHERE `user_id` = ?'; | ||
return $this->findEntities($sql, [$userId], $limit, $offset); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
namespace OCA\Maps\Db; | ||
|
||
use OCP\AppFramework\Db\Entity; | ||
|
||
class Location extends Entity { | ||
public $deviceHash; | ||
public $lat; | ||
public $lng; | ||
public $timestamp; | ||
public $hdop; | ||
public $altitude; | ||
public $speed; | ||
} |
Oops, something went wrong.