captureController.go 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. package controller
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "iot_manager_service/app/middleware"
  5. "iot_manager_service/app/operation/model"
  6. "iot_manager_service/app/operation/service"
  7. "iot_manager_service/util/common"
  8. "net/http"
  9. "strconv"
  10. )
  11. // Capture 抓拍单元
  12. var Capture = new(captureCtl)
  13. type captureCtl struct{}
  14. // CountList 取车流量 月日
  15. func (c captureCtl) CountList(ctx *gin.Context) {
  16. value, _ := ctx.Get(middleware.Authorization)
  17. claims := value.(*middleware.Claims)
  18. var req model.RequestCaptureFilter
  19. err := ctx.ShouldBindQuery(&req)
  20. if err != nil {
  21. ctx.JSON(http.StatusOK, err)
  22. return
  23. }
  24. var records interface{}
  25. err = nil
  26. if req.QueryType == "day" {
  27. records, err = service.CaptureService.GetDayVehicleTotal(claims.TenantId, req)
  28. } else {
  29. records, err = service.CaptureService.GetMonthVehicleTotal(claims.TenantId, req)
  30. }
  31. if err != nil {
  32. ctx.JSON(http.StatusOK, err)
  33. return
  34. }
  35. ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, records))
  36. }
  37. // SuggestSpeed 取抓拍单元 方位
  38. func (c captureCtl) SuggestSpeed(ctx *gin.Context) {
  39. captureId, err := strconv.Atoi(ctx.Query("captureId"))
  40. if err != nil {
  41. ctx.JSON(http.StatusOK, err)
  42. return
  43. }
  44. value, _ := ctx.Get(middleware.Authorization)
  45. claims := value.(*middleware.Claims)
  46. var records interface{}
  47. records, err = service.CaptureService.GetSuggestSpeed(claims.TenantId, captureId)
  48. if err != nil {
  49. ctx.JSON(http.StatusOK, err)
  50. return
  51. }
  52. ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, records))
  53. }
  54. // AreaList 归属地统计
  55. func (c captureCtl) AreaList(ctx *gin.Context) {
  56. value, _ := ctx.Get(middleware.Authorization)
  57. claims := value.(*middleware.Claims)
  58. var req model.RequestCaptureFilter
  59. err := ctx.ShouldBindQuery(&req)
  60. if err != nil {
  61. ctx.JSON(http.StatusOK, err)
  62. return
  63. }
  64. var records interface{}
  65. records, err = service.CaptureAreaService.GetAreaList(claims.TenantId, req)
  66. if err != nil {
  67. ctx.JSON(http.StatusOK, err)
  68. return
  69. }
  70. ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, records))
  71. }
  72. func (c captureCtl) AreaTypeList(ctx *gin.Context) {
  73. value, _ := ctx.Get(middleware.Authorization)
  74. claims := value.(*middleware.Claims)
  75. var req model.RequestCaptureFilter
  76. err := ctx.ShouldBindQuery(&req)
  77. if err != nil {
  78. ctx.JSON(http.StatusOK, err)
  79. return
  80. }
  81. var records interface{}
  82. records, err = service.CaptureAreaService.GetAreaTypeList(claims.TenantId, req)
  83. if err != nil {
  84. ctx.JSON(http.StatusOK, err)
  85. return
  86. }
  87. ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, records))
  88. }