From d6d7fd5231983c4dfb13e854363ca21698d6f9c8 Mon Sep 17 00:00:00 2001
From: liuxiaolong <736321739@qq.com>
Date: 星期四, 23 五月 2019 18:20:27 +0800
Subject: [PATCH] camera api add FindAllCameraAndTask

---
 cameraApi.go |   45 ++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 44 insertions(+), 1 deletions(-)

diff --git a/cameraApi.go b/cameraApi.go
index 03b85c6..c2a742f 100644
--- a/cameraApi.go
+++ b/cameraApi.go
@@ -1,6 +1,7 @@
 package dbapi
 
 import (
+	"basic.com/pubsub/protomsg.git"
 	"encoding/json"
 	"fmt"
 )
@@ -8,7 +9,7 @@
 type CameraApi struct{}
 
 //閫氳繃cameraId鑾峰彇鎽勫儚鏈轰俊鎭�
-func (api CameraApi) GetCameraById(cameraId string) (result Camera, err error) {
+func (api CameraApi) GetCameraById(cameraId string) (result protomsg.Camera, err error) {
 	url := BASIC_URL + DATA_URL_PREFIX + "/camera/show/" + cameraId
 	client := NewClient()
 
@@ -28,3 +29,45 @@
 
 	return result, err
 }
+
+func (api CameraApi) FindAll() (cameras []protomsg.Camera) {
+	url := BASIC_URL + DATA_URL_PREFIX + "/camera/showAll"
+	client := NewClient()
+
+	body, err := client.DoGetRequest(url, nil, nil)
+	if err != nil {
+		return nil
+	}
+
+	var res Result
+	if err = json.Unmarshal(body, &res); err != nil {
+		fmt.Println(err)
+		return nil
+	}
+
+	bytes, _ := json.Marshal(res.Data)
+	err = json.Unmarshal(bytes, &cameras)
+
+	return cameras
+}
+
+func (api CameraApi) FindAllCameraAndTask() (cameraTasks []protomsg.CameraAndTaskInfo){
+	url := BASIC_URL + DATA_URL_PREFIX + "/camera/queryCameraAndTaskInfo"
+	client := NewClient()
+
+	body, err := client.DoGetRequest(url, nil, nil)
+	if err != nil {
+		return nil
+	}
+
+	var res Result
+	if err = json.Unmarshal(body, &res); err != nil {
+		fmt.Println(err)
+		return nil
+	}
+
+	bytes, _ := json.Marshal(res.Data)
+	err = json.Unmarshal(bytes, &cameraTasks)
+
+	return cameraTasks
+}
\ No newline at end of file

--
Gitblit v1.8.0