提交 2574c38c authored 作者: zhangshuang's avatar zhangshuang

文件下载次数

上级 2089e223
...@@ -2,11 +2,15 @@ package com.zjty.efs.ftp.service.impl; ...@@ -2,11 +2,15 @@ package com.zjty.efs.ftp.service.impl;
import com.zjty.efs.ftp.base.response.ServerResponse; import com.zjty.efs.ftp.base.response.ServerResponse;
import com.zjty.efs.ftp.dao.DownLoadCountDao; import com.zjty.efs.ftp.dao.DownLoadCountDao;
import com.zjty.efs.ftp.entity.DownLoadCount;
import com.zjty.efs.ftp.entity.DownLoadRequest; import com.zjty.efs.ftp.entity.DownLoadRequest;
import com.zjty.efs.ftp.service.DownLoadService; import com.zjty.efs.ftp.service.DownLoadService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@Service @Service
public class DownLoadServiceImpl implements DownLoadService { public class DownLoadServiceImpl implements DownLoadService {
@Autowired @Autowired
...@@ -14,6 +18,27 @@ public class DownLoadServiceImpl implements DownLoadService { ...@@ -14,6 +18,27 @@ public class DownLoadServiceImpl implements DownLoadService {
@Override @Override
public ServerResponse findCount(DownLoadRequest downLoadRequest) { public ServerResponse findCount(DownLoadRequest downLoadRequest) {
return ServerResponse.saveSuccess(downLoadCountDao.findCount(downLoadRequest.getUserId(),downLoadRequest.getFileIds())); List<Integer> fileIdList = downLoadRequest.getFileIds();//请求的id集合
List<DownLoadCount> loadCounts = new ArrayList<>();
if(fileIdList != null && fileIdList.size() != 0){
loadCounts = downLoadCountDao.findCount(downLoadRequest.getUserId(),fileIdList);
if(loadCounts.size() != fileIdList.size()){
//没有文件id
List<Integer> idList = new ArrayList<>();//数据库id集合
for(DownLoadCount downLoadCount:loadCounts){
idList.add(downLoadCount.getFileId());
}
for(Integer i:fileIdList){
if(!idList.contains(i)){
DownLoadCount downLoadCount = new DownLoadCount();
downLoadCount.setUserId(downLoadRequest.getUserId());
downLoadCount.setFileId(i);
downLoadCount.setCount(0);
loadCounts.add(downLoadCount);
}
}
}
}
return ServerResponse.success(loadCounts);
} }
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论