@@ -782,12 +782,32 @@ public ResponseResult renameDir(@RequestBody String JSONString){
782
782
if (contentVO .getName ().equals (newFileName ) &&
783
783
contentVO .getId () != dirId ) return forbidden ;
784
784
}
785
-
786
- if (renamedir . getAbsolutePath () .equals (renamedir .getName ())) {
785
+ String oldAbsolutePath = renamedir . getAbsolutePath ();
786
+ if (oldAbsolutePath .equals (renamedir .getName ())) {
787
787
renamedir .setAbsolutePath (newFileName );
788
788
} else {
789
789
renamedir .setAbsolutePath (parent .getAbsolutePath () + newFileName .substring (1 ));
790
790
}
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
+ }
791
811
renamedir .setName (newFileName );
792
812
directoryMapper .updateById (renamedir );
793
813
return ok ;
0 commit comments