From e0bf75fedccd21ae9f91e9a5e6a4934dc8a269dd Mon Sep 17 00:00:00 2001
From: zqy <2522236926@qq.com>
Date: 星期一, 15 七月 2024 12:43:18 +0800
Subject: [PATCH] 分页查看分享&下载
---
zhang-content/src/main/java/com/ruoyi/service/ZfDoctorShareService.java | 4
zhang-content/src/main/java/com/ruoyi/service/impl/ZfDoctorDownloadServiceImpl.java | 31 ++++++-
ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfDoctorShareController.java | 33 +++----
zhang-content/src/main/java/com/ruoyi/service/impl/ZfDoctorShareServiceImpl.java | 27 +++++-
ruoyi-common/src/main/java/com/ruoyi/common/utils/MapUtils.java | 11 ++
ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZInfoUserController.java | 8 ++
zhang-content/src/main/java/com/ruoyi/service/ZfDoctorService.java | 2
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java | 22 ++--
zhang-content/src/main/java/com/ruoyi/service/impl/ZfDoctorServiceImpl.java | 49 ++++++------
ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableSupport.java | 5 +
zhang-content/src/main/java/com/ruoyi/service/ZfDoctorDownloadService.java | 2
11 files changed, 123 insertions(+), 71 deletions(-)
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java
index 50fef41..2d491c2 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java
@@ -183,12 +183,12 @@
System.out.println("2222222222222222222222222222222222/");
infoUser.setFamilyId(mother.getFamilyId());
}
-// else if (user.getSpouseId()!=null) {
-// ZInfoUser spouse = zInfoUserService.getById(user.getSpouseId());
-// System.out.println("33333333333333333333333333333333333333333/");
-// infoUser.setFamilyId(spouse.getFamilyId());
-// infoUser.setSpouseId(user.getSpouseId());
-// }
+ else if (user.getSpouseId()!=null) {
+ ZInfoUser spouse = zInfoUserService.getById(user.getSpouseId());
+ System.out.println("33333333333333333333333333333333333333333/");
+ infoUser.setFamilyId(spouse.getFamilyId());
+ infoUser.setSpouseId(user.getSpouseId());
+ }
zInfoUserService.saveOrUpdate(infoUser);
if(user.getSpouseId()!=null) {
@@ -280,13 +280,13 @@
ZInfoUser mother = zInfoUserService.getById(userAll.getMid());
if (father.getIsMyFamily() == 1)
infoUser.setFamilyId(father.getFamilyId());
- if (mother.getIsMyFamily() == 1)
+ else if (mother.getIsMyFamily() == 1)
infoUser.setFamilyId(mother.getFamilyId());
}
-// else {
-// ZInfoUser spouse = zInfoUserService.getById(userAll.getSpouseId());
-// infoUser.setFamilyId(spouse.getFamilyId());
-// }
+ else {
+ ZInfoUser spouse = zInfoUserService.getById(userAll.getSpouseId());
+ infoUser.setFamilyId(spouse.getFamilyId());
+ }
//鍓嶇淇濊瘉浜嗚鑹蹭笉涓虹┖
// if(user.getRoleIds()[0]==102)
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZInfoUserController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZInfoUserController.java
index e4e2075..b904ad3 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZInfoUserController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZInfoUserController.java
@@ -230,6 +230,14 @@
return AjaxResult.success(satisfyIds);
}
+ /**
+ * 鏍规嵁鐢ㄦ埛id鍒ゆ柇鏄惁鏄瓙瀛� uid:闀胯緢id,tpfid:鎴戣嚜宸辩殑zinfoid
+ */
+ @GetMapping("/uidUJd/{uid}/{tpfid}")
+ public AjaxResult findByUidAndUid2(@PathVariable("uid") Long uid ,@PathVariable("tpfid") Long tpfid){
+ return AjaxResult.success( zInfoUserService.findByuid(uid,tpfid));
+ }
+
@GetMapping("/sex/{sex}")
public AjaxResult findBySex(@PathVariable("sex") Integer sex)
{
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfDoctorShareController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfDoctorShareController.java
index cab2981..ea95f3a 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfDoctorShareController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZfDoctorShareController.java
@@ -1,8 +1,10 @@
package com.ruoyi.web.controller.zhang;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.text.Convert;
+import com.ruoyi.common.utils.MapUtils;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.domain.ShareMore;
import com.ruoyi.domain.ZfDoctor;
@@ -15,10 +17,11 @@
import javax.annotation.Resource;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.stream.Collectors;
-import static com.ruoyi.common.core.page.TableSupport.PAGE_NUM;
-import static com.ruoyi.common.core.page.TableSupport.PAGE_SIZE;
+import static com.ruoyi.common.core.page.TableSupport.*;
@RestController
@RequestMapping("/ZfDoctorShare")
@@ -47,18 +50,19 @@
*/
@PostMapping("/getInfoByUserId")
public AjaxResult empowerGetInfo(@RequestBody ShareMore zfDoctor){
- Integer pageNum = Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1);
+ Integer pageNo = Convert.toInt(ServletUtils.getParameter(PAGE_NO), 1);
Integer pageSize = Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10);
-
- return zfDoctorService.selectListById(zfDoctorShareService.listByFidAid(zfDoctor),pageNum,pageSize);
+ return zfDoctorShareService.listByFidAid(zfDoctor,pageNo,pageSize) ;
}
/**
* 鐢ㄦ埛鑷繁鏌ョ湅鍒汉鍒嗕韩鐨勬暟鎹拰鍒嗕韩浜�
*/
@GetMapping("/getInfoByShareId")
- public AjaxResult empowerGetInfo2(){
- return zfDoctorShareService.listUserId();
+ public AjaxResult empowerGetInfo2(@RequestBody ShareMore zfDoctor){
+ Integer pageNo = Convert.toInt(ServletUtils.getParameter(PAGE_NO), 1);
+ Integer pageSize = Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10);
+ return zfDoctorShareService.listUserId(zfDoctor,pageNo ,pageSize);
}
/**
* 鏍规嵁userId鍜宻hareId鏀跺洖宸茬粡鎺堟潈缁欓偅浜涗汉
@@ -80,19 +84,10 @@
* 灞曠ず涓嬭浇鍒嗕韩鐨勬暟鎹�
*/
@GetMapping("/all")
- public List<ZfDoctor> data(ZfDoctorDownload zfDoctorDownload){
- Integer pageNum = Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1);
+ public AjaxResult data(ZfDoctorDownload zfDoctorDownload){
+ Integer pageNo = Convert.toInt(ServletUtils.getParameter(PAGE_NO), 1);
Integer pageSize = Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10);
- List<ZfDoctorDownload> as = zfDoctorDownloadService.selectDoctorList(zfDoctorDownload,pageNum,pageSize);
- List<ZfDoctor> bs = new ArrayList<>();
- for (ZfDoctorDownload a: as) {
- if (zfDoctorService.getById(a.getDownloadContent()) != null) {
- ZfDoctor ds = zfDoctorService.getById(a.getDownloadContent());
- ds.setShareId(a.getShareId());
- bs.add(ds);
- }
- }
- return bs;
+ return zfDoctorDownloadService.selectDoctorList(zfDoctorDownload,pageNo ,pageSize);
}
}
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableSupport.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableSupport.java
index a120c30..38a070b 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableSupport.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableSupport.java
@@ -21,6 +21,11 @@
public static final String PAGE_SIZE = "pageSize";
/**
+ * 褰撳墠椤垫暟
+ */
+ public static final String PAGE_NO = "pageNo";
+
+ /**
* 鎺掑簭鍒�
*/
public static final String ORDER_BY_COLUMN = "orderByColumn";
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/MapUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/MapUtils.java
index 9003b2d..1dee4e7 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/MapUtils.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/MapUtils.java
@@ -3,6 +3,7 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.HashMap;
+import java.util.List;
/**
* @Version 1.0
@@ -28,4 +29,14 @@
data.put("pageSize",pageResult.getSize());
return data;
}
+
+ public static HashMap<String,Object> getResult(Page pageResult, List record){
+ HashMap<String, Object> data = new HashMap<>();
+ data.put("data",record);
+ data.put("total",record.size());
+ data.put("pageNo",pageResult.getCurrent());
+ data.put("totalPage",pageResult.getTotal());
+ data.put("pageSize",pageResult.getSize());
+ return data;
+ }
}
diff --git a/zhang-content/src/main/java/com/ruoyi/service/ZfDoctorDownloadService.java b/zhang-content/src/main/java/com/ruoyi/service/ZfDoctorDownloadService.java
index c60dd4d..c059924 100644
--- a/zhang-content/src/main/java/com/ruoyi/service/ZfDoctorDownloadService.java
+++ b/zhang-content/src/main/java/com/ruoyi/service/ZfDoctorDownloadService.java
@@ -12,7 +12,7 @@
AjaxResult deleteData(Long[] ids);
- List<ZfDoctorDownload> selectDoctorList(ZfDoctorDownload zfDoctorDownload , Integer pageNum, Integer pageSize);
+ AjaxResult selectDoctorList(ZfDoctorDownload zfDoctorDownload,Integer pageNo ,Integer pageSize);
}
diff --git a/zhang-content/src/main/java/com/ruoyi/service/ZfDoctorService.java b/zhang-content/src/main/java/com/ruoyi/service/ZfDoctorService.java
index 354e469..7e0c582 100644
--- a/zhang-content/src/main/java/com/ruoyi/service/ZfDoctorService.java
+++ b/zhang-content/src/main/java/com/ruoyi/service/ZfDoctorService.java
@@ -38,5 +38,5 @@
AjaxResult listType();
- AjaxResult selectListById(List<Long> ids, Integer pageNum, Integer pageSize);
+// AjaxResult selectListById(List<Long> ids, Integer pageNum, Integer pageSize);
}
diff --git a/zhang-content/src/main/java/com/ruoyi/service/ZfDoctorShareService.java b/zhang-content/src/main/java/com/ruoyi/service/ZfDoctorShareService.java
index b10445d..99d9f36 100644
--- a/zhang-content/src/main/java/com/ruoyi/service/ZfDoctorShareService.java
+++ b/zhang-content/src/main/java/com/ruoyi/service/ZfDoctorShareService.java
@@ -15,13 +15,13 @@
AjaxResult saveZa(ShareMore zfDoctor);
- List<Long> listByFidAid(ShareMore zfDoctorInteger);
+ AjaxResult listByFidAid(ShareMore zfDoctorInteger,Integer pageNo ,Integer pageSize);
AjaxResult deleteZa(ShareMore zfDoctor);
AjaxResult listByUserId();
- AjaxResult listUserId();
+ AjaxResult listUserId(ShareMore zfDoctorInteger,Integer pageNo ,Integer pageSize);
Long getShareId(ZfDoctorDownload zfDoctorDownload);
diff --git a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfDoctorDownloadServiceImpl.java b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfDoctorDownloadServiceImpl.java
index b542da7..8517635 100644
--- a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfDoctorDownloadServiceImpl.java
+++ b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfDoctorDownloadServiceImpl.java
@@ -1,11 +1,14 @@
package com.ruoyi.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.EsModel;
+import com.ruoyi.common.utils.MapUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.domain.ZInfoUser;
+import com.ruoyi.domain.ZfDoctor;
import com.ruoyi.domain.ZfDoctorDownload;
import com.ruoyi.mapper.ZfDoctorDownloadMapper;
import com.ruoyi.service.*;
@@ -16,10 +19,8 @@
import javax.annotation.Resource;
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.UUID;
+import java.util.*;
+import java.util.stream.Collectors;
@Service
public class ZfDoctorDownloadServiceImpl extends ServiceImpl<ZfDoctorDownloadMapper, ZfDoctorDownload> implements ZfDoctorDownloadService {
@@ -29,6 +30,10 @@
@Resource
ZfDoctorShareService zfDoctorShareService;
+
+ @Resource
+ ZfDoctorService zfDoctorService;
+
@Resource
ZInfoUserService zInfoUserService;
@@ -51,11 +56,25 @@
return lqw;
}
@Override
- public List<ZfDoctorDownload> selectDoctorList(ZfDoctorDownload zfDoctorDownload , Integer pageNum, Integer pageSize) {
+ public AjaxResult selectDoctorList(ZfDoctorDownload zfDoctorDownload,Integer pageNo ,Integer pageSize ) {
ZInfoUser myself = zInfoUserService.getMyself();
LambdaQueryWrapper<ZfDoctorDownload> lqw = buildCondition(zfDoctorDownload,myself.getUserId());
List<ZfDoctorDownload> beanRecords = list(lqw);
- return new ArrayList<>(beanRecords);
+ List<ZfDoctor> bs = new ArrayList<>();
+ for (ZfDoctorDownload a: beanRecords) {
+ if (zfDoctorService.getById(a.getDownloadContent()) != null) {
+ ZfDoctor ds = zfDoctorService.getById(a.getDownloadContent());
+ ds.setShareId(a.getShareId());
+ bs.add(ds);
+ }
+ }
+ List<ZfDoctor> record = bs.stream().skip((pageNo-1)*pageSize).limit(pageSize).collect(Collectors.toList());
+
+ int totalPage = (bs.size() -1) / pageSize +1;
+
+ Page<ZfDoctor> zfDoctorPage = new Page<>(pageNo, pageSize,totalPage);
+ HashMap<String, Object> data = MapUtils.getResult(zfDoctorPage, record);
+ return AjaxResult.success(data);
}
diff --git a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfDoctorServiceImpl.java b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfDoctorServiceImpl.java
index eeb1f45..3367b37 100644
--- a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfDoctorServiceImpl.java
+++ b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfDoctorServiceImpl.java
@@ -439,31 +439,30 @@
return lqw;
}
- public LambdaQueryWrapper<ZfDoctor> buildCondition2(List<Long> ids) {
- LambdaQueryWrapper<ZfDoctor> lqw = new LambdaQueryWrapper<>();
-
- lqw.eq(ZfDoctor::getId, ids);
-
- return lqw;
- }
- @Override
- public AjaxResult selectListById(List<Long> ids, Integer pageNum, Integer pageSize) {
- List<ZfDoctor> lqw2 = new ArrayList<>();
-
- LambdaQueryWrapper<ZfDoctor> lqw = buildCondition2(ids);
- List<ZfDoctor> bb = list(lqw);
- System.out.println("15052222254"+bb);
-
- Page<ZfDoctor> zfDoctorPage = new Page<>(pageNum, pageSize);
- Page<ZfDoctor> pageResult = page(zfDoctorPage, lqw);
- List<ZfDoctor> beanRecords = pageResult.getRecords();//寰楀埌鏌ヨ鍑烘潵鐨勬暟鎹�
- System.out.println(beanRecords);
-
- HashMap<String, Object> data = MapUtils.getResult(pageResult, beanRecords);
-
-
- return AjaxResult.success(data);
+// public LambdaQueryWrapper<ZfDoctor> buildCondition2(List<Long> ids) {
+// LambdaQueryWrapper<ZfDoctor> lqw = new LambdaQueryWrapper<>();
+// lqw.eq(ZfDoctor::getId, ids);
+//
+// return lqw;
// }
+// @Override
+// public AjaxResult selectListById(List<Long> ids, Integer pageNum, Integer pageSize) {
+// List<ZfDoctor> lqw2 = new ArrayList<>();
+//
+// LambdaQueryWrapper<ZfDoctor> lqw = buildCondition2(ids);
+// List<ZfDoctor> bb = list(lqw);
+// System.out.println("15052222254"+bb);
+//
+// Page<ZfDoctor> zfDoctorPage = new Page<>(pageNum, pageSize);
+// Page<ZfDoctor> pageResult = page(zfDoctorPage, lqw);
+// List<ZfDoctor> beanRecords = pageResult.getRecords();//寰楀埌鏌ヨ鍑烘潵鐨勬暟鎹�
+// System.out.println(beanRecords);
+//
+// HashMap<String, Object> data = MapUtils.getResult(pageResult, beanRecords);
+//
+//
+// return AjaxResult.success(data);
+//// }
// private List<Long> buildCondition1(){
// List<ZfDoctorShare> authority1 = zfDoctorShareService.getAuthority();
@@ -481,4 +480,4 @@
// }
-}}
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfDoctorShareServiceImpl.java b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfDoctorShareServiceImpl.java
index 08c6d9a..904100a 100644
--- a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfDoctorShareServiceImpl.java
+++ b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfDoctorShareServiceImpl.java
@@ -21,6 +21,9 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
+import java.util.stream.Collectors;
+
+import static com.alibaba.druid.sql.PagerUtils.limit;
@Slf4j
@Service
@@ -92,10 +95,10 @@
* 鏍规嵁UserId鍜屽垎浜汉shareId鏌ョ湅宸茬粡鎺堟潈缁欓偅浜涗汉閭d簺鏁版嵁
*/
@Override
- public List<Long> listByFidAid(ShareMore zfDoctor) {
+ public AjaxResult listByFidAid(ShareMore zfDoctor,Integer pageNo ,Integer pageSize) {
//鎵惧埌瀵瑰簲鐨勮祴浜堟暟鎹殑鐢ㄦ埛浠ュ強鏁版嵁鍐呭
Long [] shareIds = zfDoctor.getShareIds();
- List<Long> beanRecord3 = new ArrayList<>();
+ List<ZfDoctor> beanRecord3 = new ArrayList<>();
for (Long shareId : shareIds) {
{
LambdaQueryWrapper<ZfDoctorShare> lqw = new LambdaQueryWrapper<>();
@@ -103,12 +106,18 @@
.eq(ZfDoctorShare::getUserId, getUserId());
List<ZfDoctorShare> beanRecords = list(lqw);
for (ZfDoctorShare beanRecord : beanRecords ) {
- beanRecord3.add(beanRecord.getShareContent());
+ beanRecord3.add(zfDoctorService.getById(beanRecord.getShareContent()));
}
}
}
+ List<ZfDoctor> record = beanRecord3.stream().skip((pageNo-1)*pageSize).limit(pageSize).collect(Collectors.toList());
- return beanRecord3;
+ int totalPage = (beanRecord3.size() -1) / pageSize +1;
+
+ Page<ZfDoctor> zfDoctorPage = new Page<>(pageNo, pageSize,totalPage);
+ HashMap<String, Object> data = MapUtils.getResult(zfDoctorPage, record);
+
+ return AjaxResult.success(data);
}
@Override
@@ -153,7 +162,7 @@
* 鐢ㄦ埛鑷繁鏌ョ湅鍒汉鍒嗕韩鐨勬暟鎹�==鐢ㄦ埛鑷繁鏌ョ湅鍒汉鍒嗕韩鐨勬暟鎹拰鍒嗕韩浜�
*/
@Override
- public AjaxResult listUserId() {
+ public AjaxResult listUserId(ShareMore zfDoctorInteger,Integer pageNo ,Integer pageSize) {
//鎵惧埌瀵瑰簲鐨勮祴浜堟暟鎹殑鐢ㄦ埛浠ュ強鏁版嵁鍐呭
List<ZfDoctor> bs = new ArrayList<>();
LambdaQueryWrapper<ZfDoctorShare> lqw = new LambdaQueryWrapper<>();
@@ -165,7 +174,13 @@
bs.add(bs2);
}
log.info("浠庢暟鎹簱涓煡鍒扮殑涓�:{}", bs);
- return AjaxResult.success(bs);
+ List<ZfDoctor> record = bs.stream().skip((pageNo-1)*pageSize).limit(pageSize).collect(Collectors.toList());
+
+ int totalPage = (bs.size() -1) / pageSize +1;
+
+ Page<ZfDoctor> zfDoctorPage = new Page<>(pageNo, pageSize,totalPage);
+ HashMap<String, Object> data = MapUtils.getResult(zfDoctorPage, record);
+ return AjaxResult.success(data);
}
public Long getUserId(){
--
Gitblit v1.9.1