上传文件问题bug修复2

door
LI-CCONG\李聪聪 7 months ago
parent 67e66f297f
commit 97f20f244f

@ -74,7 +74,10 @@ public class FileServiceImpl extends ServiceImpl<FileMapper, File> implements IF
* @return File * @return File
*/ */
private File getFileInfoByHashVal(String hashName) { private File getFileInfoByHashVal(String hashName) {
return new LambdaQueryChainWrapper<>(fileMapper).eq(File::getHashVal, hashName).one(); return new LambdaQueryChainWrapper<>(fileMapper)
.eq(File::getHashVal, hashName)
.last("limit 1")
.one();
} }
@Override @Override
@ -146,6 +149,7 @@ public class FileServiceImpl extends ServiceImpl<FileMapper, File> implements IF
// 判断文件来源 // 判断文件来源
String userId = ObjectUtil.isNotEmpty(UserContext.getUser()) ? UserContext.getUser().getId() : ""; String userId = ObjectUtil.isNotEmpty(UserContext.getUser()) ? UserContext.getUser().getId() : "";
Integer source = StrUtil.isNotEmpty(userId) ? 1 : 2; Integer source = StrUtil.isNotEmpty(userId) ? 1 : 2;
if (fileInfo == null) {
// 入库操作 // 入库操作
fileInfo = new File().setUrl(URI) fileInfo = new File().setUrl(URI)
.setFilename(originalName) .setFilename(originalName)
@ -156,6 +160,7 @@ public class FileServiceImpl extends ServiceImpl<FileMapper, File> implements IF
.setCreatorUserId(userId); .setCreatorUserId(userId);
this.save(fileInfo); this.save(fileInfo);
} }
}
return uploadRespVO; return uploadRespVO;
} catch (IOException exception) { } catch (IOException exception) {
throw new BizIllegalException("上传失败"); throw new BizIllegalException("上传失败");

Loading…
Cancel
Save