This commit is contained in:
YunaiV
2026-05-31 19:51:37 +08:00
3 changed files with 18 additions and 8 deletions

View File

@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.infra.framework.file.core.client.AbstractFileClie
import cn.iocoder.yudao.module.infra.framework.file.core.utils.FilePathUtils;
import java.nio.file.Path;
import java.nio.file.Paths;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.FILE_PATH_INVALID;
@ -55,7 +56,7 @@ public class LocalFileClient extends AbstractFileClient<LocalFileClientConfig> {
private String getFilePath(String path) {
FilePathUtils.validatePath(path);
Path basePath = Path.of(config.getBasePath()).toAbsolutePath().normalize();
Path basePath = Paths.get(config.getBasePath()).toAbsolutePath().normalize();
Path filePath = basePath.resolve(path).normalize();
if (!filePath.startsWith(basePath)) {
throw exception(FILE_PATH_INVALID);

View File

@ -4,7 +4,7 @@ import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;
import java.nio.file.InvalidPathException;
import java.nio.file.Path;
import java.nio.file.Paths;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.FILE_PATH_INVALID;
@ -88,7 +88,7 @@ public class FilePathUtils {
}
try {
// 使用 JDK Path 再兜底判断一次绝对路径
if (Path.of(path).isAbsolute()) {
if (Paths.get(path).isAbsolute()) {
return false;
}
} catch (InvalidPathException ex) {

View File

@ -121,11 +121,20 @@ public class IotAlertTriggerSceneRuleAction implements IotSceneRuleAction {
}
private String resolveTemplateCode(IotAlertConfigDO config, IotAlertReceiveTypeEnum typeEnum) {
String templateCode = switch (typeEnum) {
case SMS -> config.getSmsTemplateCode();
case MAIL -> config.getMailTemplateCode();
case NOTIFY -> config.getNotifyTemplateCode();
};
String templateCode = null;
switch (typeEnum) {
case SMS:
templateCode = config.getSmsTemplateCode();
break;
case MAIL:
templateCode = config.getMailTemplateCode();
break;
case NOTIFY:
templateCode = config.getNotifyTemplateCode();
break;
default:
break;
}
return StrUtil.blankToDefault(templateCode, typeEnum.getTemplateCode());
}