1234567891011121314151617181920212223242526272829303132333435363738 |
- 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"
- )
- // Alarm 告警统计
- var Alarm = new(alarmCtl)
- type alarmCtl struct{}
- func (c alarmCtl) List(ctx *gin.Context) {
- value, _ := ctx.Get(middleware.Authorization)
- claims := value.(*middleware.Claims)
- var req model.RequestAlarmFilter
- 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.AlarmService.GetDayList(claims.TenantId, req)
- } else {
- records, err = service.AlarmService.GetMonthList(claims.TenantId, req)
- }
- if err != nil {
- ctx.JSON(http.StatusOK, err)
- return
- }
- ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, records))
- }
|