update 简化 stream 代码写法 (java 16) xx.collect(Collectors.toList()) => xx.toList() ;
update 简化 instanceof 代码写法 (java 12) 直接在后面定义变量 ;
update 简化 switch 代码写法 (java 12) ;
| | |
| | | if (CollUtil.isEmpty(collection)) { |
| | | return CollUtil.newArrayList(); |
| | | } |
| | | return collection.stream().filter(function).collect(Collectors.toList()); |
| | | return collection.stream().filter(function).toList(); |
| | | } |
| | | |
| | | /** |
| | |
| | | if (CollUtil.isEmpty(collection)) { |
| | | return CollUtil.newArrayList(); |
| | | } |
| | | return collection.stream().sorted(comparing).collect(Collectors.toList()); |
| | | return collection.stream().sorted(comparing).toList(); |
| | | } |
| | | |
| | | /** |
| | |
| | | .stream() |
| | | .map(function) |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toList()); |
| | | .toList(); |
| | | } |
| | | |
| | | /** |
| | |
| | | @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/>", |
| | |
| | | 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); |
| | |
| | | */ |
| | | @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; |
| | |
| | | @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); |
| | |
| | | @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); |
| | |
| | | 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) { |
| | |
| | | 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"); |
| | | } |
| | |
| | | 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)); |
| | | } |
| | |
| | | } |
| | | 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); |
| | |
| | | */ |
| | | public static Collection<String> keys(final String pattern) { |
| | | Stream<String> stream = CLIENT.getKeys().getKeysStreamByPattern(pattern); |
| | | return stream.collect(Collectors.toList()); |
| | | return stream.toList(); |
| | | } |
| | | |
| | | /** |
| | |
| | | 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 + "*"); |
| | |
| | | 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); |
| | | } |