liuxiaolong
2021-12-09 40ef8d96ae3696aded2c14c3c80f93af39bd1169
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package bhomedbapi
 
import (
    "basic.com/pubsub/protomsg.git"
    "encoding/json"
)
 
type CameraPolygonRelationApi struct {
 
}
 
func (api CameraPolygonRelationApi) FindAll() (flag bool,list []protomsg.CameraPolygonRelation) {
    url := DATA_URL_PREFIX + "/polygon/relation/findAll"
    netNode := getNetNode(url2Topic(Topic_Scene_Service, url))
    client := NewClient(WithNodes(netNode))
    body, err := client.DoGetRequest(url, nil, nil)
    if err != nil {
        logPrint("polygon relation findAll err:", err)
        return false, nil
    }
 
    var res Result
    if err = json.Unmarshal(body, &res); err != nil {
        logPrint("relations unmarshal err:", err)
        return false,nil
    }
 
    bts, _ := json.Marshal(res.Data)
    err = json.Unmarshal(bts, &list)
    if err != nil {
        return false, nil
    }
 
    return true, list
}
 
func (api CameraPolygonRelationApi) Relations(paramBody map[string]interface{}) (bool,interface{}) {
    url := DATA_URL_PREFIX + "/polygon/relations"
    netNode := getNetNode(url2Topic(Topic_Scene_Service, url))
    client := NewClient(WithNodes(netNode))
    body, err := client.DoPostRequest(url,CONTENT_TYPE_JSON,paramBody,nil,nil)
    if err != nil {
        return false,nil
    }
 
    var res Result
    if err = json.Unmarshal(body, &res); err != nil {
        return false,nil
    }
    return res.Success, res.Data
}
 
func (api CameraPolygonRelationApi) SaveRelation(paramBody map[string]interface{}) (bool,interface{}) {
    url := DATA_URL_PREFIX + "/polygon/relation/save"
    netNode := getNetNode(url2Topic(Topic_Scene_Service, url))
    client := NewClient(WithNodes(netNode))
    body, err := client.DoPostRequest(url,CONTENT_TYPE_JSON,paramBody,nil,nil)
    if err != nil {
        return false,nil
    }
 
    var res Result
    if err = json.Unmarshal(body, &res); err != nil {
        return false,nil
    }
    return res.Success,res.Data
}
 
func (api CameraPolygonRelationApi) DelRelation(id string) bool {
    url := DATA_URL_PREFIX + "/polygon/relation/del"
    netNode := getNetNode(url2Topic(Topic_Scene_Service, url))
    client := NewClient(WithNodes(netNode))
    paramMap := make(map[string]string,0)
    paramMap["id"] = id
    body, err := client.DoDeleteRequest(url,CONTENT_TYPE_FORM,nil,paramMap)
    if err != nil {
        return false
    }
 
    var res Result
    if err = json.Unmarshal(body, &res); err != nil {
        return false
    }
    return res.Success
}