Pārlūkot izejas kodu

camera play

tags/0.1.0
Robin Thoni 9 gadus atpakaļ
vecāks
revīzija
75d2b3bc27

+ 17
- 0
app/Http/Business/CamerasBusiness.php Parādīt failu

@@ -2,9 +2,12 @@
2 2
 
3 3
 namespace App\Http\Business;
4 4
 
5
+use App\Http\DBO\CameraTypesDbo;
6
+use App\Http\DBO\HostsDbo;
5 7
 use Luticate\Utils\LuBusiness;
6 8
 use App\Http\DataAccess\CamerasDataAccess;
7 9
 use App\Http\DBO\CamerasDbo;
10
+use Luticate\Utils\LuRequest;
8 11
 
9 12
 class CamerasBusiness extends LuBusiness {
10 13
     protected static function getDataAccess()
@@ -48,4 +51,18 @@ class CamerasBusiness extends LuBusiness {
48 51
         $camera->setId($camera_id);
49 52
         return CamerasDataAccess::editById($camera_id, $camera);
50 53
     }
54
+
55
+    public static function getImage($camera_id)
56
+    {
57
+        /**
58
+         * @var $camera CamerasDbo
59
+         * @var $host HostsDbo
60
+         * @var $type CameraTypesDbo
61
+         */
62
+        $camera = self::getById($camera_id);
63
+        $host = HostsBusiness::getById($camera->getHostId());
64
+        $type = CameraTypesBusiness::getById($camera->getCameraTypeId());
65
+        return LuRequest::proxy('POST', $host->getUrl() . "/cameras/image", [],
66
+            ["camera" => $camera->__toString(), "type" => $type->__toString()], ["X-Token" => $host->getToken()]);
67
+    }
51 68
 }

+ 10
- 0
app/Http/Controller/CamerasController.php Parādīt failu

@@ -78,4 +78,14 @@ class CamerasController extends LuController {
78 78
     {
79 79
         return CamerasBusiness::deleteById($camera_id);
80 80
     }
81
+
82
+    /**
83
+     * Get an image from the camera
84
+     * @param $camera_id int The camera id
85
+     * @return mixed
86
+     */
87
+    public function getImage($camera_id)
88
+    {
89
+        return CamerasBusiness::getImage($camera_id);
90
+    }
81 91
 }

+ 1
- 0
app/Http/routes.php Parādīt failu

@@ -30,6 +30,7 @@ $route->get("/cameras/$camera_id", "Cameras", "get", CamotionPermissions::CAMERA
30 30
 $route->post("/cameras/add", "Cameras", "add", array(CamotionPermissions::CAMERA_GET, CamotionPermissions::CAMERA_ADD));
31 31
 $route->post("/cameras/$camera_id/edit", "Cameras", "edit", array(CamotionPermissions::CAMERA_GET, CamotionPermissions::CAMERA_EDIT));
32 32
 $route->post("/cameras/$camera_id/del", "Cameras", "del", array(CamotionPermissions::CAMERA_GET, CamotionPermissions::CAMERA_DEL));
33
+$route->post("/cameras/$camera_id/image", "Cameras", "getImage", array(CamotionPermissions::CAMERA_GET, CamotionPermissions::CAMERA_EXEC));
33 34
 
34 35
 
35 36
 $route->get("/sensors/types", "Sensors", "getAllTypes", array(CamotionPermissions::SENSOR_GET, CamotionPermissions::SENSOR_ADD));

Notiek ielāde…
Atcelt
Saglabāt