提交 48979a78 authored 作者: zhangshuang's avatar zhangshuang

文件下载次数修改

上级 a671bad6
......@@ -20,7 +20,7 @@ import javax.persistence.Id;
@ApiModel(value = "FileSave",description = "将文件信息存储在数据库中")
public class FileSave {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@GeneratedValue(strategy = GenerationType.IDENTITY)
@ApiModelProperty(name = "id",value = "文件id",notes = "文件id",example = "1")
private Integer id;//文件id
@ApiModelProperty(name = "realName",value = "文件真正存储名称",notes = "文件真正存储名称",example = "1(1).zip")
......
......@@ -18,16 +18,19 @@ public class DownLoadServiceImpl implements DownLoadService {
@Override
public List<DownLoadCount> findCount(DownLoadRequest downLoadRequest) {
List<Integer> fileIdList = downLoadRequest.getFileIds();//请求的id集合
List<DownLoadCount> loadCounts = new ArrayList<>();
if(!downLoadRequest.getUserId().isEmpty()){
List<Integer> fileIdList = downLoadRequest.getFileIds();//请求的id集合
if(fileIdList != null && fileIdList.size() != 0){
loadCounts = downLoadCountDao.findCount(downLoadRequest.getUserId(),fileIdList);
//如果传入的文件id不存在,视为没有下载过的查询,下载过的次数为0
if(loadCounts.size() != fileIdList.size()){
//没有文件id
List<Integer> idList = new ArrayList<>();//数据库id集合
for(DownLoadCount downLoadCount:loadCounts){
idList.add(downLoadCount.getFileId());
}
//将不存在的文件下载次数设置为0
for(Integer i:fileIdList){
if(!idList.contains(i)){
DownLoadCount downLoadCount = new DownLoadCount();
......@@ -39,6 +42,7 @@ public class DownLoadServiceImpl implements DownLoadService {
}
}
}
}
return loadCounts;
}
......
......@@ -71,7 +71,8 @@ public class FileDownLoadServiceImpl implements FileDownLoadService {
log.error(file.getAbsolutePath() + "文件不存在");
e.printStackTrace();
} catch (IOException e) {
log.error(file.getAbsolutePath() + "文件读取异常");
//log.error(file.getAbsolutePath() + "文件读取异常");
log.error(file.getAbsolutePath() + "文件用户终止下载");
e.printStackTrace();
} finally {
try {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论