12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- package controller
- import (
- "github.com/gin-gonic/gin"
- "iot_manager_service/app/middleware"
- "iot_manager_service/app/operation/model"
- "iot_manager_service/app/operation/service"
- "iot_manager_service/util/common"
- "net/http"
- "strconv"
- )
- // Capture 抓拍单元
- var Capture = new(captureCtl)
- type captureCtl struct{}
- // CountList 取车流量 月日
- func (c captureCtl) CountList(ctx *gin.Context) {
- value, _ := ctx.Get(middleware.Authorization)
- claims := value.(*middleware.Claims)
- var req model.RequestCaptureFilter
- err := ctx.ShouldBindQuery(&req)
- if err != nil {
- ctx.JSON(http.StatusOK, err)
- return
- }
- var records interface{}
- err = nil
- if req.QueryType == "day" {
- records, err = service.CaptureService.GetDayVehicleTotal(claims.TenantId, req)
- } else {
- records, err = service.CaptureService.GetMonthVehicleTotal(claims.TenantId, req)
- }
- if err != nil {
- ctx.JSON(http.StatusOK, err)
- return
- }
- ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, records))
- }
- // SuggestSpeed 取抓拍单元 方位
- func (c captureCtl) SuggestSpeed(ctx *gin.Context) {
- captureId, err := strconv.Atoi(ctx.Query("captureId"))
- if err != nil {
- ctx.JSON(http.StatusOK, err)
- return
- }
- value, _ := ctx.Get(middleware.Authorization)
- claims := value.(*middleware.Claims)
- var records interface{}
- records, err = service.CaptureService.GetSuggestSpeed(claims.TenantId, captureId)
- if err != nil {
- ctx.JSON(http.StatusOK, err)
- return
- }
- ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, records))
- }
|