From 2c8c1336223ba4777d580220f1e11480fda7c948 Mon Sep 17 00:00:00 2001 From: mitao <2763622819@qq.com> Date: 星期二, 18 三月 2025 16:26:34 +0800 Subject: [PATCH] Merge remote-tracking branch '喜望/dev-2.0' into dev-2.0 --- springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/impl/IdentityInformationServiceImpl.java | 63 ++++++++++++++++++++----------- 1 files changed, 41 insertions(+), 22 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/impl/IdentityInformationServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/impl/IdentityInformationServiceImpl.java index 60e8b34..7d0c257 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/impl/IdentityInformationServiceImpl.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/impl/IdentityInformationServiceImpl.java @@ -1,6 +1,8 @@ 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; @@ -31,10 +33,15 @@ .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); @@ -43,13 +50,8 @@ 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); @@ -60,6 +62,8 @@ identityInformationVO.setIdentity(identity); } + + // 获取是否冻结 if (identityInformationVO.getIdentity() != null) { if (identityInformationVO.getIdentity() == 1) { identityInformationVO.setIsFrozen(partyMember != null && partyMember.getFreezeStatus() == 1); @@ -70,11 +74,14 @@ 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(); @@ -97,6 +104,7 @@ permissions.add(adminPermissions); } + // 封装党员信息 if (partyMember != null) { PermissionsVO partyMemberPermissions = new PermissionsVO(); partyMemberPermissions.setIdentity(1); @@ -108,18 +116,29 @@ 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; + } } -- Gitblit v1.7.1