sqlite的api,便于内部使用
liuxiaolong
2019-05-17 46f6aaeebd838b309411e7d8ab3de95d15fc42af
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package dbapi
 
import (
    "encoding/json"
    "fmt"
)
 
type CameraApi struct{}
 
//通过cameraId获取摄像机信息
func (api CameraApi) GetCameraById(cameraId string) (result Camera, err error) {
    url := BASIC_URL + DATA_URL_PREFIX + "/camera/show/" + cameraId
    client := NewClient()
 
    body, err := client.DoGetRequest(url, nil, nil)
    if err != nil {
        return result, err
    }
 
    var res Result
    if err = json.Unmarshal(body, &res); err != nil {
        fmt.Println(err)
        return result,err
    }
 
    bytes, _ := json.Marshal(res.Data)
    err = json.Unmarshal(bytes, &result)
 
    return result, err
}