handleHistory.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package controller
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "iot_manager_service/app/middleware"
  5. "iot_manager_service/app/system/model"
  6. service2 "iot_manager_service/app/system/service"
  7. "iot_manager_service/util/common"
  8. "math"
  9. "net/http"
  10. "strconv"
  11. )
  12. // 一键报警服务表管理对象
  13. var HandleHistory = new(handleHistoryCtl)
  14. type handleHistoryCtl struct{}
  15. func (c *handleHistoryCtl) List(ctx *gin.Context) {
  16. value, _ := ctx.Get(middleware.Authorization)
  17. claims := value.(*middleware.Claims)
  18. handleContent := ctx.Query("handleContent")
  19. operationType := ctx.Query("operationType")
  20. moduleType := ctx.Query("moduleType")
  21. current, _ := strconv.Atoi(ctx.Query("current"))
  22. size, _ := strconv.Atoi(ctx.Query("size"))
  23. if current == 0 {
  24. current = 1
  25. }
  26. if size <= 0 || size > 100 {
  27. size = 10
  28. }
  29. list, counts, err := service2.OperationHisService.List(claims.TenantId, handleContent, operationType, moduleType, current,
  30. size)
  31. if err != nil {
  32. ctx.JSON(http.StatusOK, err)
  33. return
  34. }
  35. pages := int(math.Ceil(float64(counts) / float64(size)))
  36. rsp := model.RsqOperationHisList{
  37. Current: current,
  38. Size: size,
  39. Total: counts,
  40. Pages: pages,
  41. Records: list,
  42. }
  43. ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, rsp))
  44. }