mirror of
				https://github.com/dromara/RuoYi-Vue-Plus.git
				synced 2025-11-04 16:23:42 +08:00 
			
		
		
		
	update 简化 stream 代码写法 (java 16) xx.collect(Collectors.toList()) => xx.toList() ;
update 简化 instanceof 代码写法 (java 12) 直接在后面定义变量 ; update 简化 switch 代码写法 (java 12) ;
This commit is contained in:
		@@ -30,7 +30,7 @@ public class StreamUtils {
 | 
			
		||||
        if (CollUtil.isEmpty(collection)) {
 | 
			
		||||
            return CollUtil.newArrayList();
 | 
			
		||||
        }
 | 
			
		||||
        return collection.stream().filter(function).collect(Collectors.toList());
 | 
			
		||||
        return collection.stream().filter(function).toList();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -70,7 +70,7 @@ public class StreamUtils {
 | 
			
		||||
        if (CollUtil.isEmpty(collection)) {
 | 
			
		||||
            return CollUtil.newArrayList();
 | 
			
		||||
        }
 | 
			
		||||
        return collection.stream().sorted(comparing).collect(Collectors.toList());
 | 
			
		||||
        return collection.stream().sorted(comparing).toList();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -188,7 +188,7 @@ public class StreamUtils {
 | 
			
		||||
            .stream()
 | 
			
		||||
            .map(function)
 | 
			
		||||
            .filter(Objects::nonNull)
 | 
			
		||||
            .collect(Collectors.toList());
 | 
			
		||||
            .toList();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -55,9 +55,8 @@ public class DefaultExcelListener<T> extends AnalysisEventListener<T> implements
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onException(Exception exception, AnalysisContext context) throws Exception {
 | 
			
		||||
        String errMsg = null;
 | 
			
		||||
        if (exception instanceof ExcelDataConvertException) {
 | 
			
		||||
        if (exception instanceof ExcelDataConvertException excelDataConvertException) {
 | 
			
		||||
            // 如果是某一个单元格的转换异常 能获取到具体行号
 | 
			
		||||
            ExcelDataConvertException excelDataConvertException = (ExcelDataConvertException) exception;
 | 
			
		||||
            Integer rowIndex = excelDataConvertException.getRowIndex();
 | 
			
		||||
            Integer columnIndex = excelDataConvertException.getColumnIndex();
 | 
			
		||||
            errMsg = StrUtil.format("第{}行-第{}列-表头{}: 解析异常<br/>",
 | 
			
		||||
@@ -66,8 +65,7 @@ public class DefaultExcelListener<T> extends AnalysisEventListener<T> implements
 | 
			
		||||
                log.error(errMsg);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if (exception instanceof ConstraintViolationException) {
 | 
			
		||||
            ConstraintViolationException constraintViolationException = (ConstraintViolationException) exception;
 | 
			
		||||
        if (exception instanceof ConstraintViolationException constraintViolationException) {
 | 
			
		||||
            Set<ConstraintViolation<?>> constraintViolations = constraintViolationException.getConstraintViolations();
 | 
			
		||||
            String constraintViolationsMsg = StreamUtils.join(constraintViolations, ConstraintViolation::getMessage, ", ");
 | 
			
		||||
            errMsg = StrUtil.format("第{}行数据校验异常: {}", context.readRowHolder().getRowIndex() + 1, constraintViolationsMsg);
 | 
			
		||||
 
 | 
			
		||||
@@ -78,9 +78,8 @@ public class RepeatSubmitAspect {
 | 
			
		||||
     */
 | 
			
		||||
    @AfterReturning(pointcut = "@annotation(repeatSubmit)", returning = "jsonResult")
 | 
			
		||||
    public void doAfterReturning(JoinPoint joinPoint, RepeatSubmit repeatSubmit, Object jsonResult) {
 | 
			
		||||
        if (jsonResult instanceof R) {
 | 
			
		||||
        if (jsonResult instanceof R r) {
 | 
			
		||||
            try {
 | 
			
		||||
                R<?> r = (R<?>) jsonResult;
 | 
			
		||||
                // 成功则不删除redis数据 保证在有效时间内无法重复提交
 | 
			
		||||
                if (r.getCode() == R.SUCCESS) {
 | 
			
		||||
                    return;
 | 
			
		||||
 
 | 
			
		||||
@@ -25,8 +25,7 @@ public class CreateAndUpdateMetaObjectHandler implements MetaObjectHandler {
 | 
			
		||||
    @Override
 | 
			
		||||
    public void insertFill(MetaObject metaObject) {
 | 
			
		||||
        try {
 | 
			
		||||
            if (ObjectUtil.isNotNull(metaObject) && metaObject.getOriginalObject() instanceof BaseEntity) {
 | 
			
		||||
                BaseEntity baseEntity = (BaseEntity) metaObject.getOriginalObject();
 | 
			
		||||
            if (ObjectUtil.isNotNull(metaObject) && metaObject.getOriginalObject() instanceof BaseEntity baseEntity) {
 | 
			
		||||
                Date current = ObjectUtil.isNotNull(baseEntity.getCreateTime())
 | 
			
		||||
                    ? baseEntity.getCreateTime() : new Date();
 | 
			
		||||
                baseEntity.setCreateTime(current);
 | 
			
		||||
@@ -46,8 +45,7 @@ public class CreateAndUpdateMetaObjectHandler implements MetaObjectHandler {
 | 
			
		||||
    @Override
 | 
			
		||||
    public void updateFill(MetaObject metaObject) {
 | 
			
		||||
        try {
 | 
			
		||||
            if (ObjectUtil.isNotNull(metaObject) && metaObject.getOriginalObject() instanceof BaseEntity) {
 | 
			
		||||
                BaseEntity baseEntity = (BaseEntity) metaObject.getOriginalObject();
 | 
			
		||||
            if (ObjectUtil.isNotNull(metaObject) && metaObject.getOriginalObject() instanceof BaseEntity baseEntity) {
 | 
			
		||||
                Date current = new Date();
 | 
			
		||||
                // 更新时间填充(不管为不为空)
 | 
			
		||||
                baseEntity.setUpdateTime(current);
 | 
			
		||||
 
 | 
			
		||||
@@ -163,7 +163,7 @@ public class PlusDataPermissionHandler {
 | 
			
		||||
        String methodName = sb.substring(index + 1, sb.length());
 | 
			
		||||
        Class<?> clazz = ClassUtil.loadClass(clazzName);
 | 
			
		||||
        List<Method> methods = Arrays.stream(ClassUtil.getDeclaredMethods(clazz))
 | 
			
		||||
            .filter(method -> method.getName().equals(methodName)).collect(Collectors.toList());
 | 
			
		||||
            .filter(method -> method.getName().equals(methodName)).toList();
 | 
			
		||||
        DataPermission dataPermission;
 | 
			
		||||
        // 获取方法注解
 | 
			
		||||
        for (Method method : methods) {
 | 
			
		||||
 
 | 
			
		||||
@@ -39,8 +39,8 @@ public class DataPermissionHelper {
 | 
			
		||||
            saStorage.set(DATA_PERMISSION_KEY, new HashMap<>());
 | 
			
		||||
            attribute = saStorage.get(DATA_PERMISSION_KEY);
 | 
			
		||||
        }
 | 
			
		||||
        if (attribute instanceof Map) {
 | 
			
		||||
            return (Map<String, Object>) attribute;
 | 
			
		||||
        if (attribute instanceof Map map) {
 | 
			
		||||
            return map;
 | 
			
		||||
        }
 | 
			
		||||
        throw new NullPointerException("data permission context type exception");
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -68,8 +68,7 @@ public class PlusDataPermissionInterceptor extends JsqlParserSupport implements
 | 
			
		||||
        SelectBody selectBody = select.getSelectBody();
 | 
			
		||||
        if (selectBody instanceof PlainSelect) {
 | 
			
		||||
            this.setWhere((PlainSelect) selectBody, (String) obj);
 | 
			
		||||
        } else if (selectBody instanceof SetOperationList) {
 | 
			
		||||
            SetOperationList setOperationList = (SetOperationList) selectBody;
 | 
			
		||||
        } else if (selectBody instanceof SetOperationList setOperationList) {
 | 
			
		||||
            List<SelectBody> selectBodyList = setOperationList.getSelects();
 | 
			
		||||
            selectBodyList.forEach(s -> this.setWhere((PlainSelect) s, (String) obj));
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -221,15 +221,12 @@ public class OssClient {
 | 
			
		||||
        }
 | 
			
		||||
        builder.append("{\n\"Action\": ");
 | 
			
		||||
        switch (policyType) {
 | 
			
		||||
            case WRITE:
 | 
			
		||||
            case WRITE ->
 | 
			
		||||
                builder.append("[\n\"s3:AbortMultipartUpload\",\n\"s3:DeleteObject\",\n\"s3:ListMultipartUploadParts\",\n\"s3:PutObject\"\n],\n");
 | 
			
		||||
                break;
 | 
			
		||||
            case READ_WRITE:
 | 
			
		||||
            case READ_WRITE ->
 | 
			
		||||
                builder.append("[\n\"s3:AbortMultipartUpload\",\n\"s3:DeleteObject\",\n\"s3:GetObject\",\n\"s3:ListMultipartUploadParts\",\n\"s3:PutObject\"\n],\n");
 | 
			
		||||
                break;
 | 
			
		||||
            default:
 | 
			
		||||
            default ->
 | 
			
		||||
                builder.append("\"s3:GetObject\",\n");
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
        builder.append("\"Effect\": \"Allow\",\n\"Principal\": \"*\",\n\"Resource\": \"arn:aws:s3:::");
 | 
			
		||||
        builder.append(bucketName);
 | 
			
		||||
 
 | 
			
		||||
@@ -438,7 +438,7 @@ public class RedisUtils {
 | 
			
		||||
     */
 | 
			
		||||
    public static Collection<String> keys(final String pattern) {
 | 
			
		||||
        Stream<String> stream = CLIENT.getKeys().getKeysStreamByPattern(pattern);
 | 
			
		||||
        return stream.collect(Collectors.toList());
 | 
			
		||||
        return stream.toList();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -94,7 +94,7 @@ public class CacheController {
 | 
			
		||||
        if (isCacheNames(cacheName)) {
 | 
			
		||||
            Set<Object> keys = CacheUtils.keys(cacheName);
 | 
			
		||||
            if (CollUtil.isNotEmpty(keys)) {
 | 
			
		||||
                cacheKeys = keys.stream().map(Object::toString).collect(Collectors.toList());
 | 
			
		||||
                cacheKeys = keys.stream().map(Object::toString).toList();
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            cacheKeys = RedisUtils.keys(cacheName + "*");
 | 
			
		||||
 
 | 
			
		||||
@@ -52,7 +52,7 @@ public class SysOssServiceImpl implements ISysOssService {
 | 
			
		||||
    public TableDataInfo<SysOssVo> queryPageList(SysOssBo bo, PageQuery pageQuery) {
 | 
			
		||||
        LambdaQueryWrapper<SysOss> lqw = buildQueryWrapper(bo);
 | 
			
		||||
        Page<SysOssVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
 | 
			
		||||
        List<SysOssVo> filterResult = result.getRecords().stream().map(this::matchingUrl).collect(Collectors.toList());
 | 
			
		||||
        List<SysOssVo> filterResult = result.getRecords().stream().map(this::matchingUrl).toList();
 | 
			
		||||
        result.setRecords(filterResult);
 | 
			
		||||
        return TableDataInfo.build(result);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user