파일 다운로드 이력생성 작업중.

thkim
강석 최 2024-02-29 18:04:28 +09:00
parent 3ba58816e8
commit 1857be50ee
8 changed files with 76 additions and 17 deletions

View File

@ -1,12 +1,13 @@
import React, {useEffect, useState} from "react";
import React from "react";
import { SERVER_URL } from 'config';
import {Button, Modal, Nav} from "react-bootstrap";
import Col from "react-bootstrap/Col";
import Row from "react-bootstrap/Row";
import * as EgovNet from "api/egovFetch";
function HistoryModal({closeFn, standardCode}){
function fileDownload(fileSeq){
window.open(encodeURI(SERVER_URL+'/file/download?fileSeq='+fileSeq));
}
return(
<>
<Modal.Header closeButton>
@ -28,10 +29,12 @@ function HistoryModal({closeFn, standardCode}){
<div className="list_item">
<div className="mainCategory">{history.rvsnYmd.split('T')[0]}</div>
<div className="middleCategory">
<Button size={"sm"} variant={"outline-secondary"}>다운로드</Button>
{history.docFileGrpId}
{history.docFileGrpId?<Button size={"sm"} variant={"outline-secondary"} onClick={()=>fileDownload(history.docFileGrpId)}>다운로드 </Button>:''}
</div>
<div className="kcscCd">
<Button size={"sm"} variant={"outline-secondary"}>다운로드</Button>
{history.rvsnFileGrpId}
{history.rvsnFileGrpId?<Button size={"sm"} variant={"outline-secondary"} onClick={()=>fileDownload(history.rvsnFileGrpId)}>다운로드 </Button>:''}
</div>
</div>
)

View File

@ -11,6 +11,7 @@ import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.*;
import java.time.LocalDate;
import java.awt.*;
import java.time.LocalDateTime;
@Getter
@Setter
@ -22,13 +23,26 @@ import java.awt.*;
@Table(name = "th_attach_file_log")
public class ThAttachFileLog {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "file_log_seq")
private Long fileLogSeq;
@Column(name = "file_seq")
private Long fileSeq;
@Column(name = "access_type")
private Long accessType;
private String accessType;
@Column(name = "access_id")
private String accessId;
@Column(name = "access_dt")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate accessDt;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime accessDt;
@Column(name = "ip_address")
private String ipAddress;
@Column(name = "group_cur_cd")
private String groupCurCd;
}

View File

@ -4,6 +4,7 @@ import com.dbnt.kcscbackend.admin.logs.repository.FileLogsRepository;
import lombok.RequiredArgsConstructor;
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@ -22,4 +23,9 @@ public class AdminFileService extends EgovAbstractServiceImpl {
return fileLogsRepository.countDistinctFileIds(startDate, endDate);
}
@Transactional
public void updateDownloadCnt(String accessId, String ipAddress, String groupCurCd){
}
}

View File

@ -72,16 +72,18 @@ public class CustomUrlAuthenticationSuccessHandler extends SimpleUrlAuthenticati
resultMap.put("resultCode", ResponseCode.SUCCESS.getCode());
resultMap.put("accessToken", accessToken);
resultMap.put("refreshToken", refreshToken);
//로그인 로그 기록
adminLogsService.insertLoginLog(securityUser.getUserId(), accessIp, accessToken, "Y", ClientUtils.getWebType(request));
}
/*
// 로그인 제한 해제시 주석 해제 및 위 if문 주석처리 할 것.
String accessToken = jwtTokenUtil.generateAccessToken(securityUser, request.getRemoteAddr());
String refreshToken = jwtTokenUtil.generateRefreshTokenToken(securityUser, request.getRemoteAddr());
resultMap.put("resultCode", ResponseCode.SUCCESS.getCode());
resultMap.put("accessToken", accessToken);
resultMap.put("refreshToken", refreshToken);
//로그인 로그 기록
adminLogsService.insertLoginLog(securityUser.getUserId(), accessIp, accessToken, "Y", ClientUtils.getWebType(request));
*/
if (jsonConverter.canWrite(resultMap.getClass(), jsonMimeType)) {
jsonConverter.write(resultMap, jsonMimeType, new ServletServerHttpResponse(response));

View File

@ -71,6 +71,7 @@ public class SecurityConfig {
"/cmm/main/**.do", // 메인페이지
"/cmm/fms/FileDown.do", //파일 다운로드
"/file/download", //파일 다운로드
"/cmm/fms/getImage.do", //갤러리 이미지보기
"/cop/bbs/selectUserBBSMasterInfAPI.do", //게시판 마스터 상세 조회

View File

@ -3,6 +3,7 @@ package com.dbnt.kcscbackend.file;
import com.dbnt.kcscbackend.config.util.ClientUtils;
import com.dbnt.kcscbackend.file.entity.TnAttachFile;
import com.dbnt.kcscbackend.file.service.FileService;
import com.dbnt.kcscbackend.standardCode.service.StandardCodeService;
import lombok.RequiredArgsConstructor;
import org.springframework.util.FileCopyUtils;
import org.springframework.web.bind.annotation.RequestMapping;
@ -19,6 +20,7 @@ import java.io.*;
public class FileController {
private final FileService fileService;
private final StandardCodeService standardCodeService;
@RequestMapping(method = RequestMethod.GET, value = "/download")
public void download(HttpServletRequest request, HttpServletResponse response, TnAttachFile tnAttachFile) throws Exception{
@ -43,4 +45,28 @@ public class FileController {
}
}
}
@RequestMapping(method = RequestMethod.GET, value = "/standardCode/download")
public void standardCodeDownload(HttpServletRequest request, HttpServletResponse response, TnAttachFile tnAttachFile) throws Exception{
tnAttachFile = fileService.selectTnAttachFile(tnAttachFile);
if(tnAttachFile != null){
BufferedInputStream in;
BufferedOutputStream out;
try {
File file = new File(tnAttachFile.getFilePath());
ClientUtils.setDisposition(tnAttachFile.getFileOldName(), request, response);
in = new BufferedInputStream(new FileInputStream(file));
out = new BufferedOutputStream(response.getOutputStream());
FileCopyUtils.copy(in, out);
out.flush();
if(out!=null) out.close();
if(in!=null )in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}

View File

@ -54,4 +54,7 @@ public class TnAttachFile {
@Column(name = "old_seq")
private Integer oldSeq;
@Transient
private String kcscCd;
}

View File

@ -4,6 +4,7 @@ import com.dbnt.kcscbackend.file.entity.TnAttachFile;
import com.dbnt.kcscbackend.file.repository.TnAttachFileRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
@RequiredArgsConstructor
@ -11,13 +12,16 @@ public class FileService {
private final TnAttachFileRepository tnAttachFileRepository;
@Transactional
public TnAttachFile selectTnAttachFile(TnAttachFile tnAttachFile) {
if(tnAttachFile.getFileSeq()!=null){
return tnAttachFileRepository.findById(tnAttachFile.getFileSeq()).orElse(null);
tnAttachFile = tnAttachFileRepository.findById(tnAttachFile.getFileSeq()).orElse(null);
}else{
return tnAttachFileRepository.findByFileGrpId(tnAttachFile.getFileGrpId()).orElse(null);
tnAttachFile = tnAttachFileRepository.findByFileGrpId(tnAttachFile.getFileGrpId()).orElse(null);
}
int downCnt = tnAttachFile.getDownCnt()==null?0: tnAttachFile.getDownCnt();
tnAttachFile.setDownCnt(downCnt+1);
tnAttachFileRepository.save(tnAttachFile);
return tnAttachFile;
}
}