diff --git a/egovframe-template-simple-react-contribution/src/pages/standardCode/list/HistoryModal.jsx b/egovframe-template-simple-react-contribution/src/pages/standardCode/list/HistoryModal.jsx
index 9092dfa..99cc163 100644
--- a/egovframe-template-simple-react-contribution/src/pages/standardCode/list/HistoryModal.jsx
+++ b/egovframe-template-simple-react-contribution/src/pages/standardCode/list/HistoryModal.jsx
@@ -1,11 +1,14 @@
import React from "react";
-import { SERVER_URL } from 'config';
+import * as File from "utils/file"
import {Button, Modal, Nav} from "react-bootstrap";
function HistoryModal({closeFn, standardCode}){
+ function fileDownloadStandardCode(fileSeq){
+ File.standardCode(fileSeq);
+ }
function fileDownload(fileSeq){
- window.open(encodeURI(SERVER_URL+'/file/download?fileSeq='+fileSeq));
+ File.download(fileSeq);
}
return(
@@ -30,7 +33,7 @@ function HistoryModal({closeFn, standardCode}){
{history.rvsnYmd.split('T')[0]}
{history.docFileGrpId}
- {history.docFileGrpId?:''}
+ {history.docFileGrpId?:''}
{history.rvsnFileGrpId}
diff --git a/egovframe-template-simple-react-contribution/src/utils/file.jsx b/egovframe-template-simple-react-contribution/src/utils/file.jsx
new file mode 100644
index 0000000..413494c
--- /dev/null
+++ b/egovframe-template-simple-react-contribution/src/utils/file.jsx
@@ -0,0 +1,11 @@
+import {SERVER_URL} from "../config";
+import {parseJwt} from "./parseJwt";
+import {getLocalItem} from "./storage";
+
+export function download(fileSeq){
+ window.open(encodeURI(SERVER_URL+'/file/download?fileSeq='+fileSeq));
+}
+export function standardCode(fileSeq){
+ const sessionUser = parseJwt(getLocalItem('accessToken'));
+ window.open(encodeURI(SERVER_URL+'/file/standardCode-download?userId='+sessionUser.id+'&fileSeq='+fileSeq));
+}
diff --git a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/logs/entity/ThAttachFileLog.java b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/logs/entity/ThAttachFileLog.java
index 74ec53a..5dfc362 100644
--- a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/logs/entity/ThAttachFileLog.java
+++ b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/logs/entity/ThAttachFileLog.java
@@ -9,8 +9,6 @@ import org.hibernate.annotations.DynamicUpdate;
import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.*;
-import java.time.LocalDate;
-import java.awt.*;
import java.time.LocalDateTime;
@Getter
diff --git a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/logs/service/AdminLogsService.java b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/logs/service/AdminLogsService.java
index 5ac6529..e4bb26e 100644
--- a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/logs/service/AdminLogsService.java
+++ b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/logs/service/AdminLogsService.java
@@ -1,11 +1,16 @@
package com.dbnt.kcscbackend.admin.logs.service;
+import com.dbnt.kcscbackend.admin.logs.entity.ThAttachFileLog;
import com.dbnt.kcscbackend.admin.logs.entity.ThLoginLog;
import com.dbnt.kcscbackend.admin.logs.entity.ThPrivacyLog;
import com.dbnt.kcscbackend.admin.logs.entity.TnDailyUserLog;
+import com.dbnt.kcscbackend.admin.logs.repository.FileLogsRepository;
import com.dbnt.kcscbackend.admin.logs.repository.PrivacyLogsRepository;
import com.dbnt.kcscbackend.admin.logs.repository.ThLoginLogRepository;
import com.dbnt.kcscbackend.admin.logs.repository.UserLogsRepository;
+import com.dbnt.kcscbackend.file.entity.TnAttachFile;
+import com.dbnt.kcscbackend.standardCode.entity.TnDocumentInfo;
+import com.dbnt.kcscbackend.standardCode.repository.TnDocumentInfoRepository;
import lombok.RequiredArgsConstructor;
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl;
import org.springframework.stereotype.Service;
@@ -24,6 +29,8 @@ public class AdminLogsService extends EgovAbstractServiceImpl {
private final PrivacyLogsRepository privacyLogsRepository;
private final ThLoginLogRepository loginLogRepository;
private final UserLogsRepository userLogsRepository;
+ private final FileLogsRepository fileLogsRepository;
+ private final TnDocumentInfoRepository documentInfoRepository;
public Map selectPrivacyList() {
Map resultMap = new HashMap<>();
@@ -93,4 +100,26 @@ public class AdminLogsService extends EgovAbstractServiceImpl {
}
}
+
+ @Transactional
+ public void insertFileLog(TnAttachFile tnAttachFile, String accessId, String ipAddress){
+ TnDocumentInfo documentInfo = documentInfoRepository.findByDocFileGrpId(tnAttachFile.getFileSeq().toString()).orElse(null);
+ ThAttachFileLog fileLog = new ThAttachFileLog();
+ fileLog.setFileSeq((long)tnAttachFile.getFileSeq());
+ fileLog.setAccessType("FILE_DOWN");
+ fileLog.setAccessId(accessId);
+ fileLog.setAccessDt(LocalDateTime.now());
+ fileLog.setIpAddress(ipAddress);
+ switch (documentInfo.getKcscCd().split(" ")[0]){
+ case "KDS": fileLog.setGroupCurCd("10"); break;
+ case "KCS": fileLog.setGroupCurCd("20"); break;
+ case "SMCS": fileLog.setGroupCurCd("40"); break;
+ case "EXCS": fileLog.setGroupCurCd("50"); break;
+ case "KRCCS": fileLog.setGroupCurCd("60"); break;
+ case "KRACS": fileLog.setGroupCurCd("70"); break;
+ case "LHCS": fileLog.setGroupCurCd("80"); break;
+ case "KWCS": fileLog.setGroupCurCd("90"); break;
+ }
+ fileLogsRepository.save(fileLog);
+ }
}
diff --git a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/config/security/SecurityConfig.java b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/config/security/SecurityConfig.java
index b202f74..85a7126 100644
--- a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/config/security/SecurityConfig.java
+++ b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/config/security/SecurityConfig.java
@@ -72,6 +72,7 @@ public class SecurityConfig {
"/cmm/main/**.do", // 메인페이지
"/cmm/fms/FileDown.do", //파일 다운로드
"/file/download", //파일 다운로드
+ "/file/standardCode-download", //파일 다운로드
"/cmm/fms/getImage.do", //갤러리 이미지보기
"/cop/bbs/selectUserBBSMasterInfAPI.do", //게시판 마스터 상세 조회
diff --git a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/file/FileController.java b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/file/FileController.java
index 2343c72..370dc20 100644
--- a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/file/FileController.java
+++ b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/file/FileController.java
@@ -1,10 +1,13 @@
package com.dbnt.kcscbackend.file;
+import com.dbnt.kcscbackend.admin.logs.service.AdminLogsService;
+import com.dbnt.kcscbackend.auth.entity.LoginVO;
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.security.core.annotation.AuthenticationPrincipal;
import org.springframework.util.FileCopyUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@@ -20,37 +23,22 @@ import java.io.*;
public class FileController {
private final FileService fileService;
- private final StandardCodeService standardCodeService;
+ private final AdminLogsService adminLogsService;
@RequestMapping(method = RequestMethod.GET, value = "/download")
public void download(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();
- }
- }
+ fileDownload(request, response, tnAttachFile);
}
- @RequestMapping(method = RequestMethod.GET, value = "/standardCode/download")
- public void standardCodeDownload(HttpServletRequest request, HttpServletResponse response, TnAttachFile tnAttachFile) throws Exception{
-
+ @RequestMapping(method = RequestMethod.GET, value = "/standardCode-download")
+ public void standardCodeDownload(HttpServletRequest request, HttpServletResponse response, TnAttachFile tnAttachFile, String userId) throws Exception{
tnAttachFile = fileService.selectTnAttachFile(tnAttachFile);
+ adminLogsService.insertFileLog(tnAttachFile, userId, ClientUtils.getRemoteIP(request));
+ fileDownload(request, response, tnAttachFile);
+ }
+ private void fileDownload(HttpServletRequest request, HttpServletResponse response, TnAttachFile tnAttachFile){
if(tnAttachFile != null){
BufferedInputStream in;
BufferedOutputStream out;
diff --git a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/standardCode/entity/TnDocumentInfo.java b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/standardCode/entity/TnDocumentInfo.java
index 8acc2d3..53c6358 100644
--- a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/standardCode/entity/TnDocumentInfo.java
+++ b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/standardCode/entity/TnDocumentInfo.java
@@ -1,7 +1,6 @@
package com.dbnt.kcscbackend.standardCode.entity;
import com.fasterxml.jackson.annotation.JsonIgnore;
-import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@@ -22,9 +21,9 @@ public class TnDocumentInfo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "doc_info_seq")
- private int docInfoSeq;
+ private Integer docInfoSeq;
@Column(name = "group_seq", nullable = false)
- private int groupSeq;
+ private Integer groupSeq;
@Column(name = "kcsc_cd")
private String kcscCd;
@Column(name = "old_kcsc_cd")
@@ -34,7 +33,7 @@ public class TnDocumentInfo {
@Column(name = "doc_yr", nullable = false)
private String docYr;
@Column(name = "doc_cycl", nullable = false)
- private int docCycl;
+ private Integer docCycl;
@Column(name = "doc_er", nullable = false)
private String docEr;
@Column(name = "estb_ymd")
@@ -44,7 +43,7 @@ public class TnDocumentInfo {
@Temporal(TemporalType.DATE)
private Date rvsnYmd;
@Column(name = "doc_rev_hist_seq")
- private int docRevHistSeq;
+ private Integer docRevHistSeq;
@Column(name = "doc_brief", length = 1000)
private String docBrief;
@Column(name = "doc_rvsn_remark", length = 1000)
@@ -66,7 +65,7 @@ public class TnDocumentInfo {
@Temporal(TemporalType.DATE)
private Date aplcnEndYmd;
@Column(name = "doc_order", nullable = false)
- private int docOrder;
+ private Integer docOrder;
@Column(name = "last_yn", nullable = false)
private char lastYn;
@Column(name = "doc_file_grp_id")
diff --git a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/standardCode/repository/TnDocumentInfoRepository.java b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/standardCode/repository/TnDocumentInfoRepository.java
index 1ab2c1a..3f1050f 100644
--- a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/standardCode/repository/TnDocumentInfoRepository.java
+++ b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/standardCode/repository/TnDocumentInfoRepository.java
@@ -6,8 +6,11 @@ import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
+import java.util.Optional;
public interface TnDocumentInfoRepository extends JpaRepository {
@Query(value = "select * from sp_get_tn_document_info_by_group_cd(null, :docCode)", nativeQuery = true)
List spGetTnDocumentInfoByGroupCd(String docCode);
+
+ Optional findByDocFileGrpId(String fileSeq);
}