| | |
| | | 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; |
| | |
| | | |
| | | @Autowired |
| | | private ZfRelationService zfRelationService; |
| | | |
| | | @Autowired |
| | | private ZInfoUserService zInfoUserService; |
| | | |
| | | @Override |
| | | public AjaxResult selectInfoList(ZInfoUser zInfoUser, Integer pageNum, Integer pageSize) { |
| | |
| | | } |
| | | |
| | | @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("对方的id不存在"); |
| | | } |
| | | List<ZfRelation> list = zfRelationService.list(lqw); |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public AjaxResult addRelation(ZfRelation zfRelation) { |
| | | checkRelation(zfRelation); |
| | | |
| | | //获取自己的id并传入 |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | Long userId = user.getUserId(); |
| | | zfRelation.setMyId(userId); |
| | | |
| | | zfRelationService.save(zfRelation); |
| | | return AjaxResult.success(); |
| | | } |
| | |
| | | @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){ |
| | | zfRelationService.removeByIds(Arrays.asList(ids)); |
| | | return AjaxResult.success(); |
| | | }else { |
| | | return AjaxResult.error(); |
| | | } |
| | | } |
| | | |
| | | /** |