From 4e94b05b765acb54053123580c570468d41371e1 Mon Sep 17 00:00:00 2001 From: whywhyo <1511349576@qq.com> Date: 星期五, 14 七月 2023 11:18:19 +0800 Subject: [PATCH] 123456 --- zhang-content/src/main/java/com/ruoyi/service/impl/ZInfoUserServiceImpl.java | 89 ++++++++++++++++---------------------------- 1 files changed, 32 insertions(+), 57 deletions(-) diff --git a/zhang-content/src/main/java/com/ruoyi/service/impl/ZInfoUserServiceImpl.java b/zhang-content/src/main/java/com/ruoyi/service/impl/ZInfoUserServiceImpl.java index 5db6910..7332469 100644 --- a/zhang-content/src/main/java/com/ruoyi/service/impl/ZInfoUserServiceImpl.java +++ b/zhang-content/src/main/java/com/ruoyi/service/impl/ZInfoUserServiceImpl.java @@ -15,10 +15,7 @@ import com.ruoyi.domain.ZInfoUser; import com.ruoyi.domain.ZfEvent; import com.ruoyi.domain.ZfRelation; -import com.ruoyi.domain.dto.EmpowerDto; -import com.ruoyi.domain.dto.Genealogy; -import com.ruoyi.domain.dto.GenealogyExportDto; -import com.ruoyi.domain.dto.UserRelationDto; +import com.ruoyi.domain.dto.*; import com.ruoyi.mapper.ZInfoUserMapper; import com.ruoyi.service.ZInfoUserService; import com.ruoyi.service.ZfRelationService; @@ -45,6 +42,9 @@ @Autowired private ZfRelationService zfRelationService; + + @Autowired + private ZInfoUserService zInfoUserService; @Override public AjaxResult selectInfoList(ZInfoUser zInfoUser, Integer pageNum, Integer pageSize) { @@ -93,55 +93,24 @@ } @Override - public AjaxResult searchMyRelation(Long userId) { + public AjaxResult searchMyRelation() { + + SysUser user = SecurityUtils.getLoginUser().getUser(); + Long userId = user.getUserId(); LambdaQueryWrapper<ZfRelation> lqw = new LambdaQueryWrapper<>(); lqw.eq(ZfRelation::getMyId,userId); - List<ZfRelation> relationList = zfRelationService.list(lqw); - ArrayList<UserRelationDto> otherUserList = new ArrayList<>(); - - relationList.stream().map( - (relation)->{ - Long otherId = relation.getOtherId(); - ZInfoUser otherUser = getById(otherId); - UserRelationDto userRelationDto = new UserRelationDto(); - BeanUtils.copyProperties(otherUser,userRelationDto); - userRelationDto.setRelation(relation.getRelation()); - userRelationDto.setId(relation.getId()); - otherUserList.add(userRelationDto); - return relation; - } - ).collect(Collectors.toList()); - - return AjaxResult.success(otherUserList); - } - - /** - * 妫�鏌ヤ紶鍏ュ鏂圭殑id鏄惁瀛樺湪 - * @param zfRelation - */ - private void checkRelation(ZfRelation zfRelation){ - - LambdaQueryWrapper<ZInfoUser> lqw = new LambdaQueryWrapper<>(); - lqw.eq(ZInfoUser::getUserId, zfRelation.getOtherId()); - - ZInfoUser zInfoUser2 = getOne(lqw); - if (zInfoUser2==null){ - throw new RuntimeException("瀵规柟鐨刬d涓嶅瓨鍦�"); - } + List<ZfRelation> list = zfRelationService.list(lqw); + return AjaxResult.success(list); } @Override @Transactional public AjaxResult addRelation(ZfRelation zfRelation) { - checkRelation(zfRelation); - - //鑾峰彇鑷繁鐨刬d骞朵紶鍏� SysUser user = SecurityUtils.getLoginUser().getUser(); Long userId = user.getUserId(); zfRelation.setMyId(userId); - zfRelationService.save(zfRelation); return AjaxResult.success(); } @@ -149,19 +118,14 @@ @Override @Transactional public AjaxResult updateRelation(ZfRelation zfRelation) { - checkRelation(zfRelation); zfRelationService.updateById(zfRelation); return AjaxResult.success(); } @Override public AjaxResult deleteRelation(Long[] ids) { - boolean flag = zfRelationService.removeByIds(Arrays.asList(ids)); - if (flag){ - return AjaxResult.success(); - }else { - return AjaxResult.error(); - } + zfRelationService.removeByIds(Arrays.asList(ids)); + return AjaxResult.success(); } /** @@ -300,17 +264,23 @@ List<ZInfoUser> allPeopleList = list(); List<ZInfoUser> result = null; try { - result = allPeopleList.stream().filter(people -> people.getUserId()!=1&&(people.getFatherId() == 0||people.getMomId()==0)) - .map(people -> { - if(depth>1){ - people.setIdentity(1); - people.setChildList(fillChildren(people, allPeopleList, depth-1)); - } - return people; - }).collect(Collectors.toList()); + result = allPeopleList.stream().filter(people -> people.getUserId()!=1&&(people.getFatherId() == 0||people.getMomId()==0)) + .map(people -> { + if(depth>1){ + people.setIdentity(1); + //鏍规嵁閰嶅伓id鏌ヨ閰嶅伓鐨勬暟鎹紝灏佽濂戒竴璧疯繑鍥� + Long spouseId = people.getSpouseId(); + ZInfoUser spouse = zInfoUserService.getById(spouseId); + people.setSpouse(spouse); + people.setChildList(fillChildren(people, allPeopleList, depth-1)); + } + return people; + }).collect(Collectors.toList()); } catch (NullPointerException e) { throw new RuntimeException("鎮ㄥ湪鍔犲叆鎴愬憳鐨勬椂鍊欐病鏈夋寚瀹氳鎴愬憳鐨勭埗浜叉垨鑰呮瘝浜�"); } + + return AjaxResult.success(result); } @@ -511,13 +481,18 @@ // layer = layer + 1; System.out.println(depth); List<ZInfoUser> collect = allPeopleList.stream().filter( - one -> one.getFatherId() == people.getUserId() || one.getMomId() == people.getUserId() + one -> (one.getFatherId() == people.getUserId() || one.getMomId() == people.getUserId()) && (people.getIsMyFamily() == 1) ).map( one -> { if(depth==1) return one; else { one.setIdentity(people.getIdentity()+1); + + //鏍规嵁閰嶅伓id鏌ヨ閰嶅伓鐨勬暟鎹紝灏佽濂戒竴璧疯繑鍥� + Long spouseId = one.getSpouseId(); + ZInfoUser spouse = zInfoUserService.getById(spouseId); + one.setSpouse(spouse); List<ZInfoUser> zinfo = fillChildren(one, allPeopleList, depth - 1); one.setChildList(zinfo); System.out.println(one); -- Gitblit v1.9.1