zhangmeng
2024-01-19 01dfd9dc8de7b19f9dfa4284722e01bbd5837801
timePgnApi.go
@@ -2,53 +2,54 @@
import (
   "basic.com/pubsub/protomsg.git"
   json "github.com/json-iterator/go"
   jsoniter "github.com/json-iterator/go"
)
type TimePgnApi struct {
}
func (api TimePgnApi) SaveCameraPolygon(paramBody map[string]interface{}) (bool,interface{}) {
func (api TimePgnApi) SaveCameraPolygon(paramBody map[string]interface{}) (bool, interface{}) {
   url := DATA_URL_PREFIX + "/polygon/save"
   netNode := getNetNode(url2Topic(Topic_Scene_Service, url))
   client := NewClient(WithNodes(netNode))
   body,err := client.DoPostRequest(url,CONTENT_TYPE_JSON, paramBody,nil,nil)
   body, err := client.DoPostRequest(url, CONTENT_TYPE_JSON, paramBody, nil, nil)
   if err != nil {
      return false,nil
      return false, nil
   }
   var json = jsoniter.ConfigCompatibleWithStandardLibrary
   var res Result
   if err = json.Unmarshal(body, &res); err != nil {
      logPrint(err)
      return false,nil
      return false, nil
   }
   return res.Success,res.Data
   return res.Success, res.Data
}
func (api TimePgnApi) DeleteCameraPolygon(id string) (bool,interface{}){
func (api TimePgnApi) DeleteCameraPolygon(id string) (bool, interface{}) {
   url := DATA_URL_PREFIX + "/polygon/delete"
   netNode := getNetNode(url2Topic(Topic_Scene_Service, url))
   client := NewClient(WithNodes(netNode))
   paramQuery := make(map[string]string,0)
   paramQuery["id"]=id
   paramQuery := make(map[string]string, 0)
   paramQuery["id"] = id
   body, err := client.DoGetRequest(url, paramQuery, nil)
   if err != nil {
      return false,nil
      return false, nil
   }
   var json = jsoniter.ConfigCompatibleWithStandardLibrary
   var res Result
   if err = json.Unmarshal(body, &res); err != nil {
      return false,nil
      return false, nil
   }
   return res.Success,res.Data
   return res.Success, res.Data
}
func (api TimePgnApi) FindAllPolygons() ([]protomsg.CameraPolygon) {
func (api TimePgnApi) FindAllPolygons() []protomsg.CameraPolygon {
   url := DATA_URL_PREFIX + "/polygon/findAll"
   netNode := getNetNode(url2Topic(Topic_Scene_Service, url))
   polygons := make([]protomsg.CameraPolygon,0)
   polygons := make([]protomsg.CameraPolygon, 0)
   client := NewClient(WithNodes(netNode))
   body, err := client.DoGetRequest(url, nil, nil)
@@ -56,66 +57,70 @@
      return nil
   }
   var json = jsoniter.ConfigCompatibleWithStandardLibrary
   var res Result
   if err = json.Unmarshal(body, &res); err != nil {
      return nil
   }
   dataBytes, _ := json.Marshal(res.Data)
   if err := json.Unmarshal(dataBytes, &polygons);err !=nil {
   if err := json.Unmarshal(dataBytes, &polygons); err != nil {
      return nil
   }
   return polygons
}
func (api TimePgnApi) FindPolygonsByCameraId(cameraId string) (bool,interface{}) {
func (api TimePgnApi) FindPolygonsByCameraId(cameraId string) (bool, interface{}) {
   url := DATA_URL_PREFIX + "/polygon/findByCameraId"
   netNode := getNetNode(url2Topic(Topic_Scene_Service, url))
   client := NewClient(WithNodes(netNode))
   paramQuery := make(map[string]string,0)
   paramQuery := make(map[string]string, 0)
   paramQuery["cameraId"] = cameraId
   body, err := client.DoGetRequest(url, paramQuery, nil)
   if err != nil {
      return false,nil
      return false, nil
   }
   var json = jsoniter.ConfigCompatibleWithStandardLibrary
   var res Result
   if err = json.Unmarshal(body, &res); err != nil {
      return false,nil
      return false, nil
   }
   return true,res.Data
   return true, res.Data
}
//新增或更新时间规则
func (api TimePgnApi) SaveCameraTimerule(paramBody map[string]interface{}) (bool,interface{}) {
func (api TimePgnApi) SaveCameraTimerule(paramBody map[string]interface{}) (bool, interface{}) {
   url := DATA_URL_PREFIX + "/cameraTimerule/save"
   netNode := getNetNode(url2Topic(Topic_Scene_Service, url))
   client := NewClient(WithNodes(netNode))
   body,err := client.DoPostRequest(url,CONTENT_TYPE_JSON, paramBody,nil,nil)
   body, err := client.DoPostRequest(url, CONTENT_TYPE_JSON, paramBody, nil, nil)
   if err != nil {
      return false,nil
      return false, nil
   }
   var json = jsoniter.ConfigCompatibleWithStandardLibrary
   var res Result
   if err = json.Unmarshal(body, &res); err != nil {
      logPrint(err)
      return false,nil
      return false, nil
   }
   return res.Success,res.Data
   return res.Success, res.Data
}
func (api TimePgnApi) DeleteCameraTimerule (id string) bool {
func (api TimePgnApi) DeleteCameraTimerule(id string) bool {
   url := DATA_URL_PREFIX + "/cameraTimerule/delete"
   netNode := getNetNode(url2Topic(Topic_Scene_Service, url))
   client := NewClient(WithNodes(netNode))
   paramQuery := make(map[string]string,0)
   paramQuery["id"]=id
   paramQuery := make(map[string]string, 0)
   paramQuery["id"] = id
   body, err := client.DoGetRequest(url, paramQuery, nil)
   if err != nil {
      return false
   }
   var json = jsoniter.ConfigCompatibleWithStandardLibrary
   var res Result
   if err = json.Unmarshal(body, &res); err != nil {
      return false
@@ -124,61 +129,63 @@
}
//根据摄像机id查找所有的时间规则
func (api TimePgnApi) FindAllTimeRules() (flag bool,rules []protomsg.CameraTimerule) {
func (api TimePgnApi) FindAllTimeRules() (flag bool, rules []protomsg.CameraTimerule) {
   url := DATA_URL_PREFIX + "/cameraTimerule/findAll"
   netNode := getNetNode(url2Topic(Topic_Scene_Service, url))
   client := NewClient(WithNodes(netNode))
   body, err := client.DoGetRequest(url, nil, nil)
   if err != nil {
      return false,nil
      return false, nil
   }
   var json = jsoniter.ConfigCompatibleWithStandardLibrary
   var res Result
   if err = json.Unmarshal(body, &res); err != nil {
      return false,nil
      return false, nil
   }
   dataBytes, _ := json.Marshal(res.Data)
   if err := json.Unmarshal(dataBytes, &rules);err !=nil {
      return false,nil
   if err := json.Unmarshal(dataBytes, &rules); err != nil {
      return false, nil
   }
   return true,rules
   return true, rules
}
func (api TimePgnApi) UpdateDefenceStateByPolygonId(polygonId string,state string) (bool,interface{}){
func (api TimePgnApi) UpdateDefenceStateByPolygonId(polygonId string, state string) (bool, interface{}) {
   url := DATA_URL_PREFIX + "/polygon/updateDefenceStateByPolygonId"
   netNode := getNetNode(url2Topic(Topic_Scene_Service, url))
   client := NewClient(WithNodes(netNode))
   paramQuery :=make(map[string]string,0)
   paramQuery := make(map[string]string, 0)
   paramQuery["polygonId"] = polygonId
   paramQuery["defence_state"]=state
   paramQuery["defence_state"] = state
   body, err := client.DoGetRequest(url, paramQuery, nil)
   if err != nil {
      return false,nil
      return false, nil
   }
   var json = jsoniter.ConfigCompatibleWithStandardLibrary
   var res Result
   if err = json.Unmarshal(body, &res); err != nil {
      return false,nil
      return false, nil
   }
   return true,res.Data
   return true, res.Data
}
func (api TimePgnApi) UpdateDefenceStateByCameraId(cameraId string,state string) (bool,interface{}){
func (api TimePgnApi) UpdateDefenceStateByCameraId(cameraId string, state string) (bool, interface{}) {
   url := DATA_URL_PREFIX + "/polygon/updateDefenceStateByCameraId"
   netNode := getNetNode(url2Topic(Topic_Scene_Service, url))
   client := NewClient(WithNodes(netNode))
   paramQuery :=make(map[string]string,0)
   paramQuery := make(map[string]string, 0)
   paramQuery["cameraId"] = cameraId
   paramQuery["defence_state"]=state
   paramQuery["defence_state"] = state
   body, err := client.DoGetRequest(url, paramQuery, nil)
   if err != nil {
      return false,nil
      return false, nil
   }
   var json = jsoniter.ConfigCompatibleWithStandardLibrary
   var res Result
   if err = json.Unmarshal(body, &res); err != nil {
      return false,nil
      return false, nil
   }
   return true,res.Data
   return true, res.Data
}