| | |
| | | package com.qianwen.smartman.modules.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import java.lang.invoke.SerializedLambda; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | import com.qianwen.smartman.common.cache.RegionCache; |
| | | import com.qianwen.smartman.common.cache.SysCache; |
| | | import com.qianwen.smartman.common.utils.Lambda; |
| | | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.qianwen.core.log.exception.ServiceException; |
| | | import com.qianwen.core.secure.utils.AuthUtil; |
| | | import com.qianwen.core.tool.constant.BladeConstant; |
| | | import com.qianwen.core.tool.node.ForestNodeMerger; |
| | | import com.qianwen.core.tool.utils.Func; |
| | | import com.qianwen.smartman.common.cache.SysCache; |
| | | import com.qianwen.smartman.common.utils.Lambda; |
| | | import com.qianwen.smartman.modules.cps.entity.Employee; |
| | | import com.qianwen.smartman.modules.cps.service.IEmployeeService; |
| | | import com.qianwen.smartman.modules.system.entity.Dept; |
| | | import com.qianwen.smartman.modules.system.entity.DeptScope; |
| | |
| | | import com.qianwen.smartman.modules.system.vo.DataScopeGrantVO; |
| | | import com.qianwen.smartman.modules.system.vo.DeptVO; |
| | | import com.qianwen.smartman.modules.system.wrapper.DeptWrapper; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | @Service |
| | | /* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/system/service/impl/DataScopeManagerServiceImpl.class */ |
| | | public class DataScopeManagerServiceImpl extends ServiceImpl<DeptMapper, Dept> implements IDataScopeManagerService { |
| | | private static final String TENANT_ID = "tenantId"; |
| | | private static final String PARENT_ID = "parentId"; |
| | |
| | | private final IUserDeptService userDeptService; |
| | | private final IEmployeeService employeeService; |
| | | |
| | | private static /* synthetic */ Object $deserializeLambda$(SerializedLambda lambda) { |
| | | String implMethodName = lambda.getImplMethodName(); |
| | | boolean z = true; |
| | | switch (implMethodName.hashCode()) { |
| | | case -1334165927: |
| | | if (implMethodName.equals("getScopeId")) { |
| | | z = true; |
| | | break; |
| | | } |
| | | break; |
| | | case -1270120474: |
| | | if (implMethodName.equals("getDeptName")) { |
| | | z = true; |
| | | break; |
| | | } |
| | | break; |
| | | case -1041904421: |
| | | if (implMethodName.equals("getParentId")) { |
| | | z = true; |
| | | break; |
| | | } |
| | | break; |
| | | case -133553590: |
| | | if (implMethodName.equals("getAncestors")) { |
| | | z = false; |
| | | break; |
| | | } |
| | | break; |
| | | case 98245393: |
| | | if (implMethodName.equals("getId")) { |
| | | z = true; |
| | | break; |
| | | } |
| | | break; |
| | | case 360688950: |
| | | if (implMethodName.equals("getDeptId")) { |
| | | z = true; |
| | | break; |
| | | } |
| | | break; |
| | | case 771206363: |
| | | if (implMethodName.equals("getTenantId")) { |
| | | z = true; |
| | | break; |
| | | } |
| | | break; |
| | | } |
| | | switch (z) { |
| | | case false: |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/Dept") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { |
| | | return (v0) -> { |
| | | return v0.getAncestors(); |
| | | }; |
| | | } |
| | | break; |
| | | case true: |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/DeptScope") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { |
| | | return (v0) -> { |
| | | return v0.getScopeId(); |
| | | }; |
| | | } |
| | | break; |
| | | case true: |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/UserDept") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { |
| | | return (v0) -> { |
| | | return v0.getDeptId(); |
| | | }; |
| | | } |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/cps/entity/Employee") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { |
| | | return (v0) -> { |
| | | return v0.getDeptId(); |
| | | }; |
| | | } |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/DeptScope") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { |
| | | return (v0) -> { |
| | | return v0.getDeptId(); |
| | | }; |
| | | } |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/DeptScope") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { |
| | | return (v0) -> { |
| | | return v0.getDeptId(); |
| | | }; |
| | | } |
| | | break; |
| | | case true: |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/Dept") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { |
| | | return (v0) -> { |
| | | return v0.getId(); |
| | | }; |
| | | } |
| | | break; |
| | | case true: |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/Dept") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { |
| | | return (v0) -> { |
| | | return v0.getTenantId(); |
| | | }; |
| | | } |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/Dept") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { |
| | | return (v0) -> { |
| | | return v0.getTenantId(); |
| | | }; |
| | | } |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/Dept") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { |
| | | return (v0) -> { |
| | | return v0.getTenantId(); |
| | | }; |
| | | } |
| | | break; |
| | | case RegionCache.VILLAGE_LEVEL /* 5 */: |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/Dept") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { |
| | | return (v0) -> { |
| | | return v0.getDeptName(); |
| | | }; |
| | | } |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/Dept") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { |
| | | return (v0) -> { |
| | | return v0.getDeptName(); |
| | | }; |
| | | } |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/Dept") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { |
| | | return (v0) -> { |
| | | return v0.getDeptName(); |
| | | }; |
| | | } |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/Dept") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { |
| | | return (v0) -> { |
| | | return v0.getDeptName(); |
| | | }; |
| | | } |
| | | break; |
| | | case true: |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/Dept") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { |
| | | return (v0) -> { |
| | | return v0.getParentId(); |
| | | }; |
| | | } |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/Dept") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { |
| | | return (v0) -> { |
| | | return v0.getParentId(); |
| | | }; |
| | | } |
| | | if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/Dept") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { |
| | | return (v0) -> { |
| | | return v0.getParentId(); |
| | | }; |
| | | } |
| | | break; |
| | | } |
| | | throw new IllegalArgumentException("Invalid lambda deserialization"); |
| | | } |
| | | |
| | | public DataScopeManagerServiceImpl(final IDeptScopeService deptScopeService, final IUserDeptService userDeptService, final IEmployeeService employeeService) { |
| | | this.deptScopeService = deptScopeService; |
| | |
| | | |
| | | @Override // org.springblade.modules.system.service.IDataScopeManagerService |
| | | public String getDeptIds(String tenantId, String deptNames) { |
| | | List<Dept> deptList = this.baseMapper.selectList(Wrappers.<Dept>query().lambda().eq(Dept::getTenantId, tenantId).in(Dept::getDeptName, Func.toStrList(deptNames))); |
| | | /* |
| | | List<Dept> deptList = ((DeptMapper) this.baseMapper).selectList((Wrapper) ((LambdaQueryWrapper) Wrappers.query().lambda().eq((v0) -> { |
| | | return v0.getTenantId(); |
| | | }, tenantId)).in((v0) -> { |
| | | return v0.getDeptName(); |
| | | }, Func.toStrList(deptNames))); |
| | | }, Func.toStrList(deptNames)));*/ |
| | | if (deptList != null && deptList.size() > 0) { |
| | | return (String) deptList.stream().map(dept -> { |
| | | return deptList.stream().map(dept -> { |
| | | return Func.toStr(dept.getId()); |
| | | }).distinct().collect(Collectors.joining(",")); |
| | | } |
| | |
| | | |
| | | @Override // org.springblade.modules.system.service.IDataScopeManagerService |
| | | public String getDeptIdsByFuzzy(String tenantId, String deptNames) { |
| | | LambdaQueryWrapper<Dept> wrapper = Wrappers.<Dept>query().lambda().eq(Dept::getTenantId, tenantId); |
| | | /* |
| | | Wrapper wrapper = (LambdaQueryWrapper) Wrappers.query().lambda().eq((v0) -> { |
| | | return v0.getTenantId(); |
| | | }, tenantId); |
| | | }, tenantId);*/ |
| | | wrapper.and(wrapper2 -> { |
| | | List<String> names = Func.toStrList(deptNames); |
| | | names.forEach(name -> { |
| | | LambdaQueryWrapper lambdaQueryWrapper = (LambdaQueryWrapper) ((LambdaQueryWrapper) wrapper2.like((v0) -> { |
| | | LambdaQueryWrapper lambdaQueryWrapper = wrapper2.like((v0) -> { |
| | | return v0.getDeptName(); |
| | | }, name)).or(); |
| | | }, name).or(); |
| | | }); |
| | | }); |
| | | List<Dept> deptList = ((DeptMapper) this.baseMapper).selectList(wrapper); |
| | |
| | | |
| | | @Override // org.springblade.modules.system.service.IDataScopeManagerService |
| | | public List<String> getDeptNames(String deptIds) { |
| | | return ((DeptMapper) this.baseMapper).getDeptNames(Func.toLongArray(deptIds)); |
| | | return this.baseMapper.getDeptNames(Func.toLongArray(deptIds)); |
| | | } |
| | | |
| | | @Override // org.springblade.modules.system.service.IDataScopeManagerService |
| | | public List<Dept> getDeptChild(Long deptId) { |
| | | return this.baseMapper.selectList(Wrappers.<Dept>query().lambda().like(Dept::getAncestors, deptId)); |
| | | /* |
| | | return ((DeptMapper) this.baseMapper).selectList((Wrapper) Wrappers.query().lambda().like((v0) -> { |
| | | return v0.getAncestors(); |
| | | }, deptId)); |
| | | }, deptId));*/ |
| | | } |
| | | |
| | | @Override // org.springblade.modules.system.service.IDataScopeManagerService |
| | | public boolean removeDept(String ids) { |
| | | Long cnt = this.baseMapper.selectCount(Wrappers.<Dept>query().lambda().in(Dept::getParentId, Func.toLongList(ids))); |
| | | /* |
| | | Long cnt = ((DeptMapper) this.baseMapper).selectCount((Wrapper) Wrappers.query().lambda().in((v0) -> { |
| | | return v0.getParentId(); |
| | | }, Func.toLongList(ids))); |
| | | }, Func.toLongList(ids)));*/ |
| | | if (cnt.longValue() > 0) { |
| | | throw new ServiceException("请先删除子节点!"); |
| | | } |
| | |
| | | }, deptId)) != 0) { |
| | | throw new ServiceException("无法删除,账号绑定了该权限"); |
| | | } |
| | | if (deptId.stream().anyMatch(dept -> { |
| | | return this.employeeService.count(Lambda.create().findIn((v0) -> { |
| | | return v0.getDeptId(); |
| | | }, String.valueOf(dept))) != 0; |
| | | })) { |
| | | |
| | | //long match = deptId.stream().anyMatch(dept -> this.employeeService.count(Lambda.<Employee>create().findIn(Employee::getDeptId, String.valueOf(dept)))) != 0L; |
| | | if (deptId.stream().anyMatch(dept -> (this.employeeService.count(Lambda.<Employee>create().findIn(Employee::getDeptId, String.valueOf(dept))) != 0L))) { |
| | | throw new ServiceException("无法删除, 员工绑定了该权限"); |
| | | } |
| | | /* |
| | | if (match) { |
| | | throw new ServiceException("无法删除, 员工绑定了该权限"); |
| | | }*/ |
| | | } |
| | | |
| | | @Override // org.springblade.modules.system.service.IDataScopeManagerService |
| | |
| | | |
| | | @Override // org.springblade.modules.system.service.IDataScopeManagerService |
| | | public List<DeptVO> search(String deptName, Long parentId) { |
| | | Wrapper lambda = Wrappers.query().lambda(); |
| | | LambdaQueryWrapper<Dept> lambda = Wrappers.<Dept>query().lambda(); |
| | | /* |
| | | Wrapper lambda = Wrappers.query().lambda();*/ |
| | | if (Func.isNotEmpty(deptName)) { |
| | | lambda.like((v0) -> { |
| | | return v0.getDeptName(); |
| | |
| | | return v0.getParentId(); |
| | | }, parentId); |
| | | } |
| | | List<Dept> deptList = ((DeptMapper) this.baseMapper).selectList(lambda); |
| | | List<Dept> deptList = this.baseMapper.selectList(lambda); |
| | | return DeptWrapper.build().listNodeVO(deptList); |
| | | } |
| | | |
| | | private void checkExistDeptNameWithSameLevel(String tenantId, Long parentId, Long id, String name) { |
| | | List<Dept> list = list(Wrappers.<Dept>lambdaQuery().eq(Dept::getTenantId, tenantId).eq(Dept::getParentId, parentId) |
| | | .eq(Dept::getDeptName, name).ne(Func.isNotEmpty(id), Dept::getId, id)); |
| | | /* |
| | | List<Dept> list = list(((LambdaQueryWrapper) ((LambdaQueryWrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getTenantId(); |
| | | }, tenantId)).eq((v0) -> { |
| | |
| | | return v0.getDeptName(); |
| | | }, name)).ne(Func.isNotEmpty(id), (v0) -> { |
| | | return v0.getId(); |
| | | }, id)); |
| | | }, id));*/ |
| | | if (Func.isNotEmpty(list)) { |
| | | throw new ServiceException("同一父机构下不能存在同名机构名称"); |
| | | } |
| | |
| | | this.deptScopeService.remove(Lambda.eq((v0) -> { |
| | | return v0.getDeptId(); |
| | | }, grantVO.getDeptId())); |
| | | List<DeptScope> deptScopeList = (List) grantVO.getDataScopeIds().stream().map(scopeId -> { |
| | | List<DeptScope> deptScopeList = grantVO.getDataScopeIds().stream().map(scopeId -> { |
| | | DeptScope scope = new DeptScope(); |
| | | scope.setScopeId(scopeId); |
| | | scope.setDeptId(grantVO.getDeptId()); |
| | |
| | | |
| | | @Override // org.springblade.modules.system.service.IDataScopeManagerService |
| | | public List<String> grantSelect(final String deptId) { |
| | | return this.deptScopeService.listObjs(Lambda.eq(DeptScope::getDeptId, deptId).select(DeptScope::getScopeId), String::valueOf); |
| | | /* |
| | | return this.deptScopeService.listObjs(Lambda.eq((v0) -> { |
| | | return v0.getDeptId(); |
| | | }, deptId).select((v0) -> { |
| | | return v0.getScopeId(); |
| | | }), String::valueOf); |
| | | }), String::valueOf);*/ |
| | | } |
| | | } |