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 77d4e0b..9092dfa 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,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( <> @@ -28,10 +29,12 @@ function HistoryModal({closeFn, standardCode}){
{history.rvsnYmd.split('T')[0]}
- + {history.docFileGrpId} + {history.docFileGrpId?:''}
- + {history.rvsnFileGrpId} + {history.rvsnFileGrpId?:''}
) 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 f71a4c6..74ec53a 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 @@ -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; } diff --git a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/logs/service/AdminFileService.java b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/logs/service/AdminFileService.java index a3226a7..1b84e11 100644 --- a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/logs/service/AdminFileService.java +++ b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/logs/service/AdminFileService.java @@ -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){ + + } + } diff --git a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/config/security/CustomUrlAuthenticationSuccessHandler.java b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/config/security/CustomUrlAuthenticationSuccessHandler.java index 1d06b0d..bf45b84 100644 --- a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/config/security/CustomUrlAuthenticationSuccessHandler.java +++ b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/config/security/CustomUrlAuthenticationSuccessHandler.java @@ -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)); 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 db4eea9..b202f74 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 @@ -71,6 +71,7 @@ public class SecurityConfig { "/cmm/main/**.do", // 메인페이지 "/cmm/fms/FileDown.do", //파일 다운로드 + "/file/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 4514398..2343c72 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 @@ -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(); + } + } + } } diff --git a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/file/entity/TnAttachFile.java b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/file/entity/TnAttachFile.java index 2909234..1407201 100644 --- a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/file/entity/TnAttachFile.java +++ b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/file/entity/TnAttachFile.java @@ -54,4 +54,7 @@ public class TnAttachFile { @Column(name = "old_seq") private Integer oldSeq; + @Transient + private String kcscCd; + } diff --git a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/file/service/FileService.java b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/file/service/FileService.java index 6efba37..b96b197 100644 --- a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/file/service/FileService.java +++ b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/file/service/FileService.java @@ -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; } }