package bhomedbapi import ( "basic.com/pubsub/protomsg.git" "basic.com/valib/c_bhomebus.git/proto/source/bhome_msg" json "github.com/json-iterator/go" ) type SysSetApi struct { } //获取服务器本机配置信息 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)) body, err := client.DoGetRequest(url, nil, nil) if err != nil { return false, sysconf } 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 } else { err = json.Unmarshal(b, &sysconf) if err !=nil { return false,sysconf } else { return true,sysconf } } } 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) 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 SysSetApi) VideoLenShow() (bool,interface{}){ url := DATA_URL_PREFIX + "/sysset/videoLenShow" netNode := getNetNode(url2Topic(Topic_System_Service, url)) client := NewClient(WithNodes(netNode)) body, err := client.DoGetRequest(url, 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 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["max_video_len"] = maxVideoLen paramBody["min_video_len"] = minVideoLen body,err := client.DoPostRequest(url,CONTENT_TYPE_FORM, 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 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) 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 SysSetApi) Gb28181ConfigShow() (bool,interface{}){ url := DATA_URL_PREFIX + "/sysset/gb28181ConfigShow" netNode := getNetNode(url2Topic(Topic_Gb28181_Service, url)) client := NewClient(WithNodes(netNode)) body, err := client.DoGetRequest(url, 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 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) 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 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)) body, err := client.DoGetRequest(url, nil, headers) 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 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)) body, err := client.DoGetRequest(url, nil, headers) 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 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)) body, err := client.DoGetRequest(url, query, headers) 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 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) 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 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)) body, err := client.DoGetRequest(url, nil, headers) 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 SysSetApi) GetResourceConfig() (flag bool,rc protomsg.ResourceConfig){ url := DATA_URL_PREFIX + "/sysset/getResourceConfig" netNode := getNetNode(url2Topic(Topic_System_Service, url)) client := NewClient(WithNodes(netNode)) body, err := client.DoGetRequest(url, nil, nil) if err != nil { return false, rc } 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 } else { err = json.Unmarshal(b, &rc) if err !=nil { return false,rc } else { return true,rc } } } 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) 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 } //控制本机reboot 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) 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 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) 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 }