Skip to content

Commit 8e21e43

Browse files
committed
fix: 文件夹重命名子文件路径不更改Bug
1 parent 648055e commit 8e21e43

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

Diff for: src/main/java/com/outzone/controller/FileController.java

+22-2
Original file line numberDiff line numberDiff line change
@@ -782,12 +782,32 @@ public ResponseResult renameDir(@RequestBody String JSONString){
782782
if (contentVO.getName().equals(newFileName) &&
783783
contentVO.getId() != dirId) return forbidden;
784784
}
785-
786-
if (renamedir.getAbsolutePath().equals(renamedir.getName())) {
785+
String oldAbsolutePath = renamedir.getAbsolutePath();
786+
if (oldAbsolutePath.equals(renamedir.getName())) {
787787
renamedir.setAbsolutePath(newFileName);
788788
} else {
789789
renamedir.setAbsolutePath(parent.getAbsolutePath() + newFileName.substring(1));
790790
}
791+
String nowAbsolutePath = renamedir.getAbsolutePath();
792+
List<DirectoryDTO> directoryList = directoryMapper.getAllSubDir(oldAbsolutePath, groupId != -1,
793+
(groupId != -1) ? groupId : requestUser.getId());
794+
for (DirectoryDTO toUpdateDir : directoryList) {
795+
toUpdateDir.setAbsolutePath(toUpdateDir.getAbsolutePath().replaceAll(oldAbsolutePath, nowAbsolutePath));
796+
directoryMapper.updateById(toUpdateDir);
797+
}
798+
if (groupId == -1) {
799+
List<UserFileDTO> userFileList = userFileMapper.getAllSubUserFileList(oldAbsolutePath, requestUser.getId());
800+
for (UserFileDTO toUpdateFile : userFileList) {
801+
toUpdateFile.setAbsolutePath(toUpdateFile.getAbsolutePath().replaceAll(oldAbsolutePath, nowAbsolutePath));
802+
userFileMapper.updateById(toUpdateFile);
803+
}
804+
} else {
805+
List<GroupFileDTO> groupFileList = groupFileMapper.getAllSubGroupFileList(oldAbsolutePath, groupId);
806+
for (GroupFileDTO toUpdateFile : groupFileList) {
807+
toUpdateFile.setAbsolutePath(toUpdateFile.getAbsolutePath().replaceAll(oldAbsolutePath, nowAbsolutePath));
808+
groupFileMapper.updateById(toUpdateFile);
809+
}
810+
}
791811
renamedir.setName(newFileName);
792812
directoryMapper.updateById(renamedir);
793813
return ok;

0 commit comments

Comments
 (0)