From 4f99f59668c9160ca60958b7347944def26f2228 Mon Sep 17 00:00:00 2001 From: liurunyu <lry9898@163.com> Date: 星期日, 27 四月 2025 10:58:53 +0800 Subject: [PATCH] 回退配置 --- pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/webUtil/QueryResultVo.java | 97 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 97 insertions(+), 0 deletions(-) diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/webUtil/QueryResultVo.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/webUtil/QueryResultVo.java new file mode 100644 index 0000000..41344a3 --- /dev/null +++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/webUtil/QueryResultVo.java @@ -0,0 +1,97 @@ +package com.dy.common.webUtil; + + +import com.alibaba.fastjson2.annotation.JSONField; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; + +import java.util.Map; + +@Data +@ToString +@NoArgsConstructor +@AllArgsConstructor +@Builder +@Schema(name = "鏌ヨ缁撴灉鍩虹被") +public class QueryResultVo<T> { + + /** + * 姣忛〉鏄剧ず鐨勮褰曟暟 + */ + @Schema(description = "姣忛〉璁板綍鏁�") + public Integer pageSize ; + /** + * 璁板綍鎬绘暟 + */ + @Schema(description = "璁板綍鎬绘暟") + public Long itemTotal ; + /** + * 褰撳墠椤� + */ + @Schema(description = "褰撳墠椤�") + public Integer pageCurr ; + /** + * 鎬婚〉鏁� + */ + @Schema(description = "鎬婚〉鏁�") + public Integer pageTotal ; + + @Schema(description = "鏁版嵁") + public T obj; + + /** + * 鏌ヨ寮�濮嬭褰� + */ + @Schema(hidden = true) + @JSONField(serialize = false) + public Integer queryStart ; + + /** + * 鏌ヨ鏁伴噺 + */ + @Schema(hidden = true) + @JSONField(serialize = false) + public Integer queryCount ; + + + public void calculateAndSet(Long itemTotal, Map<String, Object> params) { + this.itemTotal = itemTotal ; + if(this.itemTotal == null){ + this.itemTotal = 0L ; + } + + if(this.itemTotal == 0){ + this.pageSize = 10 ; + } + if(this.pageSize == null || this.pageSize <= 0){ + /** + * 鏈卞疂姘� 2024-01-30 淇敼 + * 鏈紶鍏ュ垎椤靛弬鏁版椂锛屽彇鍏ㄩ儴璁板綍 + */ + //this.pageSize = 1 ;//渚涗笅闈綔涓洪櫎鏁� + this.pageSize = 10 ;//渚涗笅闈綔涓洪櫎鏁� + } + + pageTotal = (int)Math.ceil((itemTotal==null?0.0D:itemTotal.doubleValue())/pageSize); + + if (pageTotal == 0) { + pageTotal = 1; + } + if (pageCurr == null || pageCurr < 1) { + pageCurr = 1; + } + if (pageCurr > pageTotal) { + pageCurr = pageTotal; + } + + //select * from table_name limit 5 锛�10;//浠庣6琛屽紑濮嬶紝妫�绱�10琛岃褰曪紝鍗筹細妫�绱㈣褰曡 6-15 + this.queryStart = (this.pageCurr - 1) * this.pageSize ; + this.queryCount = this.pageSize ; + + if(params != null){ + params.put("start", this.queryStart) ; + params.put("count", this.queryCount) ; + } + } + +} -- Gitblit v1.8.0