| | |
| | | @Autowired |
| | | public ProductInfoMapper productInfoMapper; |
| | | @Autowired |
| | | private IPermissionStreamService permissionStreamService; |
| | | private IPermissionStreamNewService permissionStreamNewService; |
| | | @Autowired |
| | | private IComponentDepartmentService componentDepartmentService; |
| | | @Autowired |
| | |
| | | String userId = user.getId(); |
| | | if(!ValidateUtil.validateString(userId)) |
| | | ExceptionCast.cast(UcenterCode.UCENTER_ACCOUNT_NOT_EXIST); |
| | | |
| | | List<PermissionStream> oldPermissionList; |
| | | List<PermissionStreamNew> oldPermissionList; |
| | | ProductInfo productInfo = productInfoMapper.selectById(componentInfo.getProductId()); |
| | | if(productInfo == null) |
| | | ExceptionCast.cast(ComponentInfoCode.COMPONENT_PRODUCT_NONE); |
| | |
| | | if(en == null) { |
| | | ExceptionCast.cast(ComponentInfoCode.COMPONENT_PARENT_NOT_EXIST); |
| | | } |
| | | oldPermissionList = permissionStreamService.getByComponentId(en.getProductId(), en.getComponentId()); |
| | | oldPermissionList = permissionStreamNewService.loadPermissionStreamNewByBusinessId(en.getComponentId(),"2","1"); |
| | | componentInfo.setRankLevel(en.getRankLevel() + 1); |
| | | } else { |
| | | oldPermissionList = permissionStreamService.getByProductId(productInfo.getProductId()); |
| | | oldPermissionList = permissionStreamNewService.loadPermissionStreamNewByBusinessId(productInfo.getProductId(),"1","1"); |
| | | componentInfo.setParentId(null); |
| | | componentInfo.setRankLevel(1); |
| | | } |
| | |
| | | ExceptionCast.cast(CommonCode.FAIL); |
| | | //部门权限 |
| | | List<ComponentDepartment> componentDepartmentList = new ArrayList<>(); |
| | | List<PermissionStream> componentDepartPermList = new ArrayList<>(); |
| | | List<PermissionStreamNew> componentDepartPermList = new ArrayList<>(); |
| | | if(oldPermissionList != null && !oldPermissionList.isEmpty()) { |
| | | oldPermissionList.forEach(item -> { |
| | | ComponentDepartment componentDepartment = new ComponentDepartment(); |
| | | componentDepartment.setComponentId(componentInfo.getComponentId()); |
| | | componentDepartment.setDepartId(item.getDepartId()); |
| | | componentDepartmentList.add(componentDepartment); |
| | | PermissionStream permissionStream = new PermissionStream(); |
| | | permissionStream.setProductId(componentInfo.getProductId()); |
| | | permissionStream.setComponentId(componentInfo.getComponentId()); |
| | | PermissionStreamNew permissionStream = new PermissionStreamNew(); |
| | | permissionStream.setBusinessId(componentInfo.getComponentId()); |
| | | permissionStream.setDepartId(item.getDepartId()); |
| | | permissionStream.setBusinessType("2"); |
| | | componentDepartPermList.add(permissionStream); |
| | | }); |
| | | } |
| | |
| | | ExceptionCast.cast(CommonCode.FAIL); |
| | | } |
| | | if(!componentDepartPermList.isEmpty()) { |
| | | b = permissionStreamService.saveBatch(componentDepartPermList); |
| | | b = permissionStreamNewService.saveBatch(componentDepartPermList); |
| | | if(!b) |
| | | ExceptionCast.cast(CommonCode.FAIL); |
| | | } |
| | |
| | | } |
| | | //去除默认新增工序,转为手动添加 |
| | | //添加权限 |
| | | PermissionStream stream = new PermissionStream(); |
| | | PermissionStreamNew stream = new PermissionStreamNew(); |
| | | stream.setUserId(userId); |
| | | stream.setProductId(componentInfo.getProductId()); |
| | | stream.setComponentId(componentInfo.getComponentId()); |
| | | return permissionStreamService.save(stream); |
| | | stream.setBusinessId(componentInfo.getComponentId()); |
| | | stream.setBusinessType("2"); |
| | | return permissionStreamNewService.save(stream); |
| | | } |
| | | |
| | | @Override |
| | |
| | | if(!b) |
| | | return false; |
| | | } |
| | | PermissionStream stream = permissionStreamService.getByComponentIdAndUserId(en.getProductId(), id, userId); |
| | | PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(id, userId,"2"); |
| | | if(stream == null) { |
| | | stream = new PermissionStream(); |
| | | stream = new PermissionStreamNew(); |
| | | stream.setUserId(userId); |
| | | stream.setProductId(en.getProductId()); |
| | | stream.setComponentId(id); |
| | | return permissionStreamService.save(stream); |
| | | stream.setBusinessId(id); |
| | | stream.setBusinessType("2"); |
| | | return permissionStreamNewService.save(stream); |
| | | } |
| | | return b; |
| | | } |
| | |
| | | b = componentDepartmentService.deleteByComponentId(item.getComponentId()); |
| | | if(!b) |
| | | ExceptionCast.cast(ComponentInfoCode.COMPONENT_DELETE_PERM_NONE); |
| | | b = permissionStreamService.deleteUserPermsByComponentId(item.getProductId(), item.getComponentId()); |
| | | b = permissionStreamNewService.deletePermissionStreamNewByBusinessId(item.getComponentId(),"2","0"); |
| | | if(!b) |
| | | ExceptionCast.cast(ComponentInfoCode.COMPONENT_DELETE_PERM_NONE); |
| | | b = permissionStreamService.deleteDepartPermsByComponentId(item.getProductId(), item.getComponentId()); |
| | | b = permissionStreamNewService.deletePermissionStreamNewByBusinessId(item.getComponentId(),"2","1"); |
| | | if(!b) |
| | | ExceptionCast.cast(ComponentInfoCode.COMPONENT_DELETE_PERM_NONE); |
| | | b = super.removeById(item.getComponentId()); |
| | |
| | | b = componentDepartmentService.deleteByComponentId(id); |
| | | if(!b) |
| | | ExceptionCast.cast(CommonCode.FAIL); |
| | | b = permissionStreamService.deleteUserPermsByComponentId(componentInfo.getProductId(), componentInfo.getComponentId()); |
| | | b = permissionStreamNewService.deletePermissionStreamNewByBusinessId(componentInfo.getComponentId(),"2","0"); |
| | | if(!b) |
| | | ExceptionCast.cast(CommonCode.FAIL); |
| | | b = permissionStreamService.deleteDepartPermsByComponentId(componentInfo.getProductId(), componentInfo.getComponentId()); |
| | | b = permissionStreamNewService.deletePermissionStreamNewByBusinessId(componentInfo.getComponentId(),"2","1"); |
| | | if(!b) |
| | | ExceptionCast.cast(CommonCode.FAIL); |
| | | return super.removeById(id); |
| | |
| | | if(componentInfo == null || userList == null || userList.isEmpty()) |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | List<ComponentPermission> permissionList = new ArrayList<>(); |
| | | List<PermissionStream> permissionStreamList = new ArrayList<>(); |
| | | List<PermissionStreamNew> permissionStreamList = new ArrayList<>(); |
| | | userList.forEach(item -> { |
| | | ComponentPermission en = componentPermissionService.getByComponentIdAndUserId(componentInfo.getComponentId(), item.getId()); |
| | | if(en == null) { |
| | |
| | | en.setComponentId(componentInfo.getComponentId()); |
| | | permissionList.add(en); |
| | | } |
| | | PermissionStream stream = permissionStreamService.getByComponentIdAndUserId(componentInfo.getProductId(), componentInfo.getComponentId(), item.getId()); |
| | | PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndDepartId(componentInfo.getComponentId(), item.getId(), "2 "); |
| | | if(stream == null) { |
| | | stream = new PermissionStream(); |
| | | stream = new PermissionStreamNew(); |
| | | stream.setUserId(item.getId()); |
| | | stream.setProductId(componentInfo.getProductId()); |
| | | stream.setComponentId(componentInfo.getComponentId()); |
| | | stream.setBusinessId(componentInfo.getComponentId()); |
| | | stream.setBusinessType("2"); |
| | | permissionStreamList.add(stream); |
| | | } |
| | | }); |
| | |
| | | } |
| | | } |
| | | if(!permissionStreamList.isEmpty()) { |
| | | boolean b = permissionStreamService.saveBatch(permissionStreamList); |
| | | boolean b = permissionStreamNewService.saveBatch(permissionStreamList); |
| | | if(!b) { |
| | | ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR); |
| | | } |
| | |
| | | if(componentInfo == null || userList == null || userList.isEmpty()) |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | List<ComponentPermission> permissionList = new ArrayList<>(); |
| | | List<PermissionStream> permissionStreamList = new ArrayList<>(); |
| | | List<PermissionStreamNew> permissionStreamList = new ArrayList<>(); |
| | | userList.forEach(item -> { |
| | | ComponentPermission en = componentPermissionService.getByComponentIdAndUserId(componentInfo.getComponentId(), item.getId()); |
| | | if(en != null) { |
| | | permissionList.add(en); |
| | | } |
| | | PermissionStream stream = permissionStreamService.getByComponentIdAndUserId(componentInfo.getProductId(), componentInfo.getComponentId(), item.getId()); |
| | | PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndDepartId(componentInfo.getComponentId(), item.getId(), "2 "); |
| | | if(stream != null) { |
| | | permissionStreamList.add(stream); |
| | | } |
| | |
| | | } |
| | | } |
| | | if(!permissionStreamList.isEmpty()) { |
| | | boolean b = permissionStreamService.removeByCollection(permissionStreamList); |
| | | boolean b = permissionStreamNewService.deletePermissionStreamNewByList(permissionStreamList); |
| | | if(!b) { |
| | | ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR); |
| | | } |
| | |
| | | if(componentInfo == null || departmentList == null || departmentList.isEmpty()) |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | List<ComponentDepartment> componentDepartments = new ArrayList<>(); |
| | | List<PermissionStream> permissionStreamList = new ArrayList<>(); |
| | | List<PermissionStreamNew> permissionStreamList = new ArrayList<>(); |
| | | departmentList.forEach(item -> { |
| | | ComponentDepartment en = componentDepartmentService.getByComponentIdAndDepartId(componentInfo.getComponentId(), item.getId()); |
| | | if(en == null) { |
| | |
| | | en.setComponentId(componentInfo.getComponentId()); |
| | | componentDepartments.add(en); |
| | | } |
| | | PermissionStream stream = permissionStreamService.getByComponentIdAndDepartId(componentInfo.getProductId(), componentInfo.getComponentId(), item.getId()); |
| | | PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndDepartId(componentInfo.getComponentId(), item.getId(),"2"); |
| | | if(stream == null) { |
| | | stream = new PermissionStream(); |
| | | stream = new PermissionStreamNew(); |
| | | stream.setDepartId(item.getId()); |
| | | stream.setProductId(componentInfo.getProductId()); |
| | | stream.setComponentId(componentInfo.getComponentId()); |
| | | stream.setBusinessId(componentInfo.getComponentId()); |
| | | stream.setBusinessType("2"); |
| | | permissionStreamList.add(stream); |
| | | } |
| | | }); |
| | |
| | | } |
| | | } |
| | | if(!permissionStreamList.isEmpty()) { |
| | | boolean b = permissionStreamService.saveBatch(permissionStreamList); |
| | | boolean b = permissionStreamNewService.saveBatch(permissionStreamList); |
| | | if(!b) { |
| | | ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR); |
| | | } |
| | |
| | | if(componentInfo == null || departmentList == null || departmentList.isEmpty()) |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | List<ComponentDepartment> componentDepartments = new ArrayList<>(); |
| | | List<PermissionStream> permissionStreamList = new ArrayList<>(); |
| | | List<PermissionStreamNew> permissionStreamList = new ArrayList<>(); |
| | | departmentList.forEach(item -> { |
| | | ComponentDepartment en = componentDepartmentService.getByComponentIdAndDepartId(componentInfo.getComponentId(), item.getId()); |
| | | if(en != null) { |
| | | componentDepartments.add(en); |
| | | } |
| | | PermissionStream stream = permissionStreamService.getByComponentIdAndDepartId(componentInfo.getProductId(), componentInfo.getComponentId(), item.getId()); |
| | | PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndDepartId(componentInfo.getComponentId(), item.getId(),"2"); |
| | | if(stream != null) { |
| | | permissionStreamList.add(stream); |
| | | } |
| | |
| | | } |
| | | } |
| | | if(!permissionStreamList.isEmpty()) { |
| | | boolean b = permissionStreamService.removeByCollection(permissionStreamList); |
| | | boolean b = permissionStreamNewService.deletePermissionStreamNewByList(permissionStreamList); |
| | | if(!b) { |
| | | ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR); |
| | | } |