package controller import ( "github.com/gin-gonic/gin" "iot_manager_service/app/device/service" "iot_manager_service/app/middleware" "iot_manager_service/util" "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, util.SuccessResponse(util.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, util.SuccessResponse(util.Succeeded, alarms)) } func (c *workbenchCtl) Aqi(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, util.SuccessResponse(util.Succeeded, alarms)) }