| | |
| | | |
| | | // 获取当前身份 |
| | | if (userIdentityDTO == null){ |
| | | if (systemUser != null){ |
| | | handleSystemUserLevelId(phone, systemUser, 2, identityInformationVO); |
| | | }else if (partyMember != null && partyMember.getAuditStatus() == 1){ |
| | | identityInformationVO.setIdentity(1); |
| | | UserIdentityDTO build = UserIdentityDTO.builder().identity(1).build(); |
| | | redisUtils.set("identity:" + phone, build); |
| | | }else { |
| | | identityInformationVO.setIdentity(null); |
| | | } |
| | | handleSystemUserLevelId(phone, systemUser, 2, identityInformationVO, partyMember); |
| | | }else { |
| | | Integer identity = userIdentityDTO.getIdentity(); |
| | | identityInformationVO.setIdentity(identity); |
| | | if (identity == 1 && (partyMember == null || partyMember.getAuditStatus() != 1)){ |
| | | identityInformationVO.setIdentity(null); |
| | | redisUtils.remove("identity:" + phone); |
| | | }else if (identity == 2 && systemUser == null){ |
| | | identityInformationVO.setIdentity(null); |
| | | redisUtils.remove("identity:" + phone); |
| | | }else { |
| | | }else if (identity == 2){ |
| | | Integer levelId = userIdentityDTO.getLevelId(); |
| | | //验证账号所属层级 |
| | | SystemUserLevel userLevel = systemUserLevelService.getById(levelId); |
| | | if (Objects.isNull(userLevel)) { |
| | | handleSystemUserLevelId(phone, systemUser, identity, identityInformationVO); |
| | | handleSystemUserLevelId(phone, systemUser, identity, identityInformationVO,partyMember); |
| | | } else { |
| | | identityInformationVO.setLevelId(levelId); |
| | | identityInformationVO.setSuperviseFlag(userLevel.getSuperviseFlag()); |
| | |
| | | * @param identity |
| | | * @param identityInformationVO |
| | | */ |
| | | private void handleSystemUserLevelId(String phone, SystemUser systemUser, Integer identity, IdentityInformation identityInformationVO) { |
| | | SystemUserLevel userLevel; |
| | | //当前所属层级不存在,默认为第一个添加的层级 |
| | | Optional<SystemUserLevel> levelOptional = systemUserLevelService.getByLevelByUserId(systemUser.getId()); |
| | | if (levelOptional.isPresent()) { |
| | | userLevel = levelOptional.get(); |
| | | UserIdentityDTO build = UserIdentityDTO.builder().identity(identity).levelId(userLevel.getId()).build(); |
| | | private void handleSystemUserLevelId(String phone, SystemUser systemUser, Integer identity, |
| | | IdentityInformation identityInformationVO, PartyMember partyMember) { |
| | | // 情况1:系统用户存在 |
| | | if (Objects.nonNull(systemUser)) { |
| | | Optional<SystemUserLevel> levelOptional = systemUserLevelService.getByLevelByUserId(systemUser.getId()); |
| | | if (levelOptional.isPresent()) { |
| | | // 系统用户有关联的用户级别 |
| | | SystemUserLevel userLevel = levelOptional.get(); |
| | | |
| | | // 设置用户身份信息为系统用户身份 |
| | | identityInformationVO.setIdentity(identity); |
| | | identityInformationVO.setLevelId(userLevel.getId()); |
| | | identityInformationVO.setSuperviseFlag(userLevel.getSuperviseFlag()); |
| | | identityInformationVO.setSystemUserLevel(userLevel); |
| | | |
| | | // 存储到Redis |
| | | UserIdentityDTO build = UserIdentityDTO.builder() |
| | | .identity(identity) |
| | | .levelId(userLevel.getId()) |
| | | .build(); |
| | | redisUtils.set("identity:" + phone, build); |
| | | } else if (partyMember != null && partyMember.getAuditStatus() == 1) { |
| | | // 系统用户无关联级别,但是有党员身份且审核通过 |
| | | identityInformationVO.setIdentity(1); |
| | | |
| | | UserIdentityDTO build = UserIdentityDTO.builder() |
| | | .identity(1) |
| | | .build(); |
| | | redisUtils.set("identity:" + phone, build); |
| | | } else { |
| | | // 系统用户无关联级别,也没有党员身份,清除身份信息 |
| | | redisUtils.remove("identity:" + phone); |
| | | } |
| | | } else if (partyMember != null && partyMember.getAuditStatus() == 1) { |
| | | // 情况2:不是系统用户,但是党员身份且审核通过 |
| | | identityInformationVO.setIdentity(1); |
| | | |
| | | UserIdentityDTO build = UserIdentityDTO.builder() |
| | | .identity(1) |
| | | .build(); |
| | | redisUtils.set("identity:" + phone, build); |
| | | identityInformationVO.setIdentity(identity); |
| | | identityInformationVO.setLevelId(userLevel.getId()); |
| | | identityInformationVO.setSuperviseFlag(userLevel.getSuperviseFlag()); |
| | | identityInformationVO.setSystemUserLevel(userLevel); |
| | | } else { |
| | | //当前账号没有管理员账号所属层级,清空账号当前层级信息 |
| | | // 情况3:既不是系统用户也不是审核通过的党员,清除身份信息 |
| | | redisUtils.remove("identity:" + phone); |
| | | } |
| | | } |
| | |
| | | throw new ServiceException("您的账号已被冻结,请联系管理员"); |
| | | } |
| | | List<PermissionsVO> permissions = identityInformation.getPermissions(); |
| | | if (CollectionUtil.isEmpty(permissions)){ |
| | | if (CollectionUtil.isEmpty(permissions) || Objects.isNull(identityInformation.getIdentity())){ |
| | | throw new ServiceException("请先完成认证"); |
| | | } |
| | | |
| | | SystemUser systemUser = identityInformation.getSystemUser(); |
| | | if (systemUser == null && identityInformation.getIdentity() == 2) { |
| | | if (identityInformation.getIdentity() == 2 && Objects.isNull(systemUser)) { |
| | | throw new ServiceException("管理员信息不存在"); |
| | | } |
| | | SystemUserLevel systemUserLevel = identityInformation.getSystemUserLevel(); |
| | | if (systemUserLevel == null && identityInformation.getIdentity() == 2) { |
| | | if (identityInformation.getIdentity() == 2&&Objects.isNull(systemUserLevel)) { |
| | | throw new ServiceException("管理员所属层级不存在"); |
| | | } |
| | | PartyMember partyMember = identityInformation.getPartyMember(); |
| | | if (partyMember == null && identityInformation.getIdentity() == 1) { |
| | | if (identityInformation.getIdentity() == 1 && Objects.isNull(partyMember)) { |
| | | throw new ServiceException("党员信息不存在"); |
| | | } |
| | | return identityInformation; |