no message

thkim
강석 최 2024-03-04 15:08:00 +09:00
parent 2c7604f3fa
commit 3079a00832
8 changed files with 66 additions and 34 deletions

View File

@ -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}){
<div className="mainCategory">{history.rvsnYmd.split('T')[0]}</div>
<div className="middleCategory">
{history.docFileGrpId}
{history.docFileGrpId?<Button size={"sm"} variant={"outline-secondary"} onClick={()=>fileDownload(history.docFileGrpId)}>다운로드 </Button>:''}
{history.docFileGrpId?<Button size={"sm"} variant={"outline-secondary"} onClick={()=>fileDownloadStandardCode(history.docFileGrpId)}>다운로드 </Button>:''}
</div>
<div className="kcscCd">
{history.rvsnFileGrpId}

View File

@ -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));
}

View File

@ -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

View File

@ -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<String, Object> selectPrivacyList() {
Map<String, Object> 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);
}
}

View File

@ -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", //게시판 마스터 상세 조회

View File

@ -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;

View File

@ -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")

View File

@ -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<TnDocumentInfo, Integer> {
@Query(value = "select * from sp_get_tn_document_info_by_group_cd(null, :docCode)", nativeQuery = true)
List<TnDocumentInfoInterface> spGetTnDocumentInfoByGroupCd(String docCode);
Optional<TnDocumentInfo> findByDocFileGrpId(String fileSeq);
}