| | |
| | | } |
| | | return array; |
| | | } |
| | | |
| | | @Override |
| | | public MemUser[] getParentV4V5ByRelationPath2(String relationPath, Integer memberGradeId) { |
| | | MemUser[] array = new MemUser[]{null, null}; |
| | | if (relationPath != null) { |
| | | String[] pathArray = relationPath.split("/"); |
| | | String parentId = pathArray[pathArray.length - 2]; |
| | | MemUser parentUser = memUserService.selectById(parentId); |
| | | findParents(parentUser, pathArray, array); |
| | | } |
| | | return array; |
| | | } |
| | | private void findParents(MemUser user, String[] pathArray, MemUser[] array) { |
| | | if (user != null) { |
| | | Integer memberGradeId = user.getMemberGradeId(); |
| | | if (memberGradeId == EnumMemberGrade.G_3.index) { |
| | | String grandParentId = pathArray[pathArray.length - 3]; |
| | | MemUser grandParent = memUserService.selectById(grandParentId); |
| | | if (grandParent != null && grandParent.getMemberGradeId() == EnumMemberGrade.G_4.index) { |
| | | array[0] = grandParent; |
| | | String greatGrandParentId = pathArray[pathArray.length - 3]; |
| | | MemUser greatGrandParent = memUserService.selectById(greatGrandParentId); |
| | | if (greatGrandParent != null && greatGrandParent.getMemberGradeId() == EnumMemberGrade.G_5.index) { |
| | | array[1] = greatGrandParent; |
| | | } |
| | | } |
| | | } else if (memberGradeId == EnumMemberGrade.G_4.index) { |
| | | array[0] = user; |
| | | String parentId = pathArray[pathArray.length - 3]; |
| | | MemUser parent = memUserService.selectById(parentId); |
| | | if (parent != null && parent.getMemberGradeId() == EnumMemberGrade.G_5.index) { |
| | | array[1] = parent; |
| | | } |
| | | } else if (memberGradeId == EnumMemberGrade.G_5.index) { |
| | | array[0] = user; |
| | | array[1] = user; |
| | | } |
| | | } |
| | | } |
| | | } |