다운로드시 이력 생성 추가.

master
강석 최 2021-12-16 17:42:32 +09:00
parent 8457e3343d
commit 5c236aea6c
2 changed files with 11 additions and 8 deletions

View File

@ -78,8 +78,8 @@ public class BoardController {
}
@GetMapping("/fileDownload")
public void fileDownload(Integer contentSeq, Integer fileSeq, HttpServletRequest request, HttpServletResponse response){
FileInfo downlodFileInfo = boardService.selectDownloadFileInfo(contentSeq, fileSeq);
public void fileDownload(Principal principal, Integer contentSeq, Integer fileSeq, HttpServletRequest request, HttpServletResponse response){
FileInfo downlodFileInfo = boardService.selectDownloadFileInfo(contentSeq, fileSeq, ((UserInfo)((UsernamePasswordAuthenticationToken) principal).getPrincipal()).getUserId());
BufferedInputStream in;
BufferedOutputStream out;
@ -98,8 +98,8 @@ public class BoardController {
}
@GetMapping("/fileDownloadToZip")
public void fileDownloadToZip(Integer contentSeq, @RequestParam(value = "fileSeq") List<Integer> fileSeqList, HttpServletResponse response){
List<FileInfo> targetList = boardService.selectDownloadFileInfoList(contentSeq, fileSeqList);
public void fileDownloadToZip(Principal principal, Integer contentSeq, @RequestParam(value = "fileSeq") List<Integer> fileSeqList, HttpServletResponse response){
List<FileInfo> targetList = boardService.selectDownloadFileInfoList(contentSeq, fileSeqList, ((UserInfo)((UsernamePasswordAuthenticationToken) principal).getPrincipal()).getUserId());
BufferedInputStream in;
BufferedOutputStream out;

View File

@ -104,7 +104,7 @@ public class BoardService {
fileInfo.setFileSize(calculationFileSize(file.getSize()));
fileInfo.setSavePath(path);
fileInfoRepository.save(fileInfo);
saveBoardLog(content.getContentSeq(), LogStatus.FILE_ADD, file.getOriginalFilename(), content.getCreateId());
saveBoardLog(content.getContentSeq(), LogStatus.FILE_ADD, fileInfo.getFullName(), content.getCreateId());
}
}
@ -130,18 +130,21 @@ public class BoardService {
return target;
}
public List<FileInfo> selectDownloadFileInfoList(Integer contentSeq, List<Integer> fileSeqList) {
public List<FileInfo> selectDownloadFileInfoList(Integer contentSeq, List<Integer> fileSeqList, String userId) {
List<FileInfo> fileList = fileInfoRepository.findByContentSeqOrderByFileSeqAsc(contentSeq);
List<FileInfo> targetList = new ArrayList<>();
for(FileInfo file: fileList){
if(fileSeqList.contains(file.getFileSeq())){
targetList.add(file);
saveBoardLog(contentSeq, LogStatus.FILE_DOWN, file.getFullName(), userId);
}
}
return targetList;
}
public FileInfo selectDownloadFileInfo(Integer contestSeq, Integer fileSeq){
return fileInfoRepository.findById(new FileInfo.FileInfoId(contestSeq, fileSeq)).orElse(null);
public FileInfo selectDownloadFileInfo(Integer contestSeq, Integer fileSeq, String userId){
FileInfo fileInfo = fileInfoRepository.findById(new FileInfo.FileInfoId(contestSeq, fileSeq)).orElse(null);
saveBoardLog(contestSeq, LogStatus.FILE_DOWN, fileInfo.getFullName(), userId);
return fileInfo;
}
public List<BoardLog> selectContentLog(Integer contentSeq){