Commit f1660e18e41e66a2e38631d6fb363f130b6259f6

Authored by YunaiV
1 parent 688de723

fix: 优化对 JDK8 的兼容性

yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/local/LocalFileClient.java
... ... @@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.infra.framework.file.core.client.AbstractFileClie
6 6 import cn.iocoder.yudao.module.infra.framework.file.core.utils.FilePathUtils;
7 7  
8 8 import java.nio.file.Path;
  9 +import java.nio.file.Paths;
9 10  
10 11 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
11 12 import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.FILE_PATH_INVALID;
... ... @@ -55,7 +56,7 @@ public class LocalFileClient extends AbstractFileClient<LocalFileClientConfig> {
55 56  
56 57 private String getFilePath(String path) {
57 58 FilePathUtils.validatePath(path);
58   - Path basePath = Path.of(config.getBasePath()).toAbsolutePath().normalize();
  59 + Path basePath = Paths.get(config.getBasePath()).toAbsolutePath().normalize();
59 60 Path filePath = basePath.resolve(path).normalize();
60 61 if (!filePath.startsWith(basePath)) {
61 62 throw exception(FILE_PATH_INVALID);
... ...
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/utils/FilePathUtils.java
... ... @@ -4,7 +4,7 @@ import cn.hutool.core.io.FileUtil;
4 4 import cn.hutool.core.util.StrUtil;
5 5  
6 6 import java.nio.file.InvalidPathException;
7   -import java.nio.file.Path;
  7 +import java.nio.file.Paths;
8 8  
9 9 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
10 10 import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.FILE_PATH_INVALID;
... ... @@ -88,7 +88,7 @@ public class FilePathUtils {
88 88 }
89 89 try {
90 90 // 使用 JDK Path 再兜底判断一次绝对路径
91   - if (Path.of(path).isAbsolute()) {
  91 + if (Paths.get(path).isAbsolute()) {
92 92 return false;
93 93 }
94 94 } catch (InvalidPathException ex) {
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/scene/action/IotAlertTriggerSceneRuleAction.java
... ... @@ -121,11 +121,20 @@ public class IotAlertTriggerSceneRuleAction implements IotSceneRuleAction {
121 121 }
122 122  
123 123 private String resolveTemplateCode(IotAlertConfigDO config, IotAlertReceiveTypeEnum typeEnum) {
124   - String templateCode = switch (typeEnum) {
125   - case SMS -> config.getSmsTemplateCode();
126   - case MAIL -> config.getMailTemplateCode();
127   - case NOTIFY -> config.getNotifyTemplateCode();
128   - };
  124 + String templateCode = null;
  125 + switch (typeEnum) {
  126 + case SMS:
  127 + templateCode = config.getSmsTemplateCode();
  128 + break;
  129 + case MAIL:
  130 + templateCode = config.getMailTemplateCode();
  131 + break;
  132 + case NOTIFY:
  133 + templateCode = config.getNotifyTemplateCode();
  134 + break;
  135 + default:
  136 + break;
  137 + }
129 138 return StrUtil.blankToDefault(templateCode, typeEnum.getTemplateCode());
130 139 }
131 140  
... ...