| | |
| | | package com.panzhihua.sangeshenbian.service.impl; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.panzhihua.common.exceptions.ServiceException; |
| | | import com.panzhihua.common.model.vos.LoginUserInfoVO; |
| | | import com.panzhihua.common.redis.RedisUtils; |
| | | import com.panzhihua.sangeshenbian.model.entity.PartyMember; |
| | |
| | | .eq(PartyMember::getDelFlag, 0)); |
| | | |
| | | // 获取管理员信息 |
| | | SystemUser systemUser = systemUserService.getSystemUserAdminByPhone(loginUserInfo.getPhone()).orElse(null); |
| | | SystemUser systemUser = systemUserService.lambdaQuery() |
| | | .eq(SystemUser::getPhone, loginUserInfo.getPhone()) |
| | | .eq(SystemUser::getIsAdmin, 1).last("LIMIT 1") |
| | | .one(); |
| | | // 获取身份 |
| | | Integer identity = (Integer) redisUtils.get("identity:" + loginUserInfo.getPhone()); |
| | | // 权限列表 |
| | | List<PermissionsVO> permissions = new ArrayList<>(); |
| | | |
| | | IdentityInformation identityInformationVO = new IdentityInformation(); |
| | | identityInformationVO.setPartyMember(partyMember); |
| | | identityInformationVO.setSystemUser(systemUser); |
| | |
| | | Integer isConfirm = (Integer) redisUtils.get("confirmContent:" + loginUserInfo.getPhone()); |
| | | identityInformationVO.setIsConfirmContent(isConfirm != null && isConfirm == 1); |
| | | |
| | | if (partyMember != null) { |
| | | identityInformationVO.setIsFrozen(partyMember.getFreezeStatus() == 1); |
| | | } |
| | | if (systemUser != null) { |
| | | identityInformationVO.setIsFrozen(systemUser.getStatus() == 2); |
| | | } |
| | | |
| | | // 获取当前身份 |
| | | if (identity == null && systemUser != null) { |
| | | identityInformationVO.setIdentity(2); |
| | | redisUtils.set("identity:" + loginUserInfo.getPhone(), 2); |
| | |
| | | identityInformationVO.setIdentity(identity); |
| | | } |
| | | |
| | | |
| | | // 获取是否冻结 |
| | | if (identityInformationVO.getIdentity() != null) { |
| | | if (identityInformationVO.getIdentity() == 1) { |
| | | identityInformationVO.setIsFrozen(partyMember != null && partyMember.getFreezeStatus() == 1); |
| | |
| | | identityInformationVO.setIsFrozen(false); |
| | | } |
| | | |
| | | |
| | | // 是否认证党员 |
| | | identityInformationVO.setIsPartymember(partyMember != null && partyMember.getAuditStatus().equals(1)); |
| | | // 是否确认党员信息 |
| | | identityInformationVO.setIsConfirm(partyMember != null && partyMember.getIsConfirm() == 1); |
| | | // 党员审核状态 |
| | | identityInformationVO.setAuditStatus(partyMember == null ? null : partyMember.getAuditStatus()); |
| | | |
| | | // 封装管理员信息 |
| | | if (systemUser != null) { |
| | | Integer accountLevel = systemUser.getAccountLevel(); |
| | | String districts = systemUser.getDistricts(); |
| | |
| | | permissions.add(adminPermissions); |
| | | } |
| | | |
| | | // 封装党员信息 |
| | | if (partyMember != null) { |
| | | PermissionsVO partyMemberPermissions = new PermissionsVO(); |
| | | partyMemberPermissions.setIdentity(1); |
| | |
| | | return identityInformationVO; |
| | | } |
| | | |
| | | // @Override |
| | | // public IdentityInformation getCurrentIdentityInformation(LoginUserInfoVO loginUserInfo) { |
| | | // if (identity == null && systemUser != null) { |
| | | // identityInformationVO.setIdentity(2); |
| | | // redisUtils.set("identity:" + loginUserInfo.getPhone(), 2); |
| | | // }else if (identity == null && partyMember != null){ |
| | | // identityInformationVO.setIdentity(1); |
| | | // redisUtils.set("identity:" + loginUserInfo.getPhone(), 1); |
| | | // } |
| | | // else { |
| | | // identityInformationVO.setIdentity(identity); |
| | | // } |
| | | // return null; |
| | | // } |
| | | |
| | | |
| | | @Override |
| | | public IdentityInformation getCurrentIdentityInformation(LoginUserInfoVO loginUserInfo) { |
| | | IdentityInformation identityInformation = getIdentityInformation(loginUserInfo); |
| | | Boolean isFrozen = identityInformation.getIsFrozen(); |
| | | if (isFrozen) { |
| | | throw new ServiceException("您的账号已被冻结,请联系管理员"); |
| | | } |
| | | List<PermissionsVO> permissions = identityInformation.getPermissions(); |
| | | if (CollectionUtil.isEmpty(permissions)){ |
| | | throw new ServiceException("请先完成认证"); |
| | | } |
| | | |
| | | SystemUser systemUser = identityInformation.getSystemUser(); |
| | | if (systemUser == null && identityInformation.getIdentity() == 2) { |
| | | throw new ServiceException("管理员信息不存在"); |
| | | } |
| | | |
| | | PartyMember partyMember = identityInformation.getPartyMember(); |
| | | if (partyMember == null && identityInformation.getIdentity() == 1) { |
| | | throw new ServiceException("党员信息不存在"); |
| | | } |
| | | return identityInformation; |
| | | } |
| | | } |