移动文件区分用户
This commit is contained in:
parent
fb01636722
commit
e165b3d5cc
@ -13,7 +13,7 @@ public interface IUserFileService extends IService<UserFile> {
|
||||
List<UserFile> selectUserFileByNameAndPath(String fileName, String filePath, Long userId);
|
||||
void replaceUserFilePath(String filePath, String oldFilePath, Long userId);
|
||||
List<FileListVo> userFileList(UserFile userFile, Long beginCount, Long pageCount);
|
||||
void updateFilepathByFilepath(String oldfilePath, String newfilePath, String fileName, String extendName);
|
||||
void updateFilepathByFilepath(String oldfilePath, String newfilePath, String fileName, String extendName, long userId);
|
||||
|
||||
List<FileListVo> selectFileByExtendName(List<String> fileNameList, Long beginCount, Long pageCount, long userId);
|
||||
Long selectCountByExtendName(List<String> fileNameList, Long beginCount, Long pageCount, long userId);
|
||||
|
@ -394,12 +394,14 @@ public class FileController {
|
||||
if (!operationCheck(token).getSuccess()){
|
||||
return operationCheck(token);
|
||||
}
|
||||
|
||||
UserBean sessionUserBean = userService.getUserBeanByToken(token);
|
||||
String oldfilePath = moveFileDto.getOldFilePath();
|
||||
String newfilePath = moveFileDto.getFilePath();
|
||||
String fileName = moveFileDto.getFileName();
|
||||
String extendName = moveFileDto.getExtendName();
|
||||
|
||||
userFileService.updateFilepathByFilepath(oldfilePath, newfilePath, fileName, extendName);
|
||||
userFileService.updateFilepathByFilepath(oldfilePath, newfilePath, fileName, extendName, sessionUserBean.getUserId());
|
||||
return RestResult.success();
|
||||
|
||||
}
|
||||
@ -413,6 +415,7 @@ public class FileController {
|
||||
if (!operationCheck(token).getSuccess()) {
|
||||
return operationCheck(token);
|
||||
}
|
||||
UserBean sessionUserBean = userService.getUserBeanByToken(token);
|
||||
|
||||
String files = batchMoveFileDto.getFiles();
|
||||
String newfilePath = batchMoveFileDto.getFilePath();
|
||||
@ -420,7 +423,7 @@ public class FileController {
|
||||
List<UserFile> fileList = JSON.parseArray(files, UserFile.class);
|
||||
|
||||
for (UserFile userFile : fileList) {
|
||||
userFileService.updateFilepathByFilepath(userFile.getFilePath(), newfilePath, userFile.getFileName(), userFile.getExtendName());
|
||||
userFileService.updateFilepathByFilepath(userFile.getFilePath(), newfilePath, userFile.getFileName(), userFile.getExtendName(), sessionUserBean.getUserId());
|
||||
}
|
||||
|
||||
return RestResult.success().data("批量移动文件成功");
|
||||
|
@ -14,12 +14,12 @@ public interface UserFileMapper extends BaseMapper<UserFile> {
|
||||
void replaceFilePath(@Param("filePath") String filePath, @Param("oldFilePath") String oldFilePath, @Param("userId") Long userId);
|
||||
List<FileListVo> userFileList(UserFile userFile, Long beginCount, Long pageCount);
|
||||
|
||||
void updateFilepathByPathAndName(String oldfilePath, String newfilePath, String fileName, String extendName);
|
||||
void updateFilepathByFilepath(String oldfilePath, String newfilePath);
|
||||
void updateFilepathByPathAndName(String oldfilePath, String newfilePath, String fileName, String extendName, long userId);
|
||||
void updateFilepathByFilepath(String oldfilePath, String newfilePath, long userId);
|
||||
|
||||
List<FileListVo> selectFileByExtendName(List<String> fileNameList, Long beginCount, Long pageCount, long userId);
|
||||
Long selectCountByExtendName(List<String> fileNameList, Long beginCount, Long pageCount, long userId);
|
||||
List<FileListVo> selectFileNotInExtendNames(List<String> fileNameList, Long beginCount, Long pageCount, long userId);
|
||||
Long selectCountNotInExtendNames(List<String> fileNameList, Long beginCount, Long pageCount, long userId);
|
||||
Long selectStorageSizeByUserId(Long userId);
|
||||
Long selectStorageSizeByUserId(@Param("userId") Long userId);
|
||||
}
|
||||
|
@ -108,12 +108,12 @@ public class UserFileService extends ServiceImpl<UserFileMapper, UserFile> impl
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void updateFilepathByFilepath(String oldfilePath, String newfilePath, String fileName, String extendName) {
|
||||
public void updateFilepathByFilepath(String oldfilePath, String newfilePath, String fileName, String extendName, long userId) {
|
||||
if ("null".equals(extendName)){
|
||||
extendName = null;
|
||||
}
|
||||
//移动根目录
|
||||
userFileMapper.updateFilepathByPathAndName(oldfilePath, newfilePath, fileName, extendName);
|
||||
userFileMapper.updateFilepathByPathAndName(oldfilePath, newfilePath, fileName, extendName, userId);
|
||||
|
||||
//移动子目录
|
||||
oldfilePath = oldfilePath + fileName + "/";
|
||||
@ -125,7 +125,7 @@ public class UserFileService extends ServiceImpl<UserFileMapper, UserFile> impl
|
||||
oldfilePath = oldfilePath.replace("_", "\\_");
|
||||
|
||||
if (extendName == null) { //为null说明是目录,则需要移动子目录
|
||||
userFileMapper.updateFilepathByFilepath(oldfilePath, newfilePath);
|
||||
userFileMapper.updateFilepathByFilepath(oldfilePath, newfilePath, userId);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -73,7 +73,7 @@
|
||||
|
||||
<update id="updateFilepathByFilepath">
|
||||
UPDATE userfile SET filePath=REPLACE(filePath, #{param1}, #{param2})
|
||||
WHERE filePath like N'${param1}%'
|
||||
WHERE filePath like N'${param1}%' and userId = #{param3}
|
||||
</update>
|
||||
|
||||
<update id="updateFilepathByPathAndName">
|
||||
@ -85,12 +85,13 @@
|
||||
<if test="param4 == null">
|
||||
and extendName is null
|
||||
</if>
|
||||
and userId = #{param5}
|
||||
</update>
|
||||
|
||||
<select id="selectStorageSizeByUserId" resultType="java.lang.Long" parameterType="java.lang.Long">
|
||||
SELECT SUM(fileSize) FROM userfile
|
||||
LEFT JOIN file ON file.fileId = userfile.fileId
|
||||
WHERE userfile.userId = 2
|
||||
WHERE userfile.userId = #{userId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user