feat: 관리자 - 사이트관리 > 컨텐츠관리 > 팝업 관리 첨부파일 구현 건
parent
5fc1e01f57
commit
b8136827fd
|
|
@ -1,14 +1,9 @@
|
||||||
package com.dbnt.kcscbackend.admin.contents.popUp.controller;
|
package com.dbnt.kcscbackend.admin.contents.popUp.controller;
|
||||||
|
|
||||||
|
|
||||||
import com.dbnt.kcscbackend.admin.committee.schedules.model.CreateScheduleVO;
|
|
||||||
import com.dbnt.kcscbackend.admin.committee.schedules.model.UpdateScheduleVO;
|
|
||||||
import com.dbnt.kcscbackend.admin.committee.schedules.service.EgovIndvdlSchdulManageService;
|
|
||||||
import com.dbnt.kcscbackend.admin.contents.popUp.model.CreatePopupVO;
|
import com.dbnt.kcscbackend.admin.contents.popUp.model.CreatePopupVO;
|
||||||
import com.dbnt.kcscbackend.admin.contents.popUp.model.FileVO;
|
|
||||||
import com.dbnt.kcscbackend.admin.contents.popUp.model.UpdatePopupVO;
|
import com.dbnt.kcscbackend.admin.contents.popUp.model.UpdatePopupVO;
|
||||||
import com.dbnt.kcscbackend.admin.contents.popUp.service.PopUpApiService;
|
import com.dbnt.kcscbackend.admin.contents.popUp.service.PopUpApiService;
|
||||||
import com.dbnt.kcscbackend.admin.contents.popUp.utils.EgovFileMngUtil;
|
|
||||||
import com.dbnt.kcscbackend.auth.entity.LoginVO;
|
import com.dbnt.kcscbackend.auth.entity.LoginVO;
|
||||||
import com.dbnt.kcscbackend.config.common.ResponseCode;
|
import com.dbnt.kcscbackend.config.common.ResponseCode;
|
||||||
import com.dbnt.kcscbackend.config.common.ResultVO;
|
import com.dbnt.kcscbackend.config.common.ResultVO;
|
||||||
|
|
@ -26,8 +21,7 @@ import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.util.List;
|
import java.util.Enumeration;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
|
|
||||||
@Api("PopUpApiController")
|
@Api("PopUpApiController")
|
||||||
|
|
@ -38,8 +32,6 @@ public class PopUpApiController {
|
||||||
@Resource(name = "popUpApiService")
|
@Resource(name = "popUpApiService")
|
||||||
private PopUpApiService popUpApiService;
|
private PopUpApiService popUpApiService;
|
||||||
|
|
||||||
@Resource(name = "EgovFileMngUtil")
|
|
||||||
private EgovFileMngUtil fileUtil;
|
|
||||||
|
|
||||||
@Operation(
|
@Operation(
|
||||||
summary = "'팝업 관리' 페이지에서 목록 불러오는 API",
|
summary = "'팝업 관리' 페이지에서 목록 불러오는 API",
|
||||||
|
|
@ -95,13 +87,14 @@ public class PopUpApiController {
|
||||||
HttpServletRequest request,
|
HttpServletRequest request,
|
||||||
@AuthenticationPrincipal LoginVO loginVO,
|
@AuthenticationPrincipal LoginVO loginVO,
|
||||||
final MultipartHttpServletRequest multiRequest,
|
final MultipartHttpServletRequest multiRequest,
|
||||||
CreatePopupVO createPopupVO
|
CreatePopupVO createPopupVO,
|
||||||
|
@RequestParam(required = false) MultipartFile file
|
||||||
) throws Exception {
|
) throws Exception {
|
||||||
|
|
||||||
ResultVO resultVO = new ResultVO();
|
ResultVO resultVO = new ResultVO();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
resultVO = popUpApiService.contentsApiPopUpManageCreate(resultVO, request, loginVO, multiRequest, createPopupVO);
|
resultVO = popUpApiService.contentsApiPopUpManageCreate(resultVO, request, loginVO, multiRequest, createPopupVO, file);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
resultVO.setResultCode(ResponseCode.FAILED.getCode());
|
resultVO.setResultCode(ResponseCode.FAILED.getCode());
|
||||||
resultVO.setResultMessage(e.getMessage());
|
resultVO.setResultMessage(e.getMessage());
|
||||||
|
|
@ -136,13 +129,14 @@ public class PopUpApiController {
|
||||||
HttpServletRequest request,
|
HttpServletRequest request,
|
||||||
@AuthenticationPrincipal LoginVO loginVO,
|
@AuthenticationPrincipal LoginVO loginVO,
|
||||||
UpdatePopupVO updatePopupVO,
|
UpdatePopupVO updatePopupVO,
|
||||||
|
@RequestParam(required = false) MultipartFile file,
|
||||||
@PathVariable("popupId") Long popupId
|
@PathVariable("popupId") Long popupId
|
||||||
) throws Exception {
|
) throws Exception {
|
||||||
|
|
||||||
ResultVO resultVO = new ResultVO();
|
ResultVO resultVO = new ResultVO();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
resultVO = popUpApiService.contentsApiPopUpManageUpdate(resultVO, request, loginVO, updatePopupVO, popupId);
|
resultVO = popUpApiService.contentsApiPopUpManageUpdate(resultVO, request, loginVO, updatePopupVO, file, popupId);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
resultVO.setResultCode(ResponseCode.FAILED.getCode());
|
resultVO.setResultCode(ResponseCode.FAILED.getCode());
|
||||||
resultVO.setResultMessage(e.getMessage());
|
resultVO.setResultMessage(e.getMessage());
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,10 @@ import lombok.Getter;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
@ApiModel(value = "CreatePopupVO", description =
|
@ApiModel(value = "CreatePopupVO", description =
|
||||||
"관리자 단에서 '컨텐츠 관리' > '팝업 관리' 페이지에서 팝업을 추가하는 API에 사용된다." + ""
|
"관리자 단에서 '컨텐츠 관리' > '팝업 관리' 페이지에서 팝업을 추가하는 API에 사용된다." + ""
|
||||||
|
|
@ -28,4 +30,6 @@ public class CreatePopupVO implements Serializable {
|
||||||
private String title;
|
private String title;
|
||||||
@ApiModelProperty(value = "contents")
|
@ApiModelProperty(value = "contents")
|
||||||
private String contents;
|
private String contents;
|
||||||
|
//@ApiModelProperty(value = "file")
|
||||||
|
//private MultipartFile file;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ import java.io.Serializable;
|
||||||
@ApiModel(value = "UpdatePopupVO", description =
|
@ApiModel(value = "UpdatePopupVO", description =
|
||||||
"관리자 단에서 '컨텐츠 관리' > '팝업 관리' 페이지에서 팝업을 수정하는 API에 사용된다." + ""
|
"관리자 단에서 '컨텐츠 관리' > '팝업 관리' 페이지에서 팝업을 수정하는 API에 사용된다." + ""
|
||||||
)
|
)
|
||||||
@RequiredArgsConstructor
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@ToString
|
@ToString
|
||||||
|
|
|
||||||
|
|
@ -9,15 +9,16 @@ import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
public interface PopUpApiService {
|
public interface PopUpApiService {
|
||||||
public ResultVO contentsApiPopUpManageList(ResultVO resultVO, HttpServletRequest request, LoginVO user, Pageable pageable) throws Exception;
|
public ResultVO contentsApiPopUpManageList(ResultVO resultVO, HttpServletRequest request, LoginVO user, Pageable pageable) throws Exception;
|
||||||
public ResultVO contentsApiPopUpManageCreate(ResultVO resultVO, HttpServletRequest request, LoginVO user, final MultipartHttpServletRequest multiRequest, CreatePopupVO createPopupVO) throws Exception;
|
public ResultVO contentsApiPopUpManageCreate(ResultVO resultVO, HttpServletRequest request, LoginVO user, final MultipartHttpServletRequest multiRequest, CreatePopupVO createPopupVO, MultipartFile file) throws Exception;
|
||||||
public ResultVO contentsApiPopUpManageRead(ResultVO resultVO, HttpServletRequest request, LoginVO user, Long popupId) throws Exception;
|
public ResultVO contentsApiPopUpManageRead(ResultVO resultVO, HttpServletRequest request, LoginVO user, Long popupId) throws Exception;
|
||||||
public ResultVO contentsApiPopUpManageUpdate(ResultVO resultVO, HttpServletRequest request, LoginVO user, UpdatePopupVO updatePopupVO, Long popupId) throws Exception;
|
public ResultVO contentsApiPopUpManageUpdate(ResultVO resultVO, HttpServletRequest request, LoginVO user, UpdatePopupVO updatePopupVO, MultipartFile file, Long popupId) throws Exception;
|
||||||
public ResultVO contentsApiPopUpManageDelete(ResultVO resultVO, HttpServletRequest request, LoginVO user, Long popupId) throws Exception;
|
public ResultVO contentsApiPopUpManageDelete(ResultVO resultVO, HttpServletRequest request, LoginVO user, Long popupId) throws Exception;
|
||||||
public ResultVO contentsApiPopUpManageUpdateActivationSwitch(ResultVO resultVO, HttpServletRequest request, LoginVO user, String checked, Long popupId) throws Exception;
|
public ResultVO contentsApiPopUpManageUpdateActivationSwitch(ResultVO resultVO, HttpServletRequest request, LoginVO user, String checked, Long popupId) throws Exception;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,15 @@ import com.dbnt.kcscbackend.admin.contents.popUp.model.FileVO;
|
||||||
import com.dbnt.kcscbackend.admin.contents.popUp.model.UpdatePopupVO;
|
import com.dbnt.kcscbackend.admin.contents.popUp.model.UpdatePopupVO;
|
||||||
import com.dbnt.kcscbackend.admin.contents.popUp.repository.TnPopupMngRepositoryWithoutPopupContents;
|
import com.dbnt.kcscbackend.admin.contents.popUp.repository.TnPopupMngRepositoryWithoutPopupContents;
|
||||||
import com.dbnt.kcscbackend.admin.contents.popUp.service.PopUpApiService;
|
import com.dbnt.kcscbackend.admin.contents.popUp.service.PopUpApiService;
|
||||||
|
import com.dbnt.kcscbackend.file.entity.TnAttachFile;
|
||||||
|
import com.dbnt.kcscbackend.file.repository.TnAttachFileRepository;
|
||||||
|
import com.dbnt.kcscbackend.file.service.EgovFileMngUtil;
|
||||||
import com.dbnt.kcscbackend.auth.entity.LoginVO;
|
import com.dbnt.kcscbackend.auth.entity.LoginVO;
|
||||||
import com.dbnt.kcscbackend.commonCode.entity.TnPopupMng;
|
import com.dbnt.kcscbackend.commonCode.entity.TnPopupMng;
|
||||||
import com.dbnt.kcscbackend.commonCode.repository.TnPopupMngRepository;
|
import com.dbnt.kcscbackend.commonCode.repository.TnPopupMngRepository;
|
||||||
import com.dbnt.kcscbackend.config.common.ResponseCode;
|
import com.dbnt.kcscbackend.config.common.ResponseCode;
|
||||||
import com.dbnt.kcscbackend.config.common.ResultVO;
|
import com.dbnt.kcscbackend.config.common.ResultVO;
|
||||||
|
import com.dbnt.kcscbackend.util.NetworkUtil;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl;
|
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl;
|
||||||
import org.egovframe.rte.ptl.mvc.tags.ui.pagination.PaginationInfo;
|
import org.egovframe.rte.ptl.mvc.tags.ui.pagination.PaginationInfo;
|
||||||
|
|
@ -19,11 +23,12 @@ import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.io.File;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
@ -34,6 +39,10 @@ public class PopUpApiServiceImpl extends EgovAbstractServiceImpl implements PopU
|
||||||
private final TnPopupMngRepository tnPopupMngRepository;
|
private final TnPopupMngRepository tnPopupMngRepository;
|
||||||
private final TnPopupMngRepositoryWithoutPopupContents tnPopupMngRepositoryWithoutPopupContents;
|
private final TnPopupMngRepositoryWithoutPopupContents tnPopupMngRepositoryWithoutPopupContents;
|
||||||
|
|
||||||
|
private final TnAttachFileRepository tnAttachFileRepository;
|
||||||
|
|
||||||
|
@Resource(name = "EgovFileMngUtil")
|
||||||
|
private EgovFileMngUtil fileUtil;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultVO contentsApiPopUpManageList(ResultVO resultVO, HttpServletRequest request, LoginVO user, Pageable pageable) throws Exception {
|
public ResultVO contentsApiPopUpManageList(ResultVO resultVO, HttpServletRequest request, LoginVO user, Pageable pageable) throws Exception {
|
||||||
|
|
@ -93,7 +102,7 @@ public class PopUpApiServiceImpl extends EgovAbstractServiceImpl implements PopU
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultVO contentsApiPopUpManageCreate(ResultVO resultVO, HttpServletRequest request, LoginVO user, final MultipartHttpServletRequest multiRequest, CreatePopupVO createPopupVO) throws Exception {
|
public ResultVO contentsApiPopUpManageCreate(ResultVO resultVO, HttpServletRequest request, LoginVO user, final MultipartHttpServletRequest multiRequest, CreatePopupVO createPopupVO, MultipartFile file) throws Exception {
|
||||||
|
|
||||||
System.out.println(
|
System.out.println(
|
||||||
"\n--------------------------------------------------------------\n" +
|
"\n--------------------------------------------------------------\n" +
|
||||||
|
|
@ -104,21 +113,13 @@ public class PopUpApiServiceImpl extends EgovAbstractServiceImpl implements PopU
|
||||||
"\n--------------------------------------------------------------\n"
|
"\n--------------------------------------------------------------\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
// 첨부파일 관련 첨부파일ID 생성
|
String fileGrpId = this.addTnAttachFile(request, user, file);
|
||||||
List<FileVO> _result = null;
|
|
||||||
String _atchFileId = "";
|
|
||||||
|
|
||||||
final Map<String, MultipartFile> files = multiRequest.getFileMap();
|
|
||||||
|
|
||||||
if (!files.isEmpty()) {
|
|
||||||
//_atchFileId = fileMngService.insertFileInfs(_result); //파일이 생성되고나면 생성된 첨부파일 ID를 리턴한다.
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, Object> response = tnPopupMngRepository.spAddTnPopupMng(
|
Map<String, Object> response = tnPopupMngRepository.spAddTnPopupMng(
|
||||||
createPopupVO.getTitle(),
|
createPopupVO.getTitle(),
|
||||||
createPopupVO.getStartDate(),
|
createPopupVO.getStartDate(),
|
||||||
createPopupVO.getEndDate(),
|
createPopupVO.getEndDate(),
|
||||||
null,
|
fileGrpId,
|
||||||
createPopupVO.getContents(),
|
createPopupVO.getContents(),
|
||||||
"kcsc_admin",
|
"kcsc_admin",
|
||||||
null,
|
null,
|
||||||
|
|
@ -169,6 +170,14 @@ public class PopUpApiServiceImpl extends EgovAbstractServiceImpl implements PopU
|
||||||
dto.put("schdulBgnde", tnPopupMng.getPopupStartDate().plusHours(9).format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))); // 날짜/시간의 시작 일시 - yyyyMMddHHmmss
|
dto.put("schdulBgnde", tnPopupMng.getPopupStartDate().plusHours(9).format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))); // 날짜/시간의 시작 일시 - yyyyMMddHHmmss
|
||||||
dto.put("schdulEndde", tnPopupMng.getPopupEndDate().plusHours(9).format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))); // 날짜/시간의 종료 일시 - yyyyMMddHHmmss
|
dto.put("schdulEndde", tnPopupMng.getPopupEndDate().plusHours(9).format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))); // 날짜/시간의 종료 일시 - yyyyMMddHHmmss
|
||||||
|
|
||||||
|
//첨부파일명을 가져온다.
|
||||||
|
TnAttachFile tnAttachFile = tnAttachFileRepository.findByFileGrpId(tnPopupMng.getFileGrpId()).orElse(null);
|
||||||
|
|
||||||
|
if( tnAttachFile != null ) {
|
||||||
|
dto.put("fileName", tnAttachFile.getFileOldName());
|
||||||
|
} else {
|
||||||
|
dto.put("fileName", null);
|
||||||
|
}
|
||||||
|
|
||||||
resultVO.setResult(dto);
|
resultVO.setResult(dto);
|
||||||
resultVO.setResultCode(ResponseCode.SUCCESS.getCode());
|
resultVO.setResultCode(ResponseCode.SUCCESS.getCode());
|
||||||
|
|
@ -178,7 +187,7 @@ public class PopUpApiServiceImpl extends EgovAbstractServiceImpl implements PopU
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultVO contentsApiPopUpManageUpdate(ResultVO resultVO, HttpServletRequest request, LoginVO user, UpdatePopupVO updatePopupVO, Long popupId) throws Exception {
|
public ResultVO contentsApiPopUpManageUpdate(ResultVO resultVO, HttpServletRequest request, LoginVO user, UpdatePopupVO updatePopupVO, MultipartFile file, Long popupId) throws Exception {
|
||||||
System.out.println(
|
System.out.println(
|
||||||
"\n--------------------------------------------------------------\n" +
|
"\n--------------------------------------------------------------\n" +
|
||||||
request.getRequestURI() + " IN:" +
|
request.getRequestURI() + " IN:" +
|
||||||
|
|
@ -201,14 +210,16 @@ public class PopUpApiServiceImpl extends EgovAbstractServiceImpl implements PopU
|
||||||
throw new Exception("종료일시는 시작일시보다 앞 설 수 없습니다.");
|
throw new Exception("종료일시는 시작일시보다 앞 설 수 없습니다.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String fileGrpId = this.addTnAttachFile(request, user, file);
|
||||||
|
|
||||||
Map<String, Object> response = tnPopupMngRepository.spUpdateTnPopupMng(
|
Map<String, Object> response = tnPopupMngRepository.spUpdateTnPopupMng(
|
||||||
popupId.intValue(),
|
popupId.intValue(),
|
||||||
updatePopupVO.getTitle(),
|
updatePopupVO.getTitle(),
|
||||||
updatePopupVO.getStartDate(),
|
updatePopupVO.getStartDate(),
|
||||||
updatePopupVO.getEndDate(),
|
updatePopupVO.getEndDate(),
|
||||||
null,
|
fileGrpId,
|
||||||
updatePopupVO.getContents(),
|
updatePopupVO.getContents(),
|
||||||
"kcsc_admin",
|
user.getId(),
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null
|
null
|
||||||
|
|
@ -311,4 +322,64 @@ public class PopUpApiServiceImpl extends EgovAbstractServiceImpl implements PopU
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 파일이 저장될 중간 경로를 생성한다.
|
||||||
|
* @return 중간 경로
|
||||||
|
*/
|
||||||
|
private String getMiddlePath() {
|
||||||
|
//파일이 저장될 경로를 생성한다.
|
||||||
|
String domainPath = "popup";
|
||||||
|
Date nowDate = new Date();
|
||||||
|
String strNowYyyy = new SimpleDateFormat("yyyy").format(nowDate);
|
||||||
|
String strNowYyyyMmdd = new SimpleDateFormat("yyyyMMdd").format(nowDate);
|
||||||
|
String middlePath = domainPath + "/" + strNowYyyy + "/" + strNowYyyyMmdd + "/";
|
||||||
|
|
||||||
|
return middlePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private String addTnAttachFile(HttpServletRequest request, LoginVO user, MultipartFile file) throws Exception {
|
||||||
|
String ipAddress = NetworkUtil.getClientIpAddress(request);
|
||||||
|
|
||||||
|
String fileGrpId = null;
|
||||||
|
if( file != null && !file.isEmpty()) {
|
||||||
|
//파일이 저장될 중간 경로를 생성한다.
|
||||||
|
String middlePath = this.getMiddlePath();
|
||||||
|
|
||||||
|
Map<String, MultipartFile> filesMap = new HashMap<String, MultipartFile>();
|
||||||
|
filesMap.put("file", file);
|
||||||
|
|
||||||
|
//String fileGrpId = UUID.randomUUID().toString();
|
||||||
|
fileGrpId = tnAttachFileRepository.makeFileGrpId(user.getId());
|
||||||
|
|
||||||
|
List<FileVO> files = fileUtil.parseFileInf(filesMap, "", 0, middlePath, null);
|
||||||
|
|
||||||
|
|
||||||
|
// 업로드된 file을 tnAttachFile에 insert한다.
|
||||||
|
for (Iterator<FileVO> iter = files.iterator(); iter.hasNext(); ) {
|
||||||
|
|
||||||
|
FileVO item = iter.next();
|
||||||
|
|
||||||
|
tnAttachFileRepository.spAddTnAttachFile(
|
||||||
|
fileGrpId,
|
||||||
|
1,
|
||||||
|
item.getOrignlFileNm(),
|
||||||
|
item.getStreFileNm() + "." + item.getFileExtsn(),
|
||||||
|
(item.getFileStreCours() + File.separator + item.getAtchFileId()).replaceAll("\\\\", "/"),
|
||||||
|
Long.parseLong(item.getFileMg()),
|
||||||
|
item.getFileExtsn(),
|
||||||
|
ipAddress,
|
||||||
|
user.getId(),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return fileGrpId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package com.dbnt.kcscbackend.admin.standardResearch;
|
package com.dbnt.kcscbackend.admin.standardResearch;
|
||||||
|
|
||||||
|
|
||||||
import com.dbnt.kcscbackend.admin.contents.popUp.utils.EgovFileMngUtil;
|
import com.dbnt.kcscbackend.file.service.EgovFileMngUtil;
|
||||||
import com.dbnt.kcscbackend.admin.standardResearch.model.CreateStandardResearchVO;
|
import com.dbnt.kcscbackend.admin.standardResearch.model.CreateStandardResearchVO;
|
||||||
import com.dbnt.kcscbackend.admin.standardResearch.model.UpdateStandardResearchVO;
|
import com.dbnt.kcscbackend.admin.standardResearch.model.UpdateStandardResearchVO;
|
||||||
import com.dbnt.kcscbackend.admin.standardResearch.service.AdminStandardResearchService;
|
import com.dbnt.kcscbackend.admin.standardResearch.service.AdminStandardResearchService;
|
||||||
|
|
|
||||||
|
|
@ -826,7 +826,6 @@ public class EgovStringUtil {
|
||||||
*
|
*
|
||||||
* @param
|
* @param
|
||||||
* @return Timestamp 값
|
* @return Timestamp 값
|
||||||
* @exception MyException
|
|
||||||
* @see
|
* @see
|
||||||
*/
|
*/
|
||||||
public static String getTimeStamp() {
|
public static String getTimeStamp() {
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,48 @@ package com.dbnt.kcscbackend.file.repository;
|
||||||
|
|
||||||
import com.dbnt.kcscbackend.file.entity.TnAttachFile;
|
import com.dbnt.kcscbackend.file.entity.TnAttachFile;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.jpa.repository.query.Procedure;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public interface TnAttachFileRepository extends JpaRepository<TnAttachFile, Integer> {
|
public interface TnAttachFileRepository extends JpaRepository<TnAttachFile, Integer> {
|
||||||
|
|
||||||
Optional<TnAttachFile> findByFileGrpId(String fileGrpId);
|
Optional<TnAttachFile> findByFileGrpId(String fileGrpId);
|
||||||
|
|
||||||
|
@Procedure("make_file_grp_id")
|
||||||
|
String makeFileGrpId( String modiId );
|
||||||
|
|
||||||
|
@Query(value = "CALL sp_add_tn_attach_file (" +
|
||||||
|
":_file_grp_id, " +
|
||||||
|
":_file_order, " +
|
||||||
|
":_file_old_name, " +
|
||||||
|
":_file_new_name, " +
|
||||||
|
":_file_path, " +
|
||||||
|
":_file_size, " +
|
||||||
|
":_file_ext, " +
|
||||||
|
":_ip_address, " +
|
||||||
|
":_modi_id, " +
|
||||||
|
":_result_count, " +
|
||||||
|
":_result_code, " +
|
||||||
|
":_error_message)",
|
||||||
|
nativeQuery = true)
|
||||||
|
Map<String, Object> spAddTnAttachFile(
|
||||||
|
@Param("_file_grp_id") String _file_grp_id,
|
||||||
|
@Param("_file_order") Integer _file_order,
|
||||||
|
@Param("_file_old_name") String _file_old_name,
|
||||||
|
@Param("_file_new_name") String _file_new_name,
|
||||||
|
@Param("_file_path") String _file_path,
|
||||||
|
@Param("_file_size") Long _file_size,
|
||||||
|
@Param("_file_ext") String _file_ext,
|
||||||
|
@Param("_ip_address") String _ip_address,
|
||||||
|
@Param("_modi_id") String _modi_id,
|
||||||
|
@Param("_result_count") Integer resultCount,
|
||||||
|
@Param("_result_code") String resultCode,
|
||||||
|
@Param("_error_message") String errorMessage
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
package com.dbnt.kcscbackend.admin.contents.popUp.utils;
|
package com.dbnt.kcscbackend.file.service;
|
||||||
|
|
||||||
import com.dbnt.kcscbackend.admin.contents.popUp.model.FileVO;
|
import com.dbnt.kcscbackend.admin.contents.popUp.model.FileVO;
|
||||||
|
import com.dbnt.kcscbackend.admin.contents.popUp.utils.EgovStringUtil;
|
||||||
|
import com.dbnt.kcscbackend.admin.contents.popUp.utils.EgovWebUtil;
|
||||||
|
import com.dbnt.kcscbackend.config.util.EgovNumberUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.egovframe.rte.fdl.idgnr.EgovIdGnrService;
|
import org.egovframe.rte.fdl.idgnr.EgovIdGnrService;
|
||||||
import org.egovframe.rte.fdl.property.EgovPropertyService;
|
import org.egovframe.rte.fdl.property.EgovPropertyService;
|
||||||
|
|
@ -12,10 +15,7 @@ import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -43,6 +43,8 @@ public class EgovFileMngUtil {
|
||||||
@Resource(name = "propertiesService")
|
@Resource(name = "propertiesService")
|
||||||
protected EgovPropertyService propertyService;
|
protected EgovPropertyService propertyService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 첨부파일에 대한 목록 정보를 취득한다.
|
* 첨부파일에 대한 목록 정보를 취득한다.
|
||||||
*
|
*
|
||||||
|
|
@ -50,9 +52,10 @@ public class EgovFileMngUtil {
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public List<FileVO> parseFileInf(Map<String, MultipartFile> files, String KeyStr, int fileKeyParam, String atchFileId, String storePath) throws Exception {
|
public List<FileVO> parseFileInf(Map<String, MultipartFile> files, String KeyStr, int fileKeyParam, String middlePath, String storePath) throws Exception {
|
||||||
int fileKey = fileKeyParam;
|
int fileKey = fileKeyParam;
|
||||||
|
|
||||||
|
|
||||||
String storePathString = "";
|
String storePathString = "";
|
||||||
String atchFileIdString = "";
|
String atchFileIdString = "";
|
||||||
|
|
||||||
|
|
@ -62,12 +65,12 @@ public class EgovFileMngUtil {
|
||||||
storePathString = propertyService.getString(storePath);
|
storePathString = propertyService.getString(storePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
atchFileId = atchFileId.replaceAll("\\s", "");
|
middlePath = middlePath.replaceAll("\\s", "");
|
||||||
|
|
||||||
if ("".equals(atchFileId) || atchFileId == null) {
|
if ("".equals(middlePath) || middlePath == null) {
|
||||||
atchFileIdString = "testest_thkim-temp-20240124_1446";
|
atchFileIdString = EgovStringUtil.getTimeStamp() + EgovNumberUtil.getRandomNum(0, 9) + EgovNumberUtil.getRandomNum(0, 9) + "";
|
||||||
} else {
|
} else {
|
||||||
atchFileIdString = atchFileId;
|
atchFileIdString = middlePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
File saveFolder = new File(EgovWebUtil.filePathBlackList(storePathString));
|
File saveFolder = new File(EgovWebUtil.filePathBlackList(storePathString));
|
||||||
|
|
@ -112,16 +115,25 @@ public class EgovFileMngUtil {
|
||||||
long _size = file.getSize();
|
long _size = file.getSize();
|
||||||
|
|
||||||
if (!"".equals(orginFileName)) {
|
if (!"".equals(orginFileName)) {
|
||||||
filePath = storePathString + File.separator + newName;
|
|
||||||
file.transferTo(new File(EgovWebUtil.filePathBlackList(filePath)));
|
filePath = storePathString + File.separator + middlePath + File.separator;
|
||||||
|
|
||||||
|
File savePath = new File(EgovWebUtil.filePathBlackList(filePath));
|
||||||
|
if (!savePath.exists() || savePath.isFile()) {
|
||||||
|
savePath.mkdirs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
file.transferTo(new File(EgovWebUtil.filePathBlackList(savePath.getAbsolutePath() + File.separator + newName + "." + fileExt)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
fvo = new FileVO();
|
fvo = new FileVO();
|
||||||
fvo.setFileExtsn(fileExt);
|
fvo.setFileExtsn(fileExt);
|
||||||
fvo.setFileStreCours(storePathString);
|
fvo.setFileStreCours(storePathString.replaceAll("\\\\", "/"));
|
||||||
fvo.setFileMg(Long.toString(_size));
|
fvo.setFileMg(Long.toString(_size));
|
||||||
fvo.setOrignlFileNm(orginFileName);
|
fvo.setOrignlFileNm(orginFileName);
|
||||||
fvo.setStreFileNm(newName);
|
fvo.setStreFileNm(newName);
|
||||||
fvo.setAtchFileId(atchFileIdString);
|
fvo.setAtchFileId(atchFileIdString.replaceAll("\\\\", "/"));
|
||||||
fvo.setFileSn(String.valueOf(fileKey));
|
fvo.setFileSn(String.valueOf(fileKey));
|
||||||
|
|
||||||
//writeFile(file, newName, storePathString);
|
//writeFile(file, newName, storePathString);
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,29 @@
|
||||||
package com.dbnt.kcscbackend.util;public class NetworkUtil {
|
package com.dbnt.kcscbackend.util;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
public final class NetworkUtil {
|
||||||
|
private static final String[] HEADERS_TO_TRY = {
|
||||||
|
"X-Forwarded-For",
|
||||||
|
"Proxy-Client-IP",
|
||||||
|
"WL-Proxy-Client-IP",
|
||||||
|
"HTTP_X_FORWARDED_FOR",
|
||||||
|
"HTTP_X_FORWARDED",
|
||||||
|
"HTTP_X_CLUSTER_CLIENT_IP",
|
||||||
|
"HTTP_CLIENT_IP",
|
||||||
|
"HTTP_FORWARDED_FOR",
|
||||||
|
"HTTP_FORWARDED",
|
||||||
|
"HTTP_VIA",
|
||||||
|
"REMOTE_ADDR" };
|
||||||
|
|
||||||
|
public static String getClientIpAddress(HttpServletRequest request) {
|
||||||
|
for (String header : HEADERS_TO_TRY) {
|
||||||
|
String ip = request.getHeader(header);
|
||||||
|
if (ip != null && !ip.isEmpty() && !"unknown".equalsIgnoreCase(ip)) {
|
||||||
|
return ip;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return request.getRemoteAddr();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,5 +31,5 @@ logging.level.com.atoz_develop.mybatissample.repository=TRACE
|
||||||
|
|
||||||
# File Config
|
# File Config
|
||||||
Globals.posblAtchFileSize=5242880
|
Globals.posblAtchFileSize=5242880
|
||||||
Globals.fileStorePath=D:\\kcsc
|
Globals.fileStorePath=D:\\kcscUploadFiles
|
||||||
Globals.addedOptions=false
|
Globals.addedOptions=false
|
||||||
|
|
|
||||||
|
|
@ -37,5 +37,5 @@ logging.level.com.atoz_develop.mybatissample.repository=TRACE
|
||||||
|
|
||||||
# File Config
|
# File Config
|
||||||
Globals.posblAtchFileSize=5242880
|
Globals.posblAtchFileSize=5242880
|
||||||
Globals.fileStorePath=D:\\kcsc
|
Globals.fileStorePath=D:\\kcscUploadFiles
|
||||||
Globals.addedOptions=false
|
Globals.addedOptions=false
|
||||||
|
|
@ -34,5 +34,5 @@ logging.level.com.atoz_develop.mybatissample.repository=info
|
||||||
|
|
||||||
# File Config
|
# File Config
|
||||||
Globals.posblAtchFileSize=5242880
|
Globals.posblAtchFileSize=5242880
|
||||||
Globals.fileStorePath=C:\\kcsc_web\\uploadedFile
|
Globals.fileStorePath=D:\\kcscUploadFiles
|
||||||
Globals.addedOptions=false
|
Globals.addedOptions=false
|
||||||
|
|
|
||||||
|
|
@ -34,5 +34,5 @@ logging.level.com.atoz_develop.mybatissample.repository=info
|
||||||
|
|
||||||
# File Config
|
# File Config
|
||||||
Globals.posblAtchFileSize=5242880
|
Globals.posblAtchFileSize=5242880
|
||||||
Globals.fileStorePath=/docker/kcscDev/uploadFiles
|
Globals.fileStorePath=D:\\kcscUploadFiles
|
||||||
Globals.addedOptions=false
|
Globals.addedOptions=false
|
||||||
|
|
@ -18,3 +18,8 @@ Globals.admin.allow-ip = 218.49.16.81,218.49.21.183,218.49.16.168,218.49.17.102,
|
||||||
|
|
||||||
#?????? ???? ?
|
#?????? ???? ?
|
||||||
#?? : ??? ??? "egovframe"? ????? ???? ????? ????.
|
#?? : ??? ??? "egovframe"? ????? ???? ????? ????.
|
||||||
|
|
||||||
|
|
||||||
|
# filesize limit
|
||||||
|
spring.servlet.multipart.maxFileSize=10MB
|
||||||
|
spring.servlet.multipart.maxRequestSize=10MB
|
||||||
Loading…
Reference in New Issue