Преглед изворни кода

isapi数据格式修改xml->json

longan пре 1 година
родитељ
комит
c0681a90ec

+ 19 - 5
api/v1/app/gateway.go

@@ -1,12 +1,13 @@
 package app
 
 import (
+	"fmt"
 	"github.com/gin-gonic/gin"
-	"github.com/sirupsen/logrus"
 	"lcfns/model/app"
 	"lcfns/model/app/request"
 	"lcfns/model/common/response"
 	"lcfns/service"
+	"strconv"
 )
 
 type GatewayApi struct {
@@ -17,10 +18,23 @@ var gs = service.ServiceGroupApp.AppServiceGroup.GatewayService
 // List all devices
 func (api *GatewayApi) List(c *gin.Context) {
 	var req request.GatewayRequest
-	err := c.ShouldBindJSON(&req)
-	if err != nil {
-		logrus.Error("请求数据绑定错误", err)
-	}
+	v0 := c.Query("uid")
+	req.Uid, _ = strconv.Atoi(v0)
+
+	req.Name = c.Query("gatewayName")
+
+	req.Osn = c.Query("osn")
+	req.CameraSn = c.Query("cameraSn")
+	v1 := c.Query("ipcastId")
+	req.IpcastId, _ = strconv.Atoi(v1)
+
+	v2 := c.Query("pageSize")
+	req.PageSize, _ = strconv.Atoi(v2)
+
+	v3 := c.Query("page")
+	req.Page, _ = strconv.Atoi(v3)
+
+	fmt.Printf("参数:%+v\n", req)
 	list, err := gs.List(req)
 	if err != nil {
 		response.FailWithMessage(err.Error(), c)

+ 6 - 0
api/v1/isapi/system.go

@@ -19,7 +19,13 @@ func (i SystemApi) GetInfo(c *gin.Context) {
 		logrus.Errorf("获取host失败:%e\n", err)
 		return
 	}
+	//data, err :=
 	isapi.TouChuan(host, isapi.GetDeviceInfo, nil, c)
+	//if err != nil {
+	//	response.FailWithMessage(err.Error(), c)
+	//	return
+	//}
+	//response.OkWithData(data, c)
 }
 
 func (i SystemApi) GetCap(c *gin.Context) {

+ 14 - 14
gatewayServer/c2s.go

@@ -97,8 +97,8 @@ func c2s4001(adu AppDataUnit, c net.Conn) {
 		logrus.Error(err)
 		return
 	}
-	var info isapi.DeviceInfo
-	xml.Unmarshal(resp, &info)
+	var info = resp.(isapi.DeviceInfo)
+	//xml.Unmarshal(resp, &info)
 	//创建camera记录并绑定gateway_id
 	err = cs.CreateIfNotExist(info, gw.ID)
 	if err != nil {
@@ -154,17 +154,17 @@ func setServer(host string) uint {
 		logrus.Errorf("事件主机配置文件解析错误: %e\n", err)
 		return 0
 	}
-	bytes, err := isapi.Com(host, isapi.SetHosts, marshal)
+	data, err := isapi.Com(host, isapi.SetHosts, marshal)
 	if err != nil {
 		logrus.Error("配置监听主机错误", err)
 	}
-	var resp isapi.ResponseStatus
-	err = xml.Unmarshal(bytes, &resp)
+	var resp = data.(isapi.ResponseStatus)
+	//err = xml.Unmarshal(bytes, &resp)
 	if err != nil || (resp.StatusCode != 0 && resp.StatusCode != 1) {
 		logrus.Errorf("配置监听服务器响应 err:%s,StatusCode:%d,StatusString:%s", err.Error(), resp.StatusCode, resp.StatusString)
 		return 0
 	}
-	logrus.Info("配置监听主机响应", string(bytes))
+	//logrus.Info("配置监听主机响应", string(bytes))
 	return 1
 }
 
@@ -239,13 +239,13 @@ func setSIP(host string, cid uint, cs appService.CameraService) uint {
 	}
 	//2. 配置SIP
 	s := fmt.Sprintf(sipstr, id, id)
-	bytes, err := isapi.Com(host, isapi.SetSIP, []byte(s))
+	data, err := isapi.Com(host, isapi.SetSIP, []byte(s))
 	if err != nil {
 		logrus.Error("配置SIP错误", err)
 		return 0
 	}
-	var resp isapi.ResponseStatus
-	err = xml.Unmarshal(bytes, &resp)
+	var resp = data.(isapi.ResponseStatus)
+	//err = xml.Unmarshal(bytes, &resp)
 	if err != nil {
 		logrus.Errorf("配置SIP服务器err:%s", err.Error())
 		return 0
@@ -256,20 +256,20 @@ func setSIP(host string, cid uint, cs appService.CameraService) uint {
 		return 0
 	}
 	//3. 配置SIPInfo
-	com, err := isapi.Com(host, isapi.SetSIPInfo, []byte(sipInfo))
+	data, err = isapi.Com(host, isapi.SetSIPInfo, []byte(sipInfo))
 	if err != nil {
 		logrus.Error("配置SIPInfo错误", err)
 		return 0
 	}
-	var resp1 isapi.ResponseStatus
-	err = xml.Unmarshal(com, &resp1)
+	var resp1 = data.(isapi.ResponseStatus)
+	//err = xml.Unmarshal(com, &resp1)
 	if err != nil {
 		logrus.Errorf("配置配置SIPInfo err:%s", err.Error())
 		return 0
 	}
 	//记录失败原因
-	if resp.StatusCode != 0 && resp.StatusCode != 1 {
-		logrus.Infof("配置SIPInfo-响应 StatusCode:%d,StatusString:%s", resp.StatusCode, resp.StatusString)
+	if resp1.StatusCode != 0 && resp1.StatusCode != 1 {
+		logrus.Infof("配置SIPInfo-响应 StatusCode:%d,StatusString:%s", resp1.StatusCode, resp1.StatusString)
 		return 0
 	}
 	//成功保存数据库

+ 13 - 11
isapi/client.go

@@ -29,6 +29,7 @@ func NewClient(host, username, password string) (*Client, error) {
 	if err != nil {
 		return nil, err
 	}
+	fmt.Printf("baseUrl:%s\n", u.String())
 	return &Client{
 		Client: &http.Client{
 			Transport: NewAuthTransport(username, password),
@@ -37,23 +38,24 @@ func NewClient(host, username, password string) (*Client, error) {
 	}, nil
 }
 
-func TouChuan(host string, o Operation, data []byte, c *gin.Context) ([]byte, error) {
-	info, err := Com(host, o, data)
+func TouChuan(host string, o Operation, data []byte, c *gin.Context) (resp any, err error) {
+	resp, err = Com(host, o, data)
 	if err != nil {
-		return nil, fmt.Errorf("TouChuan错误: %e", err)
+		logrus.Error(err)
+		response.FailWithDetailed(resp.(ResponseStatus), err.Error(), c)
+		return
 	}
-	if err != nil {
-		response.FailWithMessage(err.Error(), c)
-		logrus.Errorf("%s error: %e", o, err)
-		return nil, err
+	_, ok := resp.(ResponseStatus)
+	if ok {
+		response.OkWithDetailed(resp, "操作成功", c)
+		return
 	}
-	c.Data(200, `application/xml; charset="UTF-8"`, info)
-	//response.OkWithData(info, c)
-	return info, nil
+	response.OkWithData(resp, c)
+	return
 }
 
 // Com 透传
-func Com(host string, o Operation, data []byte) ([]byte, error) {
+func Com(host string, o Operation, data []byte) (any, error) {
 	c, err := NewClient(host, "admin", "kk176@lc")
 	if err != nil {
 		return nil, err

+ 22 - 16
isapi/isapi_event_channelCap.go

@@ -2,31 +2,37 @@ package isapi
 
 import (
 	"encoding/xml"
+	"github.com/sirupsen/logrus"
 )
 
 type ChannelEventCapList struct {
-	XMLName         xml.Name          `xml:"ChannelEventCapList"`
-	Text            string            `xml:",chardata"`
-	Version         string            `xml:"version,attr"`
-	Xmlns           string            `xml:"xmlns,attr"`
-	ChannelEventCap []ChannelEventCap `xml:"ChannelEventCap"`
+	ChannelEventCap []ChannelEventCap `xml:"ChannelEventCap" json:"channelEventCap"`
 }
 
 type ChannelEventCap struct {
-	Text      string `xml:",chardata"`
 	EventType struct {
-		Text string `xml:",chardata"`
-		Opt  string `xml:"opt,attr"`
-	} `xml:"eventType"`
-	ChannelID string `xml:"channelID"`
-	ID        string `xml:"id"`
+		Opt string `xml:"opt,attr" json:"opt"`
+	} `xml:"eventType" json:"eventType"`
+	ChannelID string `xml:"channelID" json:"channelID"`
+	ID        string `xml:"id" json:"ID"`
 }
 
-func (c *Client) GetAllChanEventCap() ([]byte, error) {
-
-	return c.CommonGet("/ISAPI/Event/channels/capabilities")
+func (c *Client) GetAllChanEventCap() (resp ChannelEventCapList, err error) {
+	bytes, err := c.CommonGet("/ISAPI/Event/channels/capabilities")
+	if err != nil {
+		logrus.Error("请求出错", err)
+		return
+	}
+	err = xml.Unmarshal(bytes, &resp)
+	return
 }
 
-func (c *Client) GetOneChanEventCap() ([]byte, error) {
-	return c.CommonGet("/ISAPI/Event/channels/1/capabilities")
+func (c *Client) GetOneChanEventCap() (resp ChannelEventCap, err error) {
+	bytes, err := c.CommonGet("/ISAPI/Event/channels/1/capabilities")
+	if err != nil {
+		logrus.Error("请求出错", err)
+		return
+	}
+	err = xml.Unmarshal(bytes, &resp)
+	return
 }

+ 13 - 2
isapi/isapi_event_httphost.go

@@ -1,5 +1,10 @@
 package isapi
 
+import (
+	"encoding/xml"
+	"github.com/sirupsen/logrus"
+)
+
 type eventType string
 
 const (
@@ -18,8 +23,14 @@ func (c *Client) GetHostCap() ([]byte, error) {
 }
 
 // PutHost 配置单个监听主机参数
-func (c *Client) PutHost(data []byte) ([]byte, error) {
-	return c.CommonPut(data, "/ISAPI/Event/notification/httpHosts")
+func (c *Client) PutHost(data []byte) (info ResponseStatus, err error) {
+	resp, err := c.CommonPut(data, "/ISAPI/Event/notification/httpHosts")
+	if err != nil {
+		logrus.Error("请求出错", err)
+		return
+	}
+	err = xml.Unmarshal(resp, &info)
+	return
 }
 
 // DelHost 删除单个监听主机参数

+ 17 - 13
isapi/isapi_smart_calibration.go

@@ -3,24 +3,28 @@ package isapi
 // SmartCalibrationList 配置最大、最小尺寸
 type SmartCalibrationList struct {
 	SmartCalibration []struct {
-		ID         string `xml:"ID"`
+		ID         string `xml:"ID" json:"ID"`
 		FilterSize struct {
 			MinTargetSize struct {
 				RegionCoordinatesList struct {
 					RegionCoordinates []struct {
-						PositionX string `xml:"positionX"`
-						PositionY string `xml:"positionY"`
-					} `xml:"RegionCoordinates"`
-				} `xml:"RegionCoordinatesList"`
-			} `xml:"MinTargetSize"`
+						PositionX string `xml:"positionX" json:"positionX"`
+						PositionY string `xml:"positionY" json:"positionY"`
+					} `xml:"RegionCoordinates" json:"RegionCoordinates"`
+				} `xml:"RegionCoordinatesList" json:"RegionCoordinatesList"`
+			} `xml:"MinTargetSize" json:"MinTargetSize"`
 			MaxTargetSize struct {
 				RegionCoordinatesList struct {
 					RegionCoordinates []struct {
-						PositionX string `xml:"positionX"`
-						PositionY string `xml:"positionY"`
-					} `xml:"RegionCoordinates"`
-				} `xml:"RegionCoordinatesList"`
-			} `xml:"MaxTargetSize"`
-		} `xml:"FilterSize"`
-	} `xml:"SmartCalibration"`
+						PositionX string `xml:"positionX" json:"positionX"`
+						PositionY string `xml:"positionY" json:"positionY"`
+					} `xml:"RegionCoordinates" json:"RegionCoordinates"`
+				} `xml:"RegionCoordinatesList" json:"RegionCoordinatesList"`
+			} `xml:"MaxTargetSize" json:"MaxTargetSize"`
+			Mode struct {
+				Text string `xml:",chardata" json:"chardata"`
+				Opt  string `xml:"opt,attr" json:"opt"`
+			} `xml:"mode" json:"mode"`
+		} `xml:"FilterSize" json:"FilterSize"`
+	} `xml:"SmartCalibration" json:"SmartCalibration"`
 }

+ 151 - 42
isapi/isapi_smart_fieldDetection.go

@@ -1,68 +1,177 @@
 package isapi
 
 import (
+	"encoding/json"
 	"encoding/xml"
+	"fmt"
+	"github.com/sirupsen/logrus"
 )
 
 //能力
 //http://192.168.1.64/ISAPI/Smart/FieldDetection/1/capabilities
 //http://192.168.1.64/ISAPI/Smart/channels/1/calibrations/capabilities
 
-// FieldDetection 区域入侵
-type FieldDetection struct {
-	XMLName              xml.Name `xml:"FieldDetection"`
-	Xmlns                string   `xml:"xmlns,attr"`
-	Version              string   `xml:"version,attr"`
-	ID                   string   `xml:"id"`
-	Enabled              string   `xml:"enabled"`
-	StartTriggerTime     string   `xml:"startTriggerTime"`
-	EndTriggerTime       string   `xml:"endTriggerTime"`
+// FieldDetectionCap 区域入侵参数能力
+type FieldDetectionCap struct {
+	ID      string `xml:"id" json:"id"`
+	Enabled struct {
+		Text string `xml:",chardata" json:"value"`
+		Opt  string `xml:"opt,attr" json:"opt"`
+	} `xml:"enabled"`
 	NormalizedScreenSize struct {
-		NormalizedScreenWidth  string `xml:"normalizedScreenWidth"`
-		NormalizedScreenHeight string `xml:"normalizedScreenHeight"`
-	} `xml:"normalizedScreenSize"`
+		NormalizedScreenWidth  string `xml:"normalizedScreenWidth" json:"normalized_screen_width"`
+		NormalizedScreenHeight string `xml:"normalizedScreenHeight" json:"normalized_screen_height"`
+	} `xml:"normalizedScreenSize" json:"normalizedScreenSize"`
 	FieldDetectionRegionList struct {
-		Size                 string `xml:"size,attr"`
+		Size                 string `xml:"size,attr" json:"size"`
 		FieldDetectionRegion []struct {
-			ID               string `xml:"id"`
-			Enabled          string `xml:"enabled"`
-			SensitivityLevel string `xml:"sensitivityLevel"`
-			TimeThreshold    string `xml:"timeThreshold"`
-			DetectionTarget  string `xml:"detectionTarget"`
-			AlarmConfidence  struct {
-				Opt string `xml:"opt,attr"`
-			} `xml:"alarmConfidence"`
-			RegionCoordinatesList struct {
-				RegionCoordinates []struct {
-					PositionX string `xml:"positionX"`
-					PositionY string `xml:"positionY"`
-				} `xml:"RegionCoordinates"`
-			} `xml:"RegionCoordinatesList"`
-		} `xml:"FieldDetectionRegion"`
-	} `xml:"FieldDetectionRegionList"`
-	IsSupportMultiScene           string `xml:"isSupportMultiScene"`
-	IsSupportHumanMisinfoFilter   string `xml:"isSupportHumanMisinfoFilter"`
-	IsSupportVehicleMisinfoFilter string `xml:"isSupportVehicleMisinfoFilter"`
+			ID                      string `xml:"id" json:"id"`
+			MinRegionCoordinatesNum string `xml:"minRegionCoordinatesNum" json:"minRegionCoordinatesNum"`
+			MaxRegionCoordinatesNum string `xml:"maxRegionCoordinatesNum" json:"maxRegionCoordinatesNum"`
+			SensitivityLevel        struct {
+				Text string `xml:",chardata" json:"value"`
+				Min  string `xml:"min,attr" json:"min"`
+				Max  string `xml:"max,attr" json:"max"`
+			} `xml:"sensitivityLevel" json:"sensitivityLevel"`
+			TimeThreshold struct {
+				Text string `xml:",chardata" json:"value"`
+				Min  string `xml:"min,attr" json:"min"`
+				Max  string `xml:"max,attr" json:"max"`
+			} `xml:"timeThreshold" json:"timeThreshold"`
+			CoordinatesList struct {
+				Coordinates []struct {
+					PositionX string `xml:"positionX" json:"positionX"`
+					PositionY string `xml:"positionY" json:"positionY"`
+				} `xml:"Coordinates" json:"Coordinates"`
+			} `xml:"CoordinatesList" json:"CoordinatesList"`
+			DetectionTarget struct {
+				Text string `xml:",chardata" json:"value"`
+				Opt  string `xml:"opt,attr" json:"opt"`
+			} `xml:"detectionTarget" json:"detectionTarget"`
+			AlarmConfidence struct {
+				Text string `xml:",chardata" json:"value"`
+				Opt  string `xml:"opt,attr" json:"opt"`
+				Def  string `xml:"def,attr" json:"def"`
+			} `xml:"alarmConfidence" json:"alarmConfidence"`
+		} `xml:"FieldDetectionRegion" json:"FieldDetectionRegion"`
+	} `xml:"FieldDetectionRegionList" json:"FieldDetectionRegionList"`
+	IsSupportMultiScene           string `xml:"isSupportMultiScene" json:"isSupportMultiScene"`
+	IsSupportHumanMisinfoFilter   string `xml:"isSupportHumanMisinfoFilter" json:"isSupportHumanMisinfoFilter"`
+	IsSupportVehicleMisinfoFilter string `xml:"isSupportVehicleMisinfoFilter" json:"isSupportVehicleMisinfoFilter"`
+	IsSupportTargetMultiSelect    string `xml:"isSupportTargetMultiSelect" json:"isSupportTargetMultiSelect"`
+	IsSupportAllDayUpload         string `xml:"isSupportAllDayUpload" json:"isSupportAllDayUpload"`
 }
 
-func (c *Client) GetFieldDetectionCap() ([]byte, error) {
-	return c.CommonGet("/ISAPI/Smart/FieldDetection/1/capabilities")
+func (c *Client) GetFieldDetectionCap() (resp FieldDetectionCap, err error) {
+	bytes, err := c.CommonGet("/ISAPI/Smart/FieldDetection/1/capabilities")
+	if err != nil {
+		logrus.Error("请求出错", err)
+		return
+	}
+	err = xml.Unmarshal(bytes, &resp)
+	return
 }
 
-func (c *Client) GetSizeFd() ([]byte, error) {
-	return c.CommonGet("/ISAPI/Smart/channels/1/calibrations/FieldDetection")
+func (c *Client) GetSizeFd() (resp SmartCalibrationList, err error) {
+	bytes, err := c.CommonGet("/ISAPI/Smart/channels/1/calibrations/FieldDetection")
+	if err != nil {
+		logrus.Error("请求出错", err)
+		return
+	}
+	err = xml.Unmarshal(bytes, &resp)
+	fmt.Printf("%+v\n", string(bytes))
+	fmt.Printf("%+v\n", resp)
+	return
 }
 
-func (c *Client) PutSizeFd(data []byte) ([]byte, error) {
-	return c.CommonPut(data, "/ISAPI/Smart/channels/1/calibrations/FieldDetection")
+func (c *Client) PutSizeFd(data []byte) (resp ResponseStatus, err error) {
+	var info SmartCalibrationList
+	err = json.Unmarshal(data, &info)
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	marshal, err := xml.Marshal(info)
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	respData, err := c.CommonPut(marshal, "/ISAPI/Smart/channels/1/calibrations/FieldDetection")
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	err = xml.Unmarshal(respData, &resp)
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	return
 }
 
 // PutFieldDetection 设置区域入侵报警区域
-func (c *Client) PutFieldDetection(data []byte) ([]byte, error) {
-	return c.CommonPut(data, "/ISAPI/Smart/FieldDetection/1")
+func (c *Client) PutFieldDetection(data []byte) (resp ResponseStatus, err error) {
+	var info FieldDetectionParam
+	err = json.Unmarshal(data, &info)
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	marshal, err := xml.Marshal(info)
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	respData, err := c.CommonPut(marshal, "/ISAPI/Smart/FieldDetection/1")
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	err = xml.Unmarshal(respData, &resp)
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	return
 }
 
 // GetFieldDetection 获取报警区域
-func (c *Client) GetFieldDetection() ([]byte, error) {
-	return c.CommonGet("/ISAPI/Smart/FieldDetection/1")
+func (c *Client) GetFieldDetection() (resp FieldDetectionParam, err error) {
+	bytes, err := c.CommonGet("/ISAPI/Smart/FieldDetection/1")
+	if err != nil {
+		logrus.Error("请求出错", err)
+		return
+	}
+	err = xml.Unmarshal(bytes, &resp)
+	return
+}
+
+// FieldDetectionParam 查询,配置 进入区域参数
+type FieldDetectionParam struct {
+	ID                   string `xml:"id" json:"id"`
+	Enabled              string `xml:"enabled" json:"enabled"`
+	NormalizedScreenSize struct {
+		NormalizedScreenWidth  string `xml:"normalizedScreenWidth" json:"normalizedScreenWidth"`
+		NormalizedScreenHeight string `xml:"normalizedScreenHeight" json:"normalizedScreenHeight"`
+	} `xml:"normalizedScreenSize" json:"normalizedScreenSize"`
+	FieldDetectionRegionList struct {
+		Size                 string `xml:"size,attr" json:"size"`
+		FieldDetectionRegion []struct {
+			ID                    string `xml:"id" json:"id"`
+			Enabled               string `xml:"enabled" json:"enabled"`
+			SensitivityLevel      string `xml:"sensitivityLevel" json:"sensitivityLevel"`
+			TimeThreshold         string `xml:"timeThreshold" json:"timeThreshold"`
+			DetectionTarget       string `xml:"detectionTarget" json:"detectionTarget"`
+			AlarmConfidence       string `xml:"alarmConfidence"json:"alarmConfidence"`
+			RegionCoordinatesList struct {
+				RegionCoordinates []struct {
+					PositionX string `xml:"positionX" json:"positionX"`
+					PositionY string `xml:"positionY" json:"positionY"`
+				} `xml:"RegionCoordinates" json:"RegionCoordinates"`
+			} `xml:"RegionCoordinatesList" json:"RegionCoordinatesList"`
+		} `xml:"FieldDetectionRegion" json:"FieldDetectionRegion"`
+	} `xml:"FieldDetectionRegionList" json:"FieldDetectionRegionList"`
+	IsSupportMultiScene           string `xml:"isSupportMultiScene" json:"isSupportMultiScene"`
+	IsSupportHumanMisinfoFilter   string `xml:"isSupportHumanMisinfoFilter" json:"isSupportHumanMisinfoFilter"`
+	IsSupportVehicleMisinfoFilter string `xml:"isSupportVehicleMisinfoFilter" json:"isSupportVehicleMisinfoFilter"`
 }

+ 158 - 36
isapi/isapi_smart_lineDetection.go

@@ -1,59 +1,181 @@
 package isapi
 
+import (
+	"encoding/json"
+	"encoding/xml"
+	"fmt"
+	"github.com/sirupsen/logrus"
+)
+
 //能力
 //http://192.168.1.64/ISAPI/Smart/LineDetection/1/capabilities
 //http://192.168.1.64/ISAPI/Smart/channels/1/calibrations/capabilities
 
-// LineDetection 越界侦测
-type LineDetection struct {
-	ID                   string `xml:"id"`
-	Enabled              string `xml:"enabled"`
+// LineDetectionParam 越界侦测
+type LineDetectionParam struct {
+	ID                   string `xml:"id" json:"id"`
+	Enabled              string `xml:"enabled" json:"enabled"`
 	NormalizedScreenSize struct {
-		NormalizedScreenWidth  string `xml:"normalizedScreenWidth"`
-		NormalizedScreenHeight string `xml:"normalizedScreenHeight"`
-	} `xml:"normalizedScreenSize"`
+		NormalizedScreenWidth  string `xml:"normalizedScreenWidth" json:"normalizedScreenWidth"`
+		NormalizedScreenHeight string `xml:"normalizedScreenHeight" json:"normalizedScreenHeight"`
+	} `xml:"normalizedScreenSize" json:"normalizedScreenSize"`
 	LineItemList struct {
-		Size     string `xml:"size,attr"`
+		Size     string `xml:"size,attr" json:"size"`
 		LineItem []struct {
-			ID                   string `xml:"id"`
-			Enabled              string `xml:"enabled"`
-			SensitivityLevel     string `xml:"sensitivityLevel"`
-			DirectionSensitivity string `xml:"directionSensitivity"`
-			DetectionTarget      string `xml:"detectionTarget"`
-			AlarmConfidence      struct {
-				Text string `xml:",chardata"`
-				Opt  string `xml:"opt,attr"`
-			} `xml:"alarmConfidence"`
-			CoordinatesList struct {
+			ID                   string `xml:"id" json:"id"`
+			Enabled              string `xml:"enabled" json:"enabled"`
+			SensitivityLevel     string `xml:"sensitivityLevel" json:"sensitivityLevel"`
+			DirectionSensitivity string `xml:"directionSensitivity"json:"directionSensitivity"`
+			DetectionTarget      string `xml:"detectionTarget" json:"detectionTarget"`
+			AlarmConfidence      string `xml:"alarmConfidence" json:"alarmConfidence"`
+			CoordinatesList      struct {
 				Coordinates []struct {
-					PositionX string `xml:"positionX"`
-					PositionY string `xml:"positionY"`
-				} `xml:"Coordinates"`
-			} `xml:"CoordinatesList"`
-		} `xml:"LineItem"`
-	} `xml:"LineItemList"`
-	IsSupportMultiScene string `xml:"isSupportMultiScene"`
-	RecogRuleType       string `xml:"recogRuleType"`
+					PositionX string `xml:"positionX" json:"positionX"`
+					PositionY string `xml:"positionY" json:"positionY"`
+				} `xml:"Coordinates" json:"Coordinates"`
+			} `xml:"CoordinatesList" json:"CoordinatesList"`
+		} `xml:"LineItem" json:"LineItem"`
+	} `xml:"LineItemList" json:"LineItemList"`
+	IsSupportMultiScene string `xml:"isSupportMultiScene" json:"isSupportMultiScene"`
+	RecogRuleType       string `xml:"recogRuleType" json:"recogRuleType"`
 }
 
-func (c *Client) GetLineDetectionCap() ([]byte, error) {
-	return c.CommonGet("/ISAPI/Smart/LineDetection/1/capabilities")
+func (c *Client) GetLineDetectionCap() (resp LineDetectionCap, err error) {
+	bytes, err := c.CommonGet("/ISAPI/Smart/LineDetection/1/capabilities")
+	if err != nil {
+		logrus.Error("请求出错", err)
+		return
+	}
+	err = xml.Unmarshal(bytes, &resp)
+	return
 }
 
-func (c *Client) GetSizeLd() ([]byte, error) {
-	return c.CommonGet("/ISAPI/Smart/channels/1/calibrations/linedetection")
+func (c *Client) GetSizeLd() (resp SmartCalibrationList, err error) {
+	bytes, err := c.CommonGet("/ISAPI/Smart/channels/1/calibrations/linedetection")
+	if err != nil {
+		logrus.Error("请求出错", err)
+		return
+	}
+	err = xml.Unmarshal(bytes, &resp)
+	return
 }
 
-func (c *Client) PutSizeLd(data []byte) ([]byte, error) {
-	return c.CommonPut(data, "/ISAPI/Smart/channels/1/calibrations/linedetection")
+func (c *Client) PutSizeLd(data []byte) (resp ResponseStatus, err error) {
+	var info SmartCalibrationList
+	err = json.Unmarshal(data, &info)
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	marshal, err := xml.Marshal(info)
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	respData, err := c.CommonPut(marshal, "/ISAPI/Smart/channels/1/calibrations/linedetection")
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	err = xml.Unmarshal(respData, &resp)
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	return
 }
 
 // GetLineDetection 获取单个通道越界侦测规则
-func (c *Client) GetLineDetection() ([]byte, error) {
-	return c.CommonGet("/ISAPI/Smart/LineDetection/1")
+func (c *Client) GetLineDetection() (resp LineDetectionParam, err error) {
+	bytes, err := c.CommonGet("/ISAPI/Smart/LineDetection/1")
+	if err != nil {
+		logrus.Error("请求出错", err)
+		return
+	}
+	err = xml.Unmarshal(bytes, &resp)
+	marshal, err := json.Marshal(resp)
+	if err != nil {
+		logrus.Error("请求出错", err)
+		return
+	}
+	fmt.Println("json数据:", string(marshal))
+	return
 }
 
 // PutLineDetection 配置单个通道越界侦测规则
-func (c *Client) PutLineDetection(data []byte) ([]byte, error) {
-	return c.CommonPut(data, "/ISAPI/Smart/LineDetection/1")
+func (c *Client) PutLineDetection(data []byte) (resp ResponseStatus, err error) {
+	var info LineDetectionParam
+	err = json.Unmarshal(data, &info)
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	marshal, err := xml.Marshal(info)
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	respData, err := c.CommonPut(marshal, "/ISAPI/Smart/LineDetection/1")
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	err = xml.Unmarshal(respData, &resp)
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	return
+}
+
+type LineDetectionCap struct {
+	ID      string `xml:"id" json:"id"`
+	Enabled struct {
+		Text string `xml:",chardata" json:"value"`
+		Opt  string `xml:"opt,attr" json:"opt"`
+	} `xml:"enabled" json:"enabled"`
+	NormalizedScreenSize struct {
+		NormalizedScreenWidth  string `xml:"normalizedScreenWidth" json:"normalizedScreenWidth"`
+		NormalizedScreenHeight string `xml:"normalizedScreenHeight" json:"normalizedScreenHeight"`
+	} `xml:"normalizedScreenSize" json:"normalizedScreenSize"`
+	LineItemList struct {
+		Size     string `xml:"size,attr" json:"size"`
+		LineItem []struct {
+			ID      string `xml:"id" json:"id"`
+			Enabled struct {
+				Text string `xml:",chardata" json:"value"`
+				Opt  string `xml:"opt,attr" json:"opt"`
+			} `xml:"enabled" json:"enabled"`
+			SensitivityLevel struct {
+				Text string `xml:",chardata" json:"value"`
+				Min  string `xml:"min,attr" json:"min"`
+				Max  string `xml:"max,attr" json:"max"`
+			} `xml:"sensitivityLevel" json:"sensitivityLevel"`
+			DirectionSensitivity struct {
+				Text string `xml:",chardata" json:"value"`
+				Opt  string `xml:"opt,attr" json:"opt"`
+			} `xml:"directionSensitivity" json:"directionSensitivity"`
+			CoordinatesList struct {
+				Coordinates []struct {
+					PositionX string `xml:"positionX" json:"positionX"`
+					PositionY string `xml:"positionY" json:"positionY"`
+				} `xml:"Coordinates" json:"Coordinates"`
+			} `xml:"CoordinatesList" json:"CoordinatesList"`
+			DetectionTarget struct {
+				Text string `xml:",chardata" json:"value"`
+				Opt  string `xml:"opt,attr" json:"opt"`
+			} `xml:"detectionTarget" json:"detectionTarget"`
+			AlarmConfidence struct {
+				Text string `xml:",chardata" json:"value"`
+				Opt  string `xml:"opt,attr" json:"opt"`
+				Def  string `xml:"def,attr" json:"def"`
+			} `xml:"alarmConfidence" json:"alarmConfidence"`
+		} `xml:"LineItem" json:"LineItem"`
+	} `xml:"LineItemList" json:"LineItemList"`
+	IsSupportMultiScene           string `xml:"isSupportMultiScene" json:"isSupportMultiScene"`
+	RecogRuleType                 string `xml:"recogRuleType" json:"recogRuleType"`
+	IsSupportHumanMisinfoFilter   string `xml:"isSupportHumanMisinfoFilter" json:"isSupportHumanMisinfoFilter"`
+	IsSupportVehicleMisinfoFilter string `xml:"isSupportVehicleMisinfoFilter" json:"isSupportVehicleMisinfoFilter"`
+	IsSupportTargetMultiSelect    string `xml:"isSupportTargetMultiSelect" json:"isSupportTargetMultiSelect"`
+	IsSupportAllDayUpload         string `xml:"isSupportAllDayUpload" json:"isSupportAllDayUpload"`
 }

+ 151 - 34
isapi/isapi_smart_regionEntrance.go

@@ -1,53 +1,170 @@
 package isapi
 
-// RegionEntrance 进入区域
-type RegionEntrance struct {
-	ID                   string `xml:"id"`
-	Enabled              string `xml:"enabled"`
+import (
+	"encoding/json"
+	"encoding/xml"
+	"fmt"
+	"github.com/sirupsen/logrus"
+)
+
+// RegionEntranceParam 进入区域
+type RegionEntranceParam struct {
+	ID                   string `xml:"id" json:"id"`
+	Enabled              string `xml:"enabled" json:"enabled"`
 	NormalizedScreenSize struct {
-		NormalizedScreenWidth  string `xml:"normalizedScreenWidth"`
-		NormalizedScreenHeight string `xml:"normalizedScreenHeight"`
-	} `xml:"normalizedScreenSize"`
+		NormalizedScreenWidth  string `xml:"normalizedScreenWidth" json:"normalizedScreenWidth"`
+		NormalizedScreenHeight string `xml:"normalizedScreenHeight" json:"normalizedScreenHeight"`
+	} `xml:"normalizedScreenSize" json:"normalizedScreenSize"`
 	RegionEntranceRegionList struct {
-		Size                 string `xml:"size,attr"`
+		Size                 string `xml:"size,attr" json:"size"`
 		RegionEntranceRegion []struct {
-			ID               string `xml:"id"`
-			SensitivityLevel string `xml:"sensitivityLevel"`
-			DetectionTarget  string `xml:"detectionTarget"`
-			AlarmConfidence  struct {
-				Text string `xml:",chardata"`
-				Opt  string `xml:"opt,attr"`
-			} `xml:"alarmConfidence"`
+			ID                    string `xml:"id" json:"id"`
+			SensitivityLevel      string `xml:"sensitivityLevel" json:"sensitivityLevel"`
+			DetectionTarget       string `xml:"detectionTarget" json:"detectionTarget"`
+			AlarmConfidence       string `xml:"alarmConfidence" json:"alarmConfidence"`
 			RegionCoordinatesList struct {
-				Text  string `xml:",chardata"`
-				Xmlns string `xml:"xmlns,attr"`
-			} `xml:"RegionCoordinatesList"`
-		} `xml:"RegionEntranceRegion"`
-	} `xml:"RegionEntranceRegionList"`
-	IsSupportMultiScene           string `xml:"isSupportMultiScene"`
-	IsSupportHumanMisinfoFilter   string `xml:"isSupportHumanMisinfoFilter"`
-	IsSupportVehicleMisinfoFilter string `xml:"isSupportVehicleMisinfoFilter"`
-	IsSupportTargetMultiSelect    string `xml:"isSupportTargetMultiSelect"`
+				RegionCoordinates []struct {
+					PositionX string `xml:"positionX" json:"positionX"`
+					PositionY string `xml:"positionY" json:"positionY"`
+				} `xml:"RegionCoordinates" json:"RegionCoordinates"`
+			} `xml:"RegionCoordinatesList" json:"RegionCoordinatesList"`
+		} `xml:"RegionEntranceRegion" json:"RegionEntranceRegion"`
+	} `xml:"RegionEntranceRegionList" json:"RegionEntranceRegionList"`
+	IsSupportMultiScene           string `xml:"isSupportMultiScene" json:"isSupportMultiScene"`
+	IsSupportHumanMisinfoFilter   string `xml:"isSupportHumanMisinfoFilter" json:"isSupportHumanMisinfoFilter"`
+	IsSupportVehicleMisinfoFilter string `xml:"isSupportVehicleMisinfoFilter" json:"isSupportVehicleMisinfoFilter"`
+	IsSupportTargetMultiSelect    string `xml:"isSupportTargetMultiSelect" json:"isSupportTargetMultiSelect"`
 }
 
-func (c *Client) GetRegionEntranceCap() ([]byte, error) {
-	return c.CommonGet("/ISAPI/Smart/regionEntrance/1/capabilities")
+func (c *Client) GetRegionEntranceCap() (resp RegionEntranceCap, err error) {
+	bytes, err := c.CommonGet("/ISAPI/Smart/regionEntrance/1/capabilities")
+	if err != nil {
+		logrus.Error("请求出错", err)
+		return
+	}
+	err = xml.Unmarshal(bytes, &resp)
+	return
 }
 
-func (c *Client) GetSizeRe() (resp []byte, err error) {
-	return c.CommonGet("/ISAPI/Smart/channels/1/calibrations/regionEntrance")
+func (c *Client) GetSizeRe() (resp SmartCalibrationList, err error) {
+	bytes, err := c.CommonGet("/ISAPI/Smart/channels/1/calibrations/regionEntrance")
+	if err != nil {
+		logrus.Error("请求出错", err)
+		return
+	}
+	err = xml.Unmarshal(bytes, &resp)
+	return
 }
 
-func (c *Client) PutSizeRe(data []byte) ([]byte, error) {
-	return c.CommonPut(data, "/ISAPI/Smart/channels/1/calibrations/regionEntrance")
+func (c *Client) PutSizeRe(data []byte) (resp ResponseStatus, err error) {
+	var info SmartCalibrationList
+	err = json.Unmarshal(data, &info)
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	marshal, err := xml.Marshal(info)
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	respData, err := c.CommonPut(marshal, "/ISAPI/Smart/channels/1/calibrations/regionEntrance")
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	err = xml.Unmarshal(respData, &resp)
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	return
 }
 
 // GetRegionEntrance 获取区域侦测参数
-func (c *Client) GetRegionEntrance() ([]byte, error) {
-	return c.CommonGet("/ISAPI/Smart/regionEntrance/1")
+func (c *Client) GetRegionEntrance() (resp RegionEntranceParam, err error) {
+	bytes, err := c.CommonGet("/ISAPI/Smart/regionEntrance/1")
+	if err != nil {
+		logrus.Error("请求出错", err)
+		return
+	}
+	err = xml.Unmarshal(bytes, &resp)
+	marshal, err := json.Marshal(resp)
+	if err != nil {
+		logrus.Error("请求出错", err)
+		return
+	}
+	fmt.Println("json数据:", string(marshal))
+	return
 }
 
 // PutRegionEntrance 配置区域侦测参数
-func (c *Client) PutRegionEntrance(data []byte) ([]byte, error) {
-	return c.CommonPut(data, "/ISAPI/Smart/regionEntrance/1")
+func (c *Client) PutRegionEntrance(data []byte) (resp ResponseStatus, err error) {
+	var info RegionEntranceParam
+	err = json.Unmarshal(data, &info)
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	marshal, err := xml.Marshal(info)
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	respData, err := c.CommonPut(marshal, "/ISAPI/Smart/regionEntrance/1")
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	err = xml.Unmarshal(respData, &resp)
+	if err != nil {
+		logrus.Error(err)
+		return ResponseStatus{}, err
+	}
+	return
+}
+
+type RegionEntranceCap struct {
+	ID      string `xml:"id"`
+	Enabled struct {
+		Text string `xml:",chardata" json:"value"`
+		Opt  string `xml:"opt,attr" json:"opt"`
+	} `xml:"enabled" json:"enabled"`
+	NormalizedScreenSize struct {
+		NormalizedScreenWidth  string `xml:"normalizedScreenWidth" json:"normalizedScreenWidth"`
+		NormalizedScreenHeight string `xml:"normalizedScreenHeight" json:"normalizedScreenHeight"`
+	} `xml:"normalizedScreenSize" json:"normalizedScreenSize"`
+	RegionEntranceRegionList struct {
+		Size                 string `xml:"size,attr" json:"size"`
+		RegionEntranceRegion []struct {
+			ID               string `xml:"id" json:"id"`
+			SensitivityLevel struct {
+				Text string `xml:",chardata" json:"value"`
+				Min  string `xml:"min,attr" json:"min"`
+				Max  string `xml:"max,attr" json:"max"`
+			} `xml:"sensitivityLevel" json:"sensitivityLevel"`
+			RegionCoordinatesList struct {
+				RegionCoordinates []struct {
+					PositionX string `xml:"positionX" json:"positionX"`
+					PositionY string `xml:"positionY" json:"positionY"`
+				} `xml:"RegionCoordinates" json:"RegionCoordinates"`
+			} `xml:"RegionCoordinatesList" json:"RegionCoordinatesList"`
+			MinRegionCoordinatesNum string `xml:"minRegionCoordinatesNum" json:"minRegionCoordinatesNum"`
+			MaxRegionCoordinatesNum string `xml:"maxRegionCoordinatesNum" json:"maxRegionCoordinatesNum"`
+			DetectionTarget         struct {
+				Text string `xml:",chardata" json:"value"`
+				Opt  string `xml:"opt,attr" json:"opt"`
+			} `xml:"detectionTarget" json:"detectionTarget"`
+			AlarmConfidence struct {
+				Text string `xml:",chardata" json:"value"`
+				Opt  string `xml:"opt,attr" json:"opt"`
+				Def  string `xml:"def,attr" json:"def"`
+			} `xml:"alarmConfidence" json:"alarmConfidence"`
+		} `xml:"RegionEntranceRegion" json:"RegionEntranceRegion"`
+	} `xml:"RegionEntranceRegionList" json:"RegionEntranceRegionList"`
+	IsSupportMultiScene           string `xml:"isSupportMultiScene" json:"isSupportMultiScene"`
+	IsSupportHumanMisinfoFilter   string `xml:"isSupportHumanMisinfoFilter" json:"isSupportHumanMisinfoFilter"`
+	IsSupportVehicleMisinfoFilter string `xml:"isSupportVehicleMisinfoFilter" json:"isSupportVehicleMisinfoFilter"`
+	IsSupportTargetMultiSelect    string `xml:"isSupportTargetMultiSelect" json:"isSupportTargetMultiSelect"`
+	IsSupportAllDayUpload         string `xml:"isSupportAllDayUpload" json:"isSupportAllDayUpload"`
 }

+ 32 - 28
isapi/isapi_system_deviceInfo.go

@@ -2,38 +2,42 @@ package isapi
 
 import (
 	"encoding/xml"
+	"github.com/sirupsen/logrus"
 )
 
 // DeviceInfo 设备信息
 type DeviceInfo struct {
-	XMLName              xml.Name `xml:"DeviceInfo,omitempty"`
-	XMLVersion           string   `xml:"version,attr"`
-	XMLNamespace         string   `xml:"xmlns,attr"`
-	DeviceName           string   `xml:"deviceName,omitempty" json:"deviceName,omitempty"`
-	DeviceID             string   `xml:"deviceID,omitempty" json:"deviceID,omitempty"`
-	DeviceDescription    string   `xml:"deviceDescription,omitempty" json:"deviceDescription,omitempty"`
-	DeviceLocation       string   `xml:"deviceLocation,omitempty" json:"deviceLocation,omitempty"`
-	SystemContact        string   `xml:"systemContact,omitempty" json:"systemContact,omitempty"` //生产商
-	Model                string   `xml:"model,omitempty" json:"model,omitempty"`
-	SerialNumber         string   `xml:"serialNumber,omitempty" json:"serialNumber,omitempty"`
-	MacAddress           string   `xml:"macAddress,omitempty" json:"macAddress,omitempty"`
-	FirmwareVersion      string   `xml:"firmwareVersion,omitempty" json:"firmwareVersion,omitempty"`
-	FirmwareReleasedDate string   `xml:"firmwareReleasedDate,omitempty" json:"firmwareReleasedDate,omitempty"`
-	EncoderVersion       string   `xml:"encoderVersion,omitempty" json:"encoderVersion,omitempty"`
-	EncoderReleasedDate  string   `xml:"encoderReleasedDate,omitempty" json:"encoderReleasedDate,omitempty"`
-	BootVersion          string   `xml:"bootVersion,omitempty" json:"bootVersion,omitempty"`
-	BootReleasedDate     string   `xml:"bootReleasedDate,omitempty" json:"bootReleasedDate,omitempty"`
-	HardwareVersion      string   `xml:"hardwareVersion,omitempty" json:"hardwareVersion,omitempty"`
-	DeviceType           string   `xml:"deviceType,omitempty" json:"deviceType,omitempty"`
-	TelecontrolID        string   `xml:"telecontrolID,omitempty" json:"telecontrolID,omitempty"`
-	SupportBeep          string   `xml:"supportBeep,omitempty" json:"supportBeep,omitempty"`
-	SupportVideoLoss     string   `xml:"supportVideoLoss" json:"supportVideoLoss"`
-	FirmwareVersionInfo  string   `xml:"firmwareVersionInfo" json:"firmwareVersionInfo"`
-	Manufacturer         string   `xml:"manufacturer" json:"manufacturer"`
-	SubSerialNumber      string   `xml:"subSerialNumber" json:"subSerialNumber"`
-	OEMCode              string   `xml:"OEMCode" json:"OEMCode"`
+	DeviceName           string `xml:"deviceName,omitempty" json:"deviceName,omitempty"`
+	DeviceID             string `xml:"deviceID,omitempty" json:"deviceID,omitempty"`
+	DeviceDescription    string `xml:"deviceDescription,omitempty" json:"deviceDescription,omitempty"`
+	DeviceLocation       string `xml:"deviceLocation,omitempty" json:"deviceLocation,omitempty"`
+	SystemContact        string `xml:"systemContact,omitempty" json:"systemContact,omitempty"` //生产商
+	Model                string `xml:"model,omitempty" json:"model,omitempty"`
+	SerialNumber         string `xml:"serialNumber,omitempty" json:"serialNumber,omitempty"`
+	MacAddress           string `xml:"macAddress,omitempty" json:"macAddress,omitempty"`
+	FirmwareVersion      string `xml:"firmwareVersion,omitempty" json:"firmwareVersion,omitempty"`
+	FirmwareReleasedDate string `xml:"firmwareReleasedDate,omitempty" json:"firmwareReleasedDate,omitempty"`
+	EncoderVersion       string `xml:"encoderVersion,omitempty" json:"encoderVersion,omitempty"`
+	EncoderReleasedDate  string `xml:"encoderReleasedDate,omitempty" json:"encoderReleasedDate,omitempty"`
+	BootVersion          string `xml:"bootVersion,omitempty" json:"bootVersion,omitempty"`
+	BootReleasedDate     string `xml:"bootReleasedDate,omitempty" json:"bootReleasedDate,omitempty"`
+	HardwareVersion      string `xml:"hardwareVersion,omitempty" json:"hardwareVersion,omitempty"`
+	DeviceType           string `xml:"deviceType,omitempty" json:"deviceType,omitempty"`
+	TelecontrolID        string `xml:"telecontrolID,omitempty" json:"telecontrolID,omitempty"`
+	SupportBeep          string `xml:"supportBeep,omitempty" json:"supportBeep,omitempty"`
+	SupportVideoLoss     string `xml:"supportVideoLoss" json:"supportVideoLoss"`
+	FirmwareVersionInfo  string `xml:"firmwareVersionInfo" json:"firmwareVersionInfo"`
+	Manufacturer         string `xml:"manufacturer" json:"manufacturer"`
+	SubSerialNumber      string `xml:"subSerialNumber" json:"subSerialNumber"`
+	OEMCode              string `xml:"OEMCode" json:"OEMCode"`
 }
 
-func (c *Client) GetDeviceInfo() ([]byte, error) {
-	return c.CommonGet("/ISAPI/System/deviceInfo")
+func (c *Client) GetDeviceInfo() (resp DeviceInfo, err error) {
+	bytes, err := c.CommonGet("/ISAPI/System/deviceInfo")
+	if err != nil {
+		logrus.Error("请求出错", err)
+		return
+	}
+	err = xml.Unmarshal(bytes, &resp)
+	return
 }

+ 5 - 5
isapi/response.go

@@ -1,9 +1,9 @@
 package isapi
 
 type ResponseStatus struct {
-	RequestURL    string `xml:"requestURL"`
-	StatusCode    int    `xml:"statusCode"`
-	StatusString  string `xml:"statusString"`
-	SubStatusCode string `xml:"subStatusCode"`
-	Description   string `xml:"description"`
+	RequestURL    string `xml:"requestURL" json:"requestURL"`
+	StatusCode    int    `xml:"statusCode" json:"statusCode"`
+	StatusString  string `xml:"statusString" json:"statusString"`
+	SubStatusCode string `xml:"subStatusCode" json:"subStatusCode"`
+	Description   string `xml:"description" json:"description"`
 }

+ 21 - 4
isapi/sip.go

@@ -1,5 +1,10 @@
 package isapi
 
+import (
+	"encoding/xml"
+	"github.com/sirupsen/logrus"
+)
+
 type SIPServerList struct {
 	SIPServer []struct {
 		ID        string `xml:"id" yaml:"ID"`
@@ -43,12 +48,24 @@ type SIPServerList struct {
 	} `xml:"SIPServer"`
 }
 
-func (c *Client) PutSip(data []byte) ([]byte, error) {
-	return c.CommonPut(data, "/ISAPI/System/Network/SIP")
+func (c *Client) PutSip(data []byte) (resp ResponseStatus, err error) {
+	bytes, err := c.CommonPut(data, "/ISAPI/System/Network/SIP")
+	if err != nil {
+		logrus.Error("请求出错", err)
+		return
+	}
+	err = xml.Unmarshal(bytes, &resp)
+	return
 }
 
-func (c *Client) PutSipInfo(data []byte) ([]byte, error) {
-	return c.CommonPut(data, "/ISAPI/System/Network/SIP/1/SIPInfo")
+func (c *Client) PutSipInfo(data []byte) (resp ResponseStatus, err error) {
+	bytes, err := c.CommonPut(data, "/ISAPI/System/Network/SIP/1/SIPInfo")
+	if err != nil {
+		logrus.Error("请求出错", err)
+		return
+	}
+	err = xml.Unmarshal(bytes, &resp)
+	return
 }
 
 type SIPInfo struct {

+ 1 - 1
service/app/gateway.go

@@ -53,7 +53,7 @@ func (gs *GatewayService) List(req request.GatewayRequest) (list []response.Gate
 		db.Where("i.ipcast_id = ?", req.IpcastId)
 	}
 	if req.CameraSn != "" {
-		db.Where("c.camera_sn LIKE ?", "%"+req.CameraSn)
+		db.Where("c.sn LIKE ?", "%"+req.CameraSn)
 	}
 	if req.Name != "" {
 		db.Where("gateway_name LIKE ?", "%"+req.Name+"%")