zhangmeng
2024-01-19 01dfd9dc8de7b19f9dfa4284722e01bbd5837801
syssetApi.go
@@ -3,15 +3,14 @@
import (
   "basic.com/pubsub/protomsg.git"
   "basic.com/valib/c_bhomebus.git/proto/source/bhome_msg"
   json "github.com/json-iterator/go"
   jsoniter "github.com/json-iterator/go"
)
type SysSetApi struct {
}
//获取服务器本机配置信息
func (api SysSetApi) GetServerInfo() (flag bool,sysconf protomsg.LocalConfig){
func (api SysSetApi) GetServerInfo() (flag bool, sysconf protomsg.LocalConfig) {
   url := DATA_URL_PREFIX + "/sysset/getServerInfo"
   netNode := getNetNode(url2Topic(Topic_System_Service, url))
   client := NewClient(WithNodes(netNode))
@@ -21,42 +20,44 @@
      return false, sysconf
   }
   var json = jsoniter.ConfigCompatibleWithStandardLibrary
   var res Result
   if err = json.Unmarshal(body, &res); err != nil {
      return false, sysconf
   }
   b, err := json.Marshal(res.Data)
   if err !=nil {
      return false,sysconf
   if err != nil {
      return false, sysconf
   } else {
      err = json.Unmarshal(b, &sysconf)
      if err !=nil {
         return false,sysconf
      if err != nil {
         return false, sysconf
      } else {
         return true,sysconf
         return true, sysconf
      }
   }
}
func (api SysSetApi) AlarmEdit(paramBody map[string]interface{}) (bool,interface{}){
func (api SysSetApi) AlarmEdit(paramBody map[string]interface{}) (bool, interface{}) {
   url := DATA_URL_PREFIX + "/sysset/alarmEdit"
   netNode := getNetNode(url2Topic(Topic_System_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 {
      return false,nil
      return false, nil
   }
   return res.Success,res.Data
   return res.Success, res.Data
}
func (api SysSetApi) VideoLenShow() (bool,interface{}){
func (api SysSetApi) VideoLenShow() (bool, interface{}) {
   url := DATA_URL_PREFIX + "/sysset/videoLenShow"
   netNode := getNetNode(url2Topic(Topic_System_Service, url))
   client := NewClient(WithNodes(netNode))
@@ -66,51 +67,54 @@
      return false, nil
   }
   var json = jsoniter.ConfigCompatibleWithStandardLibrary
   var res Result
   if err = json.Unmarshal(body, &res); err != nil {
      return false, nil
   }
   return res.Success,res.Data
   return res.Success, res.Data
}
func (api SysSetApi) VideoLenEdit(maxVideoLen string,minVideoLen string) (bool,interface{}){
func (api SysSetApi) VideoLenEdit(maxVideoLen string, minVideoLen string) (bool, interface{}) {
   url := DATA_URL_PREFIX + "/sysset/videoLenEdit"
   netNode := getNetNode(url2Topic(Topic_System_Service, url))
   client := NewClient(WithNodes(netNode))
   paramBody :=make(map[string]interface{},0)
   paramBody := make(map[string]interface{}, 0)
   paramBody["max_video_len"] = maxVideoLen
   paramBody["min_video_len"] = minVideoLen
   body,err := client.DoPostRequest(url,CONTENT_TYPE_FORM, paramBody,nil,nil)
   body, err := client.DoPostRequest(url, CONTENT_TYPE_FORM, 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 {
      return false,nil
      return false, nil
   }
   return res.Success,res.Data
   return res.Success, res.Data
}
func (api SysSetApi) SaveServerInfo(paramBody map[string]interface{}) (bool,interface{}){
func (api SysSetApi) SaveServerInfo(paramBody map[string]interface{}) (bool, interface{}) {
   url := DATA_URL_PREFIX + "/sysset/saveServerInfo"
   netNode := getNetNode(url2Topic(Topic_System_Service, url))
   client := NewClient(WithNodes(netNode))
   body,err := client.DoPostRequest(url,CONTENT_TYPE_FORM, paramBody,nil,nil)
   body, err := client.DoPostRequest(url, CONTENT_TYPE_FORM, 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 {
      return false,nil
      return false, nil
   }
   return res.Success,res.Data
   return res.Success, res.Data
}
func (api SysSetApi) Gb28181ConfigShow() (bool,interface{}){
func (api SysSetApi) Gb28181ConfigShow() (bool, interface{}) {
   url := DATA_URL_PREFIX + "/sysset/gb28181ConfigShow"
   netNode := getNetNode(url2Topic(Topic_Gb28181_Service, url))
   client := NewClient(WithNodes(netNode))
@@ -120,32 +124,33 @@
      return false, nil
   }
   var json = jsoniter.ConfigCompatibleWithStandardLibrary
   var res Result
   if err = json.Unmarshal(body, &res); err != nil {
      return false, nil
   }
   return res.Success,res.Data
   return res.Success, res.Data
}
func (api SysSetApi) Gb28181ConfigEdit(paramBody map[string]interface{}) (bool,interface{}){
func (api SysSetApi) Gb28181ConfigEdit(paramBody map[string]interface{}) (bool, interface{}) {
   url := DATA_URL_PREFIX + "/sysset/gb28181ConfigEdit"
   netNode := getNetNode(url2Topic(Topic_Gb28181_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 {
      return false,nil
      return false, nil
   }
   return res.Success,res.Data
   return res.Success, res.Data
}
func (api SysSetApi) GetRemoteFullServerInfo(headers map[string]string) (flag bool,d interface{}){
func (api SysSetApi) GetRemoteFullServerInfo(headers map[string]string) (flag bool, d interface{}) {
   url := DATA_URL_PREFIX + "/sysset/getDevInfo"
   netNode := getNetNode(url2Topic(Topic_System_Service, url))
   client := NewClient(WithNodes(netNode))
@@ -155,15 +160,16 @@
      return false, nil
   }
   var json = jsoniter.ConfigCompatibleWithStandardLibrary
   var res Result
   if err = json.Unmarshal(body, &res); err != nil {
      return false, nil
   }
   return res.Success,res.Data
   return res.Success, res.Data
}
func (api SysSetApi) GetClockInfo(headers map[string]string) (flag bool,d interface{}){
func (api SysSetApi) GetClockInfo(headers map[string]string) (flag bool, d interface{}) {
   url := DATA_URL_PREFIX + "/sysset/clockInfo"
   netNode := getNetNode(url2Topic(Topic_System_Service, url))
   client := NewClient(WithNodes(netNode))
@@ -173,15 +179,16 @@
      return false, nil
   }
   var json = jsoniter.ConfigCompatibleWithStandardLibrary
   var res Result
   if err = json.Unmarshal(body, &res); err != nil {
      return false, nil
   }
   return res.Success,res.Data
   return res.Success, res.Data
}
func (api SysSetApi) TestNTPServer(query map[string]string,headers map[string]string) (flag bool,d interface{}){
func (api SysSetApi) TestNTPServer(query map[string]string, headers map[string]string) (flag bool, d interface{}) {
   url := DATA_URL_PREFIX + "/sysset/ntpTest"
   netNode := getNetNode(url2Topic(Topic_System_Service, url))
   client := NewClient(WithNodes(netNode))
@@ -191,33 +198,35 @@
      return false, nil
   }
   var json = jsoniter.ConfigCompatibleWithStandardLibrary
   var res Result
   if err = json.Unmarshal(body, &res); err != nil {
      return false, nil
   }
   return res.Success,res.Data
   return res.Success, res.Data
}
func (api SysSetApi) SetSysClock(paramBody map[string]interface{},headers map[string]string) (flag bool,d interface{}){
func (api SysSetApi) SetSysClock(paramBody map[string]interface{}, headers map[string]string) (flag bool, d interface{}) {
   url := DATA_URL_PREFIX + "/sysset/updateClock"
   netNode := getNetNode(url2Topic(Topic_System_Service, url))
   client := NewClient(WithNodes(netNode))
   body, err := client.DoPostRequest(url, CONTENT_TYPE_JSON,paramBody,nil, headers)
   body, err := client.DoPostRequest(url, CONTENT_TYPE_JSON, paramBody, nil, headers)
   if err != nil {
      return false, nil
   }
   var json = jsoniter.ConfigCompatibleWithStandardLibrary
   var res Result
   if err = json.Unmarshal(body, &res); err != nil {
      return false, nil
   }
   return res.Success,res.Data
   return res.Success, res.Data
}
func (api SysSetApi) GetSysInfo(headers map[string]string) (flag bool,d interface{}){
func (api SysSetApi) GetSysInfo(headers map[string]string) (flag bool, d interface{}) {
   url := DATA_URL_PREFIX + "/sysset/sysinfo"
   netNode := getNetNode(url2Topic(Topic_System_Service, url))
   client := NewClient(WithNodes(netNode))
@@ -227,15 +236,16 @@
      return false, nil
   }
   var json = jsoniter.ConfigCompatibleWithStandardLibrary
   var res Result
   if err = json.Unmarshal(body, &res); err != nil {
      return false, nil
   }
   return res.Success,res.Data
   return res.Success, res.Data
}
func (api SysSetApi) GetResourceConfig() (flag bool,rc protomsg.ResourceConfig){
func (api SysSetApi) GetResourceConfig() (flag bool, rc protomsg.ResourceConfig) {
   url := DATA_URL_PREFIX + "/sysset/getResourceConfig"
   netNode := getNetNode(url2Topic(Topic_System_Service, url))
   client := NewClient(WithNodes(netNode))
@@ -245,73 +255,77 @@
      return false, rc
   }
   var json = jsoniter.ConfigCompatibleWithStandardLibrary
   var res Result
   if err = json.Unmarshal(body, &res); err != nil {
      return false, rc
   }
   b, err := json.Marshal(res.Data)
   if err !=nil {
      return false,rc
   if err != nil {
      return false, rc
   } else {
      err = json.Unmarshal(b, &rc)
      if err !=nil {
         return false,rc
      if err != nil {
         return false, rc
      } else {
         return true,rc
         return true, rc
      }
   }
}
func (api SysSetApi) SaveResourceConfig(paramBody map[string]interface{}) (flag bool,d interface{}){
func (api SysSetApi) SaveResourceConfig(paramBody map[string]interface{}) (flag bool, d interface{}) {
   url := DATA_URL_PREFIX + "/sysset/saveResourceConfig"
   netNode := getNetNode(url2Topic(Topic_System_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
   }
   var json = jsoniter.ConfigCompatibleWithStandardLibrary
   var res Result
   if err = json.Unmarshal(body, &res); err != nil {
      return false, nil
   }
   return res.Success,res.Data
   return res.Success, res.Data
}
//控制本机reboot
func (api SysSetApi) RebootOS() (bool,interface{}) {
func (api SysSetApi) RebootOS() (bool, interface{}) {
   url := DATA_URL_PREFIX + "/sysset/reboot"
   netNode := getNetNode(url2Topic(Topic_System_Service, url))
   client := NewClient(WithNodes(netNode))
   body, err := client.DoPostRequest(url, CONTENT_TYPE_JSON,nil,nil, nil)
   body, err := client.DoPostRequest(url, CONTENT_TYPE_JSON, nil, nil, nil)
   if err != nil {
      return false, nil
   }
   var json = jsoniter.ConfigCompatibleWithStandardLibrary
   var res Result
   if err = json.Unmarshal(body, &res); err != nil {
      return false, nil
   }
   return res.Success,res.Data
   return res.Success, res.Data
}
func (api SysSetApi) SyncDevToManager(addr []*bhome_msg.MsgQueryTopicReply_BHNodeAddress, paramBody map[string]interface{}) (bool, interface{}) {
   url := DATA_URL_PREFIX + "/device/syncDevToManager"
   client := NewClient(WithNodes(addr))
   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
   }
   var json = jsoniter.ConfigCompatibleWithStandardLibrary
   var res Result
   if err = json.Unmarshal(body, &res); err != nil {
      return false, nil
   }
   return res.Success,res.Data
}
   return res.Success, res.Data
}