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 }