package controller import ( "github.com/gin-gonic/gin" "iot_manager_service/app/middleware" "iot_manager_service/app/system/model" service2 "iot_manager_service/app/system/service" "iot_manager_service/util/common" "math" "net/http" "strconv" ) // 一键报警服务表管理对象 var HandleHistory = new(handleHistoryCtl) type handleHistoryCtl struct{} func (c *handleHistoryCtl) List(ctx *gin.Context) { value, _ := ctx.Get(middleware.Authorization) claims := value.(*middleware.Claims) handleContent := ctx.Query("handleContent") operationType := ctx.Query("operationType") moduleType := ctx.Query("moduleType") current, _ := strconv.Atoi(ctx.Query("current")) size, _ := strconv.Atoi(ctx.Query("size")) if current == 0 { current = 1 } if size <= 0 || size > 100 { size = 10 } list, counts, err := service2.OperationHisService.List(claims.TenantId, handleContent, operationType, moduleType, current, size) if err != nil { ctx.JSON(http.StatusOK, err) return } pages := int(math.Ceil(float64(counts) / float64(size))) rsp := model.RsqOperationHisList{ Current: current, Size: size, Total: counts, Pages: pages, Records: list, } ctx.JSON(http.StatusOK, common.SuccessResponse(common.Succeeded, rsp)) }