multiscreenController.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package controller
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "iot_manager_service/app/middleware"
  5. edgeService "iot_manager_service/app/security/edge_service"
  6. "iot_manager_service/app/security/service"
  7. "iot_manager_service/util/common"
  8. "net/http"
  9. "strconv"
  10. )
  11. // TODO: 未记录日志
  12. var Multiscreen = new(multiscreenCtl)
  13. type multiscreenCtl struct{}
  14. func (c *multiscreenCtl) Ptzhome(ctx *gin.Context) {
  15. code := ctx.Query("sn")
  16. name := ctx.Query("name")
  17. flag, _ := strconv.Atoi(ctx.Query("flag"))
  18. vidiconService := edgeService.ForVidiconService{}
  19. operate, err := vidiconService.Ptzhome(code, name, flag)
  20. if err != nil {
  21. ctx.JSON(http.StatusOK, err)
  22. }
  23. if !operate {
  24. ctx.JSON(http.StatusOK, nil)
  25. return
  26. }
  27. ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, nil))
  28. }
  29. func (c *multiscreenCtl) List(ctx *gin.Context) {
  30. value, _ := ctx.Get(middleware.Authorization)
  31. claims := value.(*middleware.Claims)
  32. list, err := service.MultiscreenService.List(claims)
  33. if err != nil {
  34. ctx.JSON(http.StatusOK, err)
  35. }
  36. ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, list))
  37. }
  38. func (c *multiscreenCtl) Submit(ctx *gin.Context) {
  39. value, _ := ctx.Get(middleware.Authorization)
  40. claims := value.(*middleware.Claims)
  41. site, _ := strconv.Atoi(ctx.Query("site"))
  42. id, _ := strconv.Atoi(ctx.Query("id"))
  43. service.MultiscreenService.Save(claims, site, id)
  44. ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, nil))
  45. }