From a3c0b0d20c0840234560eab53b3b33730bfefc2d Mon Sep 17 00:00:00 2001 From: wzh <zhuhaow@phiskin.com> Date: 星期三, 10 八月 2022 20:30:02 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- phis-feign/src/main/java/com/hz/his/dto/dcp/FilterUserDto.java | 22 +++++++ phis-feign/src/main/java/com/hz/his/dto/dcp/FilterUserTagDto.java | 12 --- phis-feign/src/main/java/com/hz/his/feign/service/dcp/SUserTagInfoService.java | 2 phis-feign/src/main/java/com/hz/his/dto/dcp/FilterUserTagIdDto.java | 18 ++++++ phis-feign/src/main/java/com/hz/his/util/PageHelperUtil.java | 93 +++++++++++++++++++++++++++++++ 5 files changed, 136 insertions(+), 11 deletions(-) diff --git a/phis-feign/src/main/java/com/hz/his/dto/dcp/FilterUserDto.java b/phis-feign/src/main/java/com/hz/his/dto/dcp/FilterUserDto.java new file mode 100644 index 0000000..2265e04 --- /dev/null +++ b/phis-feign/src/main/java/com/hz/his/dto/dcp/FilterUserDto.java @@ -0,0 +1,22 @@ +package com.hz.his.dto.dcp; + +import lombok.Data; + +import java.util.List; + +@Data +public class FilterUserDto { + + /**鎬绘暟閲�*/ + private Integer total; + /**姣忛〉鏁伴噺*/ + private Integer pages; + /**椤�*/ + private Integer pageNum; + /**姣忛〉鏁伴噺*/ + private Integer pageSize; + /**鏄惁鏈�鍚庝竴椤�*/ + private Boolean isLastPage; + /**鏍囩鍒楄〃*/ + private List<FilterUserTagDto> list; +} diff --git a/phis-feign/src/main/java/com/hz/his/dto/dcp/FilterUserTagInfoDto.java b/phis-feign/src/main/java/com/hz/his/dto/dcp/FilterUserTagDto.java similarity index 62% rename from phis-feign/src/main/java/com/hz/his/dto/dcp/FilterUserTagInfoDto.java rename to phis-feign/src/main/java/com/hz/his/dto/dcp/FilterUserTagDto.java index 36702fb..c090f43 100644 --- a/phis-feign/src/main/java/com/hz/his/dto/dcp/FilterUserTagInfoDto.java +++ b/phis-feign/src/main/java/com/hz/his/dto/dcp/FilterUserTagDto.java @@ -1,18 +1,14 @@ package com.hz.his.dto.dcp; -import com.alibaba.fastjson.JSONObject; import lombok.Data; import java.util.List; -/** - * 鏍囩绛涢�夌敤鎴锋暟鎹瓺to - */ @Data -public class FilterUserTagInfoDto { +public class FilterUserTagDto { /**鎺掑簭鍏抽敭淇℃伅 鍐呭寘鍚�(userId platformCode) 鎺掑簭缁撴灉*/ - private JSONObject id; + private FilterUserTagIdDto id; /**鐢ㄦ埛缂栧彿*/ private String userNo; @@ -22,8 +18,4 @@ /**鏍囩鍒楄〃*/ private List<String> tagList; - - public FilterUserTagInfoDto() { - - } } diff --git a/phis-feign/src/main/java/com/hz/his/dto/dcp/FilterUserTagIdDto.java b/phis-feign/src/main/java/com/hz/his/dto/dcp/FilterUserTagIdDto.java new file mode 100644 index 0000000..63ece83 --- /dev/null +++ b/phis-feign/src/main/java/com/hz/his/dto/dcp/FilterUserTagIdDto.java @@ -0,0 +1,18 @@ +package com.hz.his.dto.dcp; + +import lombok.Data; + +/** + * 鏍囩绛涢�夌敤鎴锋暟鎹瓺to + */ +@Data +public class FilterUserTagIdDto { + + private String userId; + + private String platformCode; + + public FilterUserTagIdDto() { + + } +} diff --git a/phis-feign/src/main/java/com/hz/his/feign/service/dcp/SUserTagInfoService.java b/phis-feign/src/main/java/com/hz/his/feign/service/dcp/SUserTagInfoService.java index 8f09928..b645b90 100644 --- a/phis-feign/src/main/java/com/hz/his/feign/service/dcp/SUserTagInfoService.java +++ b/phis-feign/src/main/java/com/hz/his/feign/service/dcp/SUserTagInfoService.java @@ -20,7 +20,7 @@ @PostMapping("/user/tag/info/list") Result userTagInfoListData(@RequestBody UserTagInfoDto userTagInfoDto); - /**鏌ヨ鐢ㄦ埛鏍囩鐢ㄦ埛鍒楄〃 杩斿洖(FilterUserTagInfoDto)*/ + /**鏌ヨ鐢ㄦ埛鏍囩鐢ㄦ埛鍒楄〃 杩斿洖(FilterUserDto)*/ @RequestMapping("/user/tag/info/user/list") Result userListData(@RequestBody UserTagInfoDto userTagInfoDto); diff --git a/phis-feign/src/main/java/com/hz/his/util/PageHelperUtil.java b/phis-feign/src/main/java/com/hz/his/util/PageHelperUtil.java new file mode 100644 index 0000000..e26e9d7 --- /dev/null +++ b/phis-feign/src/main/java/com/hz/his/util/PageHelperUtil.java @@ -0,0 +1,93 @@ +package com.hz.his.util; + +import com.github.pagehelper.PageInfo; + +import java.util.List; + +/** + * @author fwq + * PageHelperTool + * 鍒嗛〉宸ュ叿绫�:瀵规煡璇㈢粨鏋滃鐞嗗悗鍐嶈繘琛屽垎椤� + */ +public class PageHelperUtil { + + public static <T> PageInfo<T> pageInfo(int currentPage, int pageSize, List list) { + + int fromIndex = 0; + int toIndex = 0; + //鍙栧嚭鎬昏褰曟暟 + int total = list.size(); + //褰撳墠椤电爜 + currentPage = (currentPage <= 0) ? 1 : currentPage; + //褰撳墠椤垫潯鐩暟 + pageSize = (pageSize <= 0) ? 10 : (Math.min(pageSize, total)); + + if (total / pageSize == 0 && total % pageSize > 0) { + fromIndex = 0; + toIndex = total; + } else { + if (total / pageSize >= 1 && total % pageSize >= 0) { + fromIndex = pageSize * (currentPage - 1); + if (pageSize * currentPage >= total) { + toIndex = total; + } else { + toIndex = pageSize * currentPage; + } + } + } + + List pageList = list.subList(fromIndex, toIndex); + PageInfo pageInfo = new PageInfo<>(pageList); + return initPageInfoObj(currentPage, total, pageSize, pageInfo); + } + + private static <T> PageInfo<T> initPageInfoObj(int currentPage, int total, int pageSize, PageInfo<T> pageInfo) { + pageInfo.setNextPage(currentPage < ((total + pageSize - 1) / pageSize) ? currentPage + 1 : currentPage); + pageInfo.setTotal(total); + pageInfo.setPageNum(currentPage); + pageInfo.setPages((total + pageSize - 1) / pageSize); + pageInfo.setPrePage(currentPage > 1 ? currentPage - 1 : currentPage); + pageInfo.setIsFirstPage(currentPage == 1); + pageInfo.setIsLastPage(currentPage == (total + pageSize - 1) / pageSize); + pageInfo.setHasPreviousPage(currentPage != 1); + pageInfo.setHasNextPage(currentPage != (total + pageSize - 1) / pageSize); + return calcNavigatepageNums(pageInfo); + } + + private static <T> PageInfo<T> calcNavigatepageNums(PageInfo<T> pageInfo) { + //褰撴�婚〉鏁板皬浜庢垨绛変簬瀵艰埅椤电爜鏁版椂 + if (pageInfo.getPages() <= pageInfo.getNavigatePages()) { + pageInfo.setNavigatepageNums(new int[pageInfo.getPages()]); + for (int i = 0; i < pageInfo.getPages(); i++) { + pageInfo.getNavigatepageNums()[i] = i + 1; + } + } else { //褰撴�婚〉鏁板ぇ浜庡鑸〉鐮佹暟鏃� + pageInfo.setNavigatepageNums(new int[pageInfo.getNavigatePages()]); + int startNum = pageInfo.getPageNum() - pageInfo.getNavigatePages() / 2; + int endNum = pageInfo.getPageNum() + pageInfo.getNavigatePages() / 2; + + if (startNum < 1) { + startNum = 1; + //(鏈�鍓峮avigatePages椤� + for (int i = 0; i < pageInfo.getNavigatePages(); i++) { + pageInfo.getNavigatepageNums()[i] = startNum++; + } + } else if (endNum > pageInfo.getPages()) { + endNum = pageInfo.getPages(); + //鏈�鍚巒avigatePages椤� + for (int i = pageInfo.getNavigatePages() - 1; i >= 0; i--) { + pageInfo.getNavigatepageNums()[i] = endNum--; + } + } else { + //鎵�鏈変腑闂撮〉 + for (int i = 0; i < pageInfo.getNavigatePages(); i++) { + pageInfo.getNavigatepageNums()[i] = startNum++; + } + } + } + return pageInfo; + } + + +} + -- Gitblit v1.8.0