refactor(系统微服务代码逻辑优化): 专区会员操作逻辑应当在组织类型为特色专区时才执行,防止系统耦合无法拔插

This commit is contained in:
OTTO 2024-06-19 14:31:35 +08:00
parent e66e088cda
commit 92f4570d87
1 changed files with 13 additions and 9 deletions

View File

@ -103,17 +103,21 @@ public class SysUserDeptRoleServiceImpl implements ISysUserDeptRoleService {
@Override
@Transactional(rollbackFor = Exception.class)
public int deleteSysUserDeptRoleByDeptIdAndUserIds(Long deptId, Long[] userIds) {
List<Long> memberUserIdList = FeignUtils.getReturnData(
remoteZoneService.checkUsersIsMemberInDept(deptId, userIds, SecurityConstants.INNER)
);
// 检查该身份是否为会员用户若是则将身份调整为会员并且不删除该身份
if (memberUserIdList != null && !memberUserIdList.isEmpty()) {
userIds = Arrays.stream(userIds).filter(x -> !memberUserIdList.contains(x)).toArray(Long[]::new);
SysRole memberRole = sysRoleService.selectRoleByKey(SystemRole.ZONE_MEMBER.getRoleKey());
for (Long userId : memberUserIdList) {
updateSysUserDeptRole(userId, deptId, memberRole.getRoleId());
SysDept sysDept = sysDeptMapper.selectDeptById(deptId);
if (CacheConstants.DEPT_TYPE_TSZQ == sysDept.getDeptType()) {
List<Long> memberUserIdList = FeignUtils.getReturnData(
remoteZoneService.checkUsersIsMemberInDept(deptId, userIds, SecurityConstants.INNER)
);
// 检查该身份是否为会员用户若是则将身份调整为会员并且不删除该身份
if (memberUserIdList != null && !memberUserIdList.isEmpty()) {
userIds = Arrays.stream(userIds).filter(x -> !memberUserIdList.contains(x)).toArray(Long[]::new);
SysRole memberRole = sysRoleService.selectRoleByKey(SystemRole.ZONE_MEMBER.getRoleKey());
for (Long userId : memberUserIdList) {
updateSysUserDeptRole(userId, deptId, memberRole.getRoleId());
}
}
}
if (userIds == null || userIds.length == 0) {
return 1;
}