handleHistoryController.go 1000 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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. "strconv"
  9. )
  10. // 一键报警服务表管理对象
  11. var HandleHistory = new(handleHistoryCtl)
  12. type handleHistoryCtl struct{}
  13. func (c *handleHistoryCtl) List(ctx *gin.Context) {
  14. value, _ := ctx.Get(middleware.Authorization)
  15. claims := value.(*middleware.Claims)
  16. handleContent := ctx.Query("handleContent")
  17. operationType := ctx.Query("operationType")
  18. moduleType := ctx.Query("moduleType")
  19. current, _ := strconv.Atoi(ctx.Query("current"))
  20. size, _ := strconv.Atoi(ctx.Query("size"))
  21. if current == 0 {
  22. current = 1
  23. }
  24. if size <= 0 || size > 100 {
  25. size = 10
  26. }
  27. list, err := service.OperationHisService.List(claims.TenantId, handleContent, operationType, moduleType, current,
  28. size)
  29. if err != nil {
  30. ctx.JSON(http.StatusOK, err)
  31. return
  32. }
  33. ctx.JSON(http.StatusOK, util.SuccessResponse(util.Succeeded, list))
  34. }