fieldDetection.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package isapi
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "github.com/sirupsen/logrus"
  5. "io/ioutil"
  6. "lc-fangdaosha/isapi"
  7. )
  8. //区域入侵
  9. type FieldDetectionApi struct {
  10. }
  11. // GetFieldDetectionCap 获取单个通道区域入侵规则参数配置能力
  12. func (api FieldDetectionApi) GetFieldDetectionCap(c *gin.Context) {
  13. host, err := GetHost(c)
  14. if err != nil {
  15. logrus.Errorf("获取host失败:%s", err.Error())
  16. return
  17. }
  18. isapi.TouChuan(host, isapi.GetFieldDetectionCap, nil, c)
  19. }
  20. // GetSizeFd 获取监测目标的尺寸
  21. func (api FieldDetectionApi) GetSizeFd(c *gin.Context) {
  22. host, err := GetHost(c)
  23. if err != nil {
  24. logrus.Errorf("获取host失败:%s", err.Error())
  25. return
  26. }
  27. isapi.TouChuan(host, isapi.GetFieldDetectionCal, nil, c)
  28. }
  29. // PutSizeFd 配置监测目标的尺寸
  30. func (api FieldDetectionApi) PutSizeFd(c *gin.Context) {
  31. defer c.Request.Body.Close()
  32. all, err := ioutil.ReadAll(c.Request.Body)
  33. if err != nil {
  34. logrus.Errorf("读取数据失败:%e\n", err)
  35. }
  36. host, err := GetHost(c)
  37. if err != nil {
  38. logrus.Errorf("获取设备连接失败:%e\n", err)
  39. return
  40. }
  41. isapi.TouChuan(host, isapi.PutFieldDetectionCal, all, c)
  42. }
  43. // GetFieldDetection 获取单个通道区域入侵侦测规则
  44. func (api FieldDetectionApi) GetFieldDetection(c *gin.Context) {
  45. host, err := GetHost(c)
  46. if err != nil {
  47. logrus.Errorf("获取host失败:%s", err.Error())
  48. return
  49. }
  50. isapi.TouChuan(host, isapi.GetFieldDetection, nil, c)
  51. }
  52. // PutFieldDetection 配置单个通道区域入侵侦测规则
  53. func (api FieldDetectionApi) PutFieldDetection(c *gin.Context) {
  54. defer c.Request.Body.Close()
  55. all, err := ioutil.ReadAll(c.Request.Body)
  56. if err != nil {
  57. logrus.Errorf("读取数据失败:%e\n", err)
  58. return
  59. }
  60. host, err := GetHost(c)
  61. if err != nil {
  62. logrus.Errorf("获取设备连接失败:%e\n", err)
  63. return
  64. }
  65. isapi.TouChuan(host, isapi.PutRegionEntrance, all, c)
  66. }