fix(文件重命名): 重复文件名嵌套时,重命名混乱问题修复
This commit is contained in:
parent
f20ae789b6
commit
9bd765cee5
@ -11,7 +11,7 @@ public interface IUserFileService extends IService<UserFile> {
|
|||||||
List<UserFile> selectUserFileByNameAndPath(String fileName, String filePath, Long userId);
|
List<UserFile> selectUserFileByNameAndPath(String fileName, String filePath, Long userId);
|
||||||
boolean isDirExist(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);
|
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);
|
IPage<FileListVo> userFileList(Long userId, String filePath, Long beginCount, Long pageCount);
|
||||||
void updateFilepathByFilepath(String oldfilePath, String newfilePath, String fileName, String extendName, long userId);
|
void updateFilepathByFilepath(String oldfilePath, String newfilePath, String fileName, String extendName, long userId);
|
||||||
void userFileCopy(String oldfilePath, String newfilePath, String fileName, String extendName, long userId);
|
void userFileCopy(String oldfilePath, String newfilePath, String fileName, String extendName, long userId);
|
||||||
|
@ -176,10 +176,13 @@ public class FileController {
|
|||||||
.eq(UserFile::getUserFileId, renameFileDto.getUserFileId());
|
.eq(UserFile::getUserFileId, renameFileDto.getUserFileId());
|
||||||
userFileService.update(lambdaUpdateWrapper);
|
userFileService.update(lambdaUpdateWrapper);
|
||||||
if (1 == userFile.getIsDir()) {
|
if (1 == userFile.getIsDir()) {
|
||||||
userFileService.replaceUserFilePath(userFile.getFilePath() + renameFileDto.getFileName() + "/",
|
List<UserFile> list = userFileService.selectFileListLikeRightFilePath(userFile.getFilePath() + userFile.getFileName() + "/", sessionUserBean.getUserId());
|
||||||
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());
|
fileDealComp.uploadESByUserFileId(renameFileDto.getUserFileId());
|
||||||
return RestResult.success();
|
return RestResult.success();
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ import com.qiwenshare.file.vo.file.FileListVo;
|
|||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
public interface UserFileMapper extends BaseMapper<UserFile> {
|
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 updateFilepathByPathAndName(String oldfilePath, String newfilePath, String fileName, String extendName, long userId);
|
||||||
void updateFilepathByFilepath(String oldfilePath, String newfilePath, long userId);
|
void updateFilepathByFilepath(String oldfilePath, String newfilePath, long userId);
|
||||||
|
@ -81,10 +81,6 @@ public class UserFileService extends ServiceImpl<UserFileMapper, UserFile> impl
|
|||||||
return userFileMapper.selectList(lambdaQueryWrapper);
|
return userFileMapper.selectList(lambdaQueryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void replaceUserFilePath(String filePath, String oldFilePath, Long userId) {
|
|
||||||
userFileMapper.replaceFilePath(filePath, oldFilePath, userId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IPage<FileListVo> userFileList(Long userId, String filePath, Long currentPage, Long pageCount) {
|
public IPage<FileListVo> userFileList(Long userId, String filePath, Long currentPage, Long pageCount) {
|
||||||
|
@ -6,10 +6,6 @@
|
|||||||
|
|
||||||
<mapper namespace="com.qiwenshare.file.mapper.UserFileMapper">
|
<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">
|
<select id="selectPageVo" parameterType="com.qiwenshare.file.domain.UserFile" resultType="com.qiwenshare.file.vo.file.FileListVo">
|
||||||
|
Loading…
Reference in New Issue
Block a user