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" ) // LightingRate 灯控能耗统计 var LightingRate = new(lightingRateCtl) type lightingRateCtl struct{} func (c lightingRateCtl) List(ctx *gin.Context) { value, _ := ctx.Get(middleware.Authorization) claims := value.(*middleware.Claims) var req model.RequestLightingRateFilter 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.LightingRateService.GetDayList(claims.TenantId, req) } else { records, err = service.LightingRateService.GetMonthList(claims.TenantId, req) } if err != nil { ctx.JSON(http.StatusOK, err) return } ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, records)) }