1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- package controller
- import (
- "github.com/gin-gonic/gin"
- "iot_manager_service/app/device/service"
- "iot_manager_service/app/middleware"
- "iot_manager_service/util/common"
- "net/http"
- )
- // 工作台管理对象
- var Workbench = new(workbenchCtl)
- type workbenchCtl struct{}
- func (c *workbenchCtl) CountDevice(ctx *gin.Context) {
- value, _ := ctx.Get(middleware.Authorization)
- claims := value.(*middleware.Claims)
- devices, err := service.WorkbenchService.CountDevice(claims.TenantId)
- if err != nil {
- ctx.JSON(http.StatusOK, err)
- return
- }
- ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, devices))
- }
- func (c *workbenchCtl) CountAlarm(ctx *gin.Context) {
- value, _ := ctx.Get(middleware.Authorization)
- claims := value.(*middleware.Claims)
- alarms, err := service.WorkbenchService.CountAlarm(claims.TenantId)
- if err != nil {
- ctx.JSON(http.StatusOK, err)
- return
- }
- ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, alarms))
- }
- func (c *workbenchCtl) Aqi(ctx *gin.Context) {
- value, _ := ctx.Get(middleware.Authorization)
- claims := value.(*middleware.Claims)
- alarms, err := service.WorkbenchService.Aqi(claims.TenantId)
- if err != nil {
- ctx.JSON(http.StatusOK, err)
- return
- }
- ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, alarms))
- }
- func (c *workbenchCtl) CountJobTodo(ctx *gin.Context) {
- value, _ := ctx.Get(middleware.Authorization)
- claims := value.(*middleware.Claims)
- alarms, err := service.WorkbenchService.CountJobTodo(claims.TenantId)
- if err != nil {
- ctx.JSON(http.StatusOK, err)
- return
- }
- ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, alarms))
- }
- func (c *workbenchCtl) Notification(ctx *gin.Context) {
- value, _ := ctx.Get(middleware.Authorization)
- claims := value.(*middleware.Claims)
- alarms, err := service.WorkbenchService.Notification(claims.TenantId)
- if err != nil {
- ctx.JSON(http.StatusOK, err)
- return
- }
- ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, alarms))
- }
- func (c *workbenchCtl) LightRate(ctx *gin.Context) {
- value, _ := ctx.Get(middleware.Authorization)
- claims := value.(*middleware.Claims)
- //queryType=month&startDate=2022-09-01&endDate=2022-10-04
- alarms, err := service.WorkbenchService.LightRate(claims.TenantId)
- if err != nil {
- ctx.JSON(http.StatusOK, err)
- return
- }
- ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, alarms))
- }
|