workbenchController.go 727 B

12345678910111213141516171819202122232425262728
  1. package controller
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "iot_manager_service/app/device/service"
  5. "iot_manager_service/app/middleware"
  6. "iot_manager_service/util"
  7. "net/http"
  8. )
  9. // 工作台管理对象
  10. var Workbench = new(workbenchCtl)
  11. type workbenchCtl struct{}
  12. func (c *workbenchCtl) CountDevice(ctx *gin.Context) {
  13. value, isExist := ctx.Get(middleware.Authorization)
  14. if !isExist || value == nil {
  15. ctx.JSON(http.StatusUnauthorized, util.NormalResponse(http.StatusUnauthorized, "", nil))
  16. }
  17. device, err := service.WorkbenchService.CountDevice(value.(*middleware.JwtToken).TenantId)
  18. if err != nil {
  19. ctx.JSON(http.StatusOK, err)
  20. return
  21. }
  22. ctx.JSON(http.StatusOK, util.SuccessResponse(util.Succeeded, device))
  23. }