fix(文件重命名): 重复文件名嵌套时,重命名混乱问题修复

This commit is contained in:
MAC 2022-03-03 22:51:07 +08:00
parent f20ae789b6
commit 9bd765cee5
5 changed files with 7 additions and 13 deletions

View File

@ -11,7 +11,7 @@ public interface IUserFileService extends IService<UserFile> {
List<UserFile> selectUserFileByNameAndPath(String fileName, String filePath, Long userId);
boolean isDirExist(String fileName, String filePath, long userId);
List<UserFile> selectSameUserFile(String fileName, String filePath, String extendName, Long userId);
void replaceUserFilePath(String filePath, String oldFilePath, Long userId);
IPage<FileListVo> userFileList(Long userId, String filePath, Long beginCount, Long pageCount);
void updateFilepathByFilepath(String oldfilePath, String newfilePath, String fileName, String extendName, long userId);
void userFileCopy(String oldfilePath, String newfilePath, String fileName, String extendName, long userId);

View File

@ -176,10 +176,13 @@ public class FileController {
.eq(UserFile::getUserFileId, renameFileDto.getUserFileId());
userFileService.update(lambdaUpdateWrapper);
if (1 == userFile.getIsDir()) {
userFileService.replaceUserFilePath(userFile.getFilePath() + renameFileDto.getFileName() + "/",
userFile.getFilePath() + userFile.getFileName() + "/", sessionUserBean.getUserId());
}
List<UserFile> list = userFileService.selectFileListLikeRightFilePath(userFile.getFilePath() + userFile.getFileName() + "/", sessionUserBean.getUserId());
for (UserFile newUserFile : list) {
newUserFile.setFilePath(newUserFile.getFilePath().replaceFirst(userFile.getFilePath() + userFile.getFileName() + "/", userFile.getFilePath() + renameFileDto.getFileName() + "/"));
userFileService.updateById(newUserFile);
}
}
fileDealComp.uploadESByUserFileId(renameFileDto.getUserFileId());
return RestResult.success();
}

View File

@ -8,7 +8,6 @@ import com.qiwenshare.file.vo.file.FileListVo;
import org.apache.ibatis.annotations.Param;
public interface UserFileMapper extends BaseMapper<UserFile> {
void replaceFilePath(@Param("filePath") String filePath, @Param("oldFilePath") String oldFilePath, @Param("userId") Long userId);
void updateFilepathByPathAndName(String oldfilePath, String newfilePath, String fileName, String extendName, long userId);
void updateFilepathByFilepath(String oldfilePath, String newfilePath, long userId);

View File

@ -81,10 +81,6 @@ public class UserFileService extends ServiceImpl<UserFileMapper, UserFile> impl
return userFileMapper.selectList(lambdaQueryWrapper);
}
@Override
public void replaceUserFilePath(String filePath, String oldFilePath, Long userId) {
userFileMapper.replaceFilePath(filePath, oldFilePath, userId);
}
@Override
public IPage<FileListVo> userFileList(Long userId, String filePath, Long currentPage, Long pageCount) {

View File

@ -6,10 +6,6 @@
<mapper namespace="com.qiwenshare.file.mapper.UserFileMapper">
<update id="replaceFilePath">
UPDATE userfile SET filepath=REPLACE(filepath, #{oldFilePath}, #{filePath})
WHERE filepath LIKE N'${oldFilePath}%' and userId = #{userId};
</update>
<select id="selectPageVo" parameterType="com.qiwenshare.file.domain.UserFile" resultType="com.qiwenshare.file.vo.file.FileListVo">