diff --git a/src/main/java/com/yutou/tools/home/nas/MusicController.java b/src/main/java/com/yutou/tools/home/nas/MusicController.java index 4a65365..594c610 100644 --- a/src/main/java/com/yutou/tools/home/nas/MusicController.java +++ b/src/main/java/com/yutou/tools/home/nas/MusicController.java @@ -46,6 +46,7 @@ public class MusicController { if(!StringUtils.isEmpty(path)&&!new File(path).exists()){ path=Tools.base64ToString(path); } + System.out.println("接收到地址:"+path); if(StringUtils.isEmpty(path) ||path.equals("root") ||!path.contains(defaultMusicPath) diff --git a/src/main/java/com/yutou/tools/utils/MusicTools.java b/src/main/java/com/yutou/tools/utils/MusicTools.java index 53e5134..428d1a5 100644 --- a/src/main/java/com/yutou/tools/utils/MusicTools.java +++ b/src/main/java/com/yutou/tools/utils/MusicTools.java @@ -123,20 +123,31 @@ public class MusicTools implements MusicToolsService { @Override public List getPath(String path, boolean isDir) { List list = new ArrayList<>(); - List main; + List main=new ArrayList<>(); MusicDataExample example = new MusicDataExample(); String replacement = ConfigTools.load(ConfigTools.CONFIG, "os").equals("windows") ? "\\\\" : "/"; + String tmpPath=path; if (isDir) { - example.createCriteria().andFileLike(path.replace(File.separator, replacement) + "%"); + example.createCriteria().andFileLike(tmpPath.replace(File.separator, replacement) + "%"); main = musicDataDao.selectByExample(example); - } else { - main = musicDataDao.selectByRegexp(path.replace(File.separator, replacement) + replacement + "([^" + replacement + "]+)$"); } + tmpPath=tmpPath.replace(File.separator, replacement) + .replace("[","\\[") + .replace("(","\\(") + .replace(")","\\)") + .replace("]","\\]"); + main.addAll(musicDataDao.selectByRegexp(tmpPath + replacement + "([^" + replacement + "]+)$")); + if (!path.equals(MusicController.defaultMusicPath) && !path.equals("root")) { - MusicData tmp = main.get(0); MusicData t2 = new MusicData(); t2.setTitle("返回"); - t2.setFile(new File(tmp.getLastdir()).getAbsolutePath()); + if(main.isEmpty()){ + t2.setFile("root"); + }else { + MusicData tmp = main.get(0); + t2.setFile(new File(tmp.getLastdir()).getAbsolutePath()); + } + System.out.println("查询地址:"+path+" 设置返回地址:"+t2.getFile()); t2.setIsdir(1); list.add(t2); }