첨부파일 테이블 변경작업 및 처리 방식 변경, 다운로드 보완 강화
This commit is contained in:
parent
a0a9a90b8e
commit
d10885c338
@ -7,45 +7,98 @@ import java.util.Map;
|
||||
|
||||
import nlib.user.service.NlibLoginVO;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* @Class Name : AttachFileService.java
|
||||
*
|
||||
* @Description : 첨부파일을 관리하는 서비스 인터페이스
|
||||
*
|
||||
*
|
||||
* @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021)
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @ ------------ -------- ---------------------------
|
||||
* @ 수정일 수정자 수정내용
|
||||
* @ ------------ -------- ---------------------------
|
||||
* @ 2021. 9. 16. KNKIM 최초 생성
|
||||
*
|
||||
*
|
||||
* @author 이씨플라자 * DIGITALSHIP KNKIM
|
||||
* @since 2021. 9. 16.
|
||||
* @version 1.0
|
||||
*
|
||||
*/
|
||||
public interface AttachFileService
|
||||
{
|
||||
|
||||
/**
|
||||
* 첨부파일 목록을 조회한다.
|
||||
*
|
||||
* @param
|
||||
* @param attachFileId
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public List<AttachFileVO> listAttachFiles(String attachFileId) throws Exception;
|
||||
|
||||
|
||||
/**
|
||||
* 첨부파일그룹 등록한다.
|
||||
*
|
||||
* @param attachFileVO
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public int insertAttachFileGroup(AttachFileVO attachFileVO) throws Exception;
|
||||
|
||||
|
||||
/**
|
||||
* 첨부파일 등록한다.
|
||||
*
|
||||
* @param
|
||||
* @param attachFileVO
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public int insertAttachFile(AttachFileVO attachFileVO) throws Exception;
|
||||
|
||||
|
||||
/**
|
||||
* 첨부파일그룹을 삭제한다.
|
||||
*
|
||||
* @param attachFileVO
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public int deleteAttachFileGroup(AttachFileVO attachFileVO) throws Exception;
|
||||
|
||||
/**
|
||||
* 첨부파일 삭제한다.
|
||||
*
|
||||
* @param
|
||||
* @param attachFileVO
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public int deleteAttachFile(AttachFileVO attachFileVO) throws Exception;
|
||||
|
||||
|
||||
/**
|
||||
* 첨부파일 다운로드 회수를 증가시킨다.
|
||||
* 첨부파일 정보를 조회한다.
|
||||
*
|
||||
* @param
|
||||
* @param attachFileVO
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public int increaseDownloadCount(AttachFileVO attachFileVO) throws Exception;
|
||||
public AttachFileVO selectAttachFile(AttachFileVO attachFileVO) throws Exception;
|
||||
|
||||
|
||||
/**
|
||||
* 다운로드 가능 여부를 확인하다.
|
||||
*
|
||||
* @param attachFileVO
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public boolean checkAttachFileDownload(AttachFileVO attachFileVO) throws Exception;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -27,164 +27,94 @@ import nlib.util.UUID;
|
||||
*/
|
||||
public class AttachFileVO {
|
||||
|
||||
private String bdType; /* 첨부된 게시판 유형 : ancmnt, faq, qna */
|
||||
private String mbInfoId; /* 사용자ID (권한체크 등에 사용) */
|
||||
|
||||
private String subPathKey; /* 첨부파일서브경로 */
|
||||
|
||||
private String fileMask; /* 첨부파일아이디 */
|
||||
private String fileId; /* 업무 아이디 */
|
||||
private int fileSeq; /* 파일 번호 */
|
||||
private String fileName; /* 파일 이름 */
|
||||
private int fileSize; /* 파일 사이즈 */
|
||||
private String fileTypeCd; /* 파일 유형(디지털화사용) */
|
||||
private int downloadCount; /* 파일 다운로드 횟수 */
|
||||
private String downloadExpireDate; /* 파일 만료 날짜 */
|
||||
private int downloadLimitCount; /* 파일 다운로드 제한 횟수 */
|
||||
|
||||
private String deleteYn; /* 삭제 여부 */
|
||||
private String streamingUrl; /* 스트리밍URL */
|
||||
private String content; /* 내용주기 */
|
||||
private String atchTypeCd; /* 첨부파일유형 (image, doc) */
|
||||
|
||||
private String regDd; /* 등록 날짜 */
|
||||
|
||||
private String attachFileId; /* 첨부파일아이디 */
|
||||
private int fileSn; /* 파일 순번 */
|
||||
private String fileStreCours; /* 파일 저장결올 */
|
||||
private String streFileNm; /* 저장파일명 */
|
||||
private String orignlFileNm; /* 원본파일명 */
|
||||
private String fileExtsn; /* 파일확장자 */
|
||||
private String fileCn; /* 파일내용 */
|
||||
private int fileSize; /* 파일 사이즈 */
|
||||
private String useAt; /* 사용영부 */
|
||||
|
||||
public void setAtchTypeCdFromFileExtsn() {
|
||||
if(StringUtil.isEmpty(fileExtsn)) return;
|
||||
|
||||
if("|jpg|jpeg|png|gif|".contains(fileExtsn)) atchTypeCd = "image";
|
||||
else if("|hwp|doc|docx|xls|xlsx|ppt|pptx|".contains(fileExtsn)) atchTypeCd = "doc";
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
public String getFileMask() {
|
||||
return fileMask;
|
||||
}
|
||||
|
||||
public void setFileMask(String fileMask) {
|
||||
this.fileMask = fileMask;
|
||||
}
|
||||
|
||||
public String getFileId() {
|
||||
return fileId;
|
||||
}
|
||||
|
||||
public void setFileId(String fileId) {
|
||||
this.fileId = fileId;
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public void setFileName(String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
public String getFileTypeCd() {
|
||||
return fileTypeCd;
|
||||
}
|
||||
|
||||
public void setFileTypeCd(String fileTypeCd) {
|
||||
this.fileTypeCd = fileTypeCd;
|
||||
}
|
||||
|
||||
public String getDownloadExpireDate() {
|
||||
return downloadExpireDate;
|
||||
}
|
||||
|
||||
public void setDownloadExpireDate(String downloadExpireDate) {
|
||||
this.downloadExpireDate = downloadExpireDate;
|
||||
}
|
||||
|
||||
public String getDeleteYn() {
|
||||
return deleteYn;
|
||||
}
|
||||
|
||||
public void setDeleteYn(String deleteYn) {
|
||||
this.deleteYn = deleteYn;
|
||||
}
|
||||
|
||||
public String getStreamingUrl() {
|
||||
return streamingUrl;
|
||||
}
|
||||
|
||||
public void setStreamingUrl(String streamingUrl) {
|
||||
this.streamingUrl = streamingUrl;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getAtchTypeCd() {
|
||||
return atchTypeCd;
|
||||
}
|
||||
|
||||
public void setAtchTypeCd(String atchTypeCd) {
|
||||
this.atchTypeCd = atchTypeCd;
|
||||
}
|
||||
|
||||
public String getRegDd() {
|
||||
return regDd;
|
||||
}
|
||||
|
||||
public void setRegDd(String regDd) {
|
||||
this.regDd = regDd;
|
||||
}
|
||||
|
||||
public int getFileSeq() {
|
||||
return fileSeq;
|
||||
}
|
||||
|
||||
public void setFileSeq(int fileSeq) {
|
||||
this.fileSeq = fileSeq;
|
||||
}
|
||||
|
||||
public int getFileSize() {
|
||||
return fileSize;
|
||||
}
|
||||
|
||||
public void setFileSize(int fileSize) {
|
||||
this.fileSize = fileSize;
|
||||
}
|
||||
|
||||
|
||||
public int getDownloadCount() {
|
||||
return downloadCount;
|
||||
}
|
||||
|
||||
public void setDownloadCount(int downloadCount) {
|
||||
this.downloadCount = downloadCount;
|
||||
}
|
||||
|
||||
public int getDownloadLimitCount() {
|
||||
return downloadLimitCount;
|
||||
}
|
||||
|
||||
public void setDownloadLimitCount(int downloadLimitCount) {
|
||||
this.downloadLimitCount = downloadLimitCount;
|
||||
}
|
||||
|
||||
// GET/SET
|
||||
public String getSubPathKey() {
|
||||
return subPathKey;
|
||||
}
|
||||
|
||||
public void setSubPathKey(String subPathKey) {
|
||||
this.subPathKey = subPathKey;
|
||||
}
|
||||
|
||||
public String getAttachFileId() {
|
||||
return attachFileId;
|
||||
}
|
||||
public void setAttachFileId(String attachFileId) {
|
||||
this.attachFileId = attachFileId;
|
||||
}
|
||||
public int getFileSn() {
|
||||
return fileSn;
|
||||
}
|
||||
public void setFileSn(int fileSn) {
|
||||
this.fileSn = fileSn;
|
||||
}
|
||||
public String getFileStreCours() {
|
||||
return fileStreCours;
|
||||
}
|
||||
public void setFileStreCours(String fileStreCours) {
|
||||
this.fileStreCours = fileStreCours;
|
||||
}
|
||||
public String getStreFileNm() {
|
||||
return streFileNm;
|
||||
}
|
||||
public void setStreFileNm(String streFileNm) {
|
||||
this.streFileNm = streFileNm;
|
||||
}
|
||||
public String getOrignlFileNm() {
|
||||
return orignlFileNm;
|
||||
}
|
||||
public void setOrignlFileNm(String orignlFileNm) {
|
||||
this.orignlFileNm = orignlFileNm;
|
||||
}
|
||||
public String getFileExtsn() {
|
||||
return fileExtsn;
|
||||
}
|
||||
|
||||
public void setFileExtsn(String fileExtsn) {
|
||||
this.fileExtsn = (fileExtsn == null ? null : fileExtsn.toLowerCase());
|
||||
}
|
||||
public String getFileCn() {
|
||||
return fileCn;
|
||||
}
|
||||
public void setFileCn(String fileCn) {
|
||||
this.fileCn = fileCn;
|
||||
}
|
||||
public int getFileSize() {
|
||||
return fileSize;
|
||||
}
|
||||
public void setFileSize(int fileSize) {
|
||||
this.fileSize = fileSize;
|
||||
}
|
||||
public String getUseAt() {
|
||||
return useAt;
|
||||
}
|
||||
public void setUseAt(String useAt) {
|
||||
this.useAt = useAt;
|
||||
}
|
||||
public String getMbInfoId() {
|
||||
return mbInfoId;
|
||||
}
|
||||
public void setMbInfoId(String mbInfoId) {
|
||||
this.mbInfoId = mbInfoId;
|
||||
}
|
||||
public String getBdType() {
|
||||
return bdType;
|
||||
}
|
||||
public void setBdType(String bdType) {
|
||||
this.bdType = bdType;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -50,6 +50,16 @@ public interface AttachFileDAO {
|
||||
public List<AttachFileVO> listAttachFiles(String attachFileId) throws Exception;
|
||||
|
||||
|
||||
/**
|
||||
* 첨부파일그룹을 등록한다.
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public int insertAttachFileGroup(AttachFileVO attachFileVO) throws Exception;
|
||||
|
||||
|
||||
/**
|
||||
* 첨부파일 등록한다.
|
||||
*
|
||||
@ -59,6 +69,15 @@ public interface AttachFileDAO {
|
||||
*/
|
||||
public int insertAttachFile(AttachFileVO attachFileVO) throws Exception;
|
||||
|
||||
/**
|
||||
* 첨부파일그룹을 삭제한다.
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public int deleteAttachFileGroup(AttachFileVO attachFileVO) throws Exception;
|
||||
|
||||
/**
|
||||
* 첨부파일 삭제한다.
|
||||
*
|
||||
@ -69,12 +88,20 @@ public interface AttachFileDAO {
|
||||
public int deleteAttachFile(AttachFileVO attachFileVO) throws Exception;
|
||||
|
||||
/**
|
||||
* 첨부파일 다운로드 회수를 증가시킨다.
|
||||
* 첨부파일 정보를 조회한다.
|
||||
*
|
||||
* @param
|
||||
* @param attachFileVO
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public int increaseDownloadCount(AttachFileVO attachFileVO) throws Exception;
|
||||
|
||||
public AttachFileVO selectAttachFile(AttachFileVO attachFileVO) throws Exception;
|
||||
|
||||
/**
|
||||
* 다운로드 가능 여부를 확인하다.
|
||||
*
|
||||
* @param attachFileVO
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public String checkAttachFileDownload(AttachFileVO attachFileVO) throws Exception;
|
||||
}
|
||||
|
||||
@ -10,7 +10,30 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import nlib.bbs.service.AttachFileService;
|
||||
import nlib.bbs.service.AttachFileVO;
|
||||
import nlib.util.StringUtil;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* @Class Name : AttachFileServiceImpl.java
|
||||
*
|
||||
* @Description : 첨부파일을 관리하는 서비스 클래스
|
||||
*
|
||||
*
|
||||
* @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021)
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @ ------------ -------- ---------------------------
|
||||
* @ 수정일 수정자 수정내용
|
||||
* @ ------------ -------- ---------------------------
|
||||
* @ 2021. 9. 16. KNKIM 최초 생성
|
||||
*
|
||||
*
|
||||
* @author 이씨플라자 * DIGITALSHIP KNKIM
|
||||
* @since 2021. 9. 16.
|
||||
* @version 1.0
|
||||
*
|
||||
*/
|
||||
@Service("attachFileService")
|
||||
public class AttachFileServiceImpl implements AttachFileService
|
||||
{
|
||||
@ -26,24 +49,90 @@ public class AttachFileServiceImpl implements AttachFileService
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public List<AttachFileVO> listAttachFiles(String attachFileId) throws Exception {
|
||||
return attachFileDAO.listAttachFiles(attachFileId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 첨부파일그룹 등록한다.
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public int insertAttachFileGroup(AttachFileVO attachFileVO) throws Exception {
|
||||
return attachFileDAO.insertAttachFileGroup(attachFileVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 첨부파일 등록한다.
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public int insertAttachFile(AttachFileVO attachFileVO) throws Exception {
|
||||
|
||||
return attachFileDAO.insertAttachFile(attachFileVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 첨부파일그룹을 삭제한다.
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public int deleteAttachFileGroup(AttachFileVO attachFileVO) throws Exception {
|
||||
return attachFileDAO.deleteAttachFileGroup(attachFileVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 첨부파일 삭제한다.
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public int deleteAttachFile(AttachFileVO attachFileVO) throws Exception {
|
||||
return attachFileDAO.deleteAttachFile(attachFileVO);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int increaseDownloadCount(AttachFileVO attachFileVO) throws Exception {
|
||||
return attachFileDAO.increaseDownloadCount(attachFileVO);
|
||||
|
||||
/**
|
||||
* 첨부파일 정보를 조회한다.
|
||||
*
|
||||
* @param attachFileVO
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public AttachFileVO selectAttachFile(AttachFileVO attachFileVO) throws Exception {
|
||||
|
||||
if(attachFileVO == null) return null;
|
||||
if(StringUtil.isEmpty(attachFileVO.getAttachFileId())) return null;
|
||||
if(attachFileVO.getFileSn() < 1) return null;
|
||||
|
||||
return attachFileDAO.selectAttachFile(attachFileVO);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 다운로드 가능 여부를 확인하다.
|
||||
*
|
||||
* @param attachFileVO
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public boolean checkAttachFileDownload(AttachFileVO attachFileVO) throws Exception {
|
||||
String ret = attachFileDAO.checkAttachFileDownload(attachFileVO);
|
||||
|
||||
if(StringUtil.isEmpty(ret)) return false;
|
||||
|
||||
return ret.charAt(0) == 'Y';
|
||||
}
|
||||
}
|
||||
@ -46,22 +46,35 @@ public class QnaServiceImpl extends BoardServiceImpl implements QnaService
|
||||
}
|
||||
|
||||
articleVO.setResultCode("S001");
|
||||
articleVO.setResultMessage("정상적으로 등록되었습니다.");
|
||||
|
||||
if(articleVO.getAttachFileCnt() > 0) {
|
||||
int savedCnt = 0;
|
||||
List<AttachFileVO> attachFileList = articleVO.getAttachFiles();
|
||||
for(int i=0; i<attachFileList.size(); i++) {
|
||||
AttachFileVO attachFileVO = attachFileList.get(i);
|
||||
int retAttFile = attachFileService.insertAttachFile(attachFileVO);
|
||||
savedCnt += retAttFile;
|
||||
if(retAttFile < 1) {
|
||||
log.error("insertArticle > 첨부파일 등록에 실패하였습니다 : " + attachFileVO.getFileName());
|
||||
}
|
||||
}
|
||||
|
||||
if(savedCnt != articleVO.getAttachFileCnt()) {
|
||||
articleVO.setResultMessage(String.format("총 %d개 파일 중 %개 파일만 정상등록되었습니다.", articleVO.getAttachFileCnt(), savedCnt));
|
||||
// 첨부파일그룹 등록
|
||||
int groupCnt = attachFileService.insertAttachFileGroup(attachFileList.get(0));
|
||||
|
||||
if(groupCnt > 0) {
|
||||
|
||||
// 첨부파일 등록
|
||||
for(int i=0; i<attachFileList.size(); i++) {
|
||||
AttachFileVO attachFileVO = attachFileList.get(i);
|
||||
int retAttFile = attachFileService.insertAttachFile(attachFileVO);
|
||||
savedCnt += retAttFile;
|
||||
if(retAttFile < 1) {
|
||||
log.error("insertArticle > 첨부파일 등록에 실패하였습니다 : " + attachFileVO.getOrignlFileNm());
|
||||
}
|
||||
}
|
||||
|
||||
if(savedCnt != articleVO.getAttachFileCnt()) {
|
||||
articleVO.setResultMessage(String.format("총 %d개 파일 중 %개 파일만 정상등록되었습니다.", articleVO.getAttachFileCnt(), savedCnt));
|
||||
}
|
||||
|
||||
} else {
|
||||
articleVO.setResultMessage("게시글은 등록되었으나, 첨부파일그룹 등록에 실패하여 첨부파일 등록처리가 수행되지 않았습니다.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return articleVO;
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
|
||||
package nlib.bbs.web;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -260,33 +261,37 @@ public class QnaController extends NlibCommonController {
|
||||
}
|
||||
|
||||
if(fileListObj != null && fileListObj.size() > 0) {
|
||||
List<AttachFileVO> attachFiles = new ArrayList<AttachFileVO>();
|
||||
String fileId = null;
|
||||
for(int i=0; i<fileListObj.size(); i++) {
|
||||
Map finfo = fileListObj.get(i);
|
||||
AttachFileVO fVO = new AttachFileVO();
|
||||
|
||||
// 게시물에 첨부파일 ID 설정
|
||||
if(i == 0) {
|
||||
fileId = (String)finfo.get("fileId");
|
||||
if(StringUtil.isEmpty(fileId)) {
|
||||
log.error("첨부파일의 FILEID 값은 필수 항목입니다. 첨부파일 처리에 실패하였습니다. 그러나, 게시물 등록은 계속 진행됩니다.");
|
||||
break;
|
||||
}
|
||||
articleVO.setBdAttachFileId(fileId);
|
||||
}
|
||||
|
||||
String attachFileId = (String)(fileListObj.get(0).get("attachFileId"));
|
||||
if(StringUtil.isEmpty(attachFileId)) {
|
||||
log.error("첨부파일 아이디(attachFileId) 값은 필수 항목입니다. 첨부파일 처리에 실패하였습니다. 그러나, 게시물 등록은 계속 진행됩니다.");
|
||||
}
|
||||
|
||||
if(StringUtil.isNotEmpty(attachFileId)) {
|
||||
articleVO.setBdAttachFileId(attachFileId);
|
||||
|
||||
String fileSStreCours = NlibProperty.getProperty("fileupload.base.path") + NlibProperty.getProperty("fileupload.bbs.qna.subpath") + "/";
|
||||
List<AttachFileVO> attachFiles = new ArrayList<AttachFileVO>();
|
||||
|
||||
for(int i=0; i<fileListObj.size(); i++) {
|
||||
Map finfo = fileListObj.get(i);
|
||||
AttachFileVO fVO = new AttachFileVO();
|
||||
|
||||
fVO.setAttachFileId(attachFileId);
|
||||
fVO.setFileStreCours(fileSStreCours);
|
||||
fVO.setStreFileNm((String)finfo.get("streFileNm"));
|
||||
fVO.setOrignlFileNm((String)finfo.get("orignlFileNm"));
|
||||
fVO.setFileExtsn((String)finfo.get("fileExtsn"));
|
||||
fVO.setFileSize(((Integer)finfo.get("fileSize")).intValue());
|
||||
|
||||
File f = new File(fVO.getFileStreCours() + fVO.getStreFileNm());
|
||||
if(!f.exists() || !f.isFile()) continue;
|
||||
|
||||
attachFiles.add(fVO);
|
||||
}
|
||||
articleVO.setAttachFiles(attachFiles);
|
||||
}
|
||||
|
||||
fVO.setFileMask((String)finfo.get("fileMask"));
|
||||
fVO.setFileId(fileId);
|
||||
fVO.setFileSeq(((Integer)finfo.get("fileSeq")).intValue());
|
||||
fVO.setFileName((String)finfo.get("fileName"));
|
||||
fVO.setFileSize(((Integer)finfo.get("fileSize")).intValue());
|
||||
fVO.setAtchTypeCd((String)finfo.get("atchTypeCd"));
|
||||
fVO.setFileExtsn((String)finfo.get("fileExtsn"));
|
||||
|
||||
attachFiles.add(fVO);
|
||||
}
|
||||
articleVO.setAttachFiles(attachFiles);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -95,7 +95,8 @@ public class FileUploadController {
|
||||
@RequestMapping(value="/fileupload/uploadFilesAjax.do", produces="application/json")
|
||||
public ResponseEntity uploadFilesAjax(
|
||||
final MultipartHttpServletRequest multiRequest
|
||||
, @RequestParam("subPathKey") String subPathKey
|
||||
, @RequestParam(name="subPathKey") String subPathKey
|
||||
, @RequestParam(name="attachFileId", required=false) String attachFileId
|
||||
, HttpServletResponse response) {
|
||||
|
||||
String message = null;
|
||||
@ -150,60 +151,51 @@ public class FileUploadController {
|
||||
String filePath = "";
|
||||
FileVO fvo;
|
||||
AttachFileVO atvo;
|
||||
String fileId = UUID.getNewFileId(); // J_ATTACHFILE 테이블의 FILE_ID : 첨부파일그룹코드
|
||||
String fileId = UUID.getNewFileId();
|
||||
|
||||
// 첨브파일그룹ID
|
||||
if(StringUtil.isEmpty(attachFileId)) {
|
||||
attachFileId = UUID.getNewAttachFileId();
|
||||
}
|
||||
|
||||
int fileSeq = 1;
|
||||
while (itr.hasNext()) {
|
||||
Entry<String, MultipartFile> entry = itr.next();
|
||||
|
||||
file = entry.getValue();
|
||||
String orginFileName = file.getOriginalFilename();
|
||||
String orignlFileNm = file.getOriginalFilename();
|
||||
|
||||
//--------------------------------------
|
||||
// 원 파일명이 없는 경우 처리 SKIP
|
||||
// (첨부가 되지 않은 input file type)
|
||||
//--------------------------------------
|
||||
if (orginFileName == null || "".equals(orginFileName)) {
|
||||
if (orignlFileNm == null || "".equals(orignlFileNm)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int index = orginFileName.lastIndexOf(".");
|
||||
String fileExt = (index < 1 ? "" : orginFileName.substring(index + 1));
|
||||
// 파일 확장자
|
||||
int index = orignlFileNm.lastIndexOf(".");
|
||||
String fileExt = (index < 1 ? "" : orignlFileNm.substring(index + 1));
|
||||
|
||||
//String newName = UUID.getPhysicalFileName();
|
||||
String fileMask = UUID.getNewFileMask();
|
||||
|
||||
|
||||
int size = (int)file.getSize();
|
||||
String streFileNm = UUID.getNewStreFileNm();
|
||||
|
||||
filePath = FILEUPLOAD_BASE_PATH + subPath + "/" + streFileNm;
|
||||
log.debug("FILE UPLOAD : filePath=" + filePath);
|
||||
|
||||
if (!"".equals(orginFileName)) {
|
||||
filePath = FILEUPLOAD_BASE_PATH + subPath + "/" + fileMask;
|
||||
log.debug("FILE UPLOAD : filePath=" + filePath);
|
||||
|
||||
file.transferTo(new File(FileUtil.filePathBlackList(filePath)));
|
||||
}
|
||||
|
||||
// ---------------- 삭제대상 : 시작
|
||||
fvo = new FileVO();
|
||||
fvo.setFileExtsn(fileExt);
|
||||
fvo.setFileMg(Long.toString(size));
|
||||
fvo.setOrignlFileNm(orginFileName);
|
||||
fvo.setStreFileNm(fileMask);
|
||||
fvo.setFileSn(String.valueOf(fileSeq));
|
||||
// ---------------- 삭제대상 : 종료
|
||||
|
||||
file.transferTo(new File(FileUtil.filePathBlackList(filePath)));
|
||||
|
||||
atvo = new AttachFileVO();
|
||||
atvo.setSubPathKey(subPathKey);
|
||||
atvo.setFileMask(fileMask);
|
||||
atvo.setFileId(fileId);
|
||||
atvo.setFileSeq(fileSeq);
|
||||
atvo.setFileName(orginFileName);
|
||||
atvo.setFileSize(size);
|
||||
atvo.setAttachFileId(attachFileId);
|
||||
atvo.setStreFileNm(streFileNm);
|
||||
atvo.setOrignlFileNm(orignlFileNm);
|
||||
atvo.setFileExtsn(fileExt);
|
||||
atvo.setAtchTypeCdFromFileExtsn();
|
||||
atvo.setFileSize(size);
|
||||
|
||||
result.add(atvo);
|
||||
|
||||
fileSeq++;
|
||||
}
|
||||
}
|
||||
} catch(Exception e) {
|
||||
@ -241,17 +233,38 @@ public class FileUploadController {
|
||||
@RequestMapping(value="/fileupload/downloadAttachFile.do")
|
||||
public ModelAndView downloadAttachFile(AttachFileVO attachFileVO, ModelAndView mv) throws Exception {
|
||||
|
||||
// TODO 권한 설정 기능 추가 필요
|
||||
//---------------------------------
|
||||
// 권한체크
|
||||
//---------------------------------
|
||||
// 공지사항, FAQ : 모두 공개
|
||||
// QnA : 공개된 글인 경우, 모두 공개
|
||||
// QnA : 비밀글 (본인에 한정)
|
||||
|
||||
int ret = attachFileService.increaseDownloadCount(attachFileVO);
|
||||
if(ret < 1) {
|
||||
String message = "다운로드 가능 회수를 초과하였거나, 해당 정보를 찾을 수 없습니다.";
|
||||
log.error("downloadAttachFile > " + message);
|
||||
throw new Exception(message);
|
||||
boolean hasAuth = attachFileService.checkAttachFileDownload(attachFileVO);
|
||||
|
||||
if(!hasAuth) {
|
||||
throw new Exception("잘못된 접근입니다. 파일다운로드를 할 수 있는 권한이 없습니다.");
|
||||
}
|
||||
|
||||
String subPath = NlibProperty.getProperty(attachFileVO.getSubPathKey());
|
||||
String fullPath = FILEUPLOAD_BASE_PATH + "/" + subPath + "/" + attachFileVO.getFileMask();
|
||||
AttachFileVO retAttachFileVO = attachFileService.selectAttachFile(attachFileVO);
|
||||
|
||||
if(retAttachFileVO == null || StringUtil.isEmpty(retAttachFileVO.getAttachFileId())) {
|
||||
throw new Exception("잘못된 접근이므로 파일다운로드를 할 수 없습니다.");
|
||||
}
|
||||
|
||||
if(StringUtil.isEmpty(retAttachFileVO.getFileStreCours()) || StringUtil.isEmpty(retAttachFileVO.getStreFileNm())) {
|
||||
throw new Exception("파일정보가 올바르지 않습니다.");
|
||||
}
|
||||
|
||||
if(StringUtil.isEmpty(retAttachFileVO.getOrignlFileNm())) {
|
||||
retAttachFileVO.setOrignlFileNm("첨부파일." + retAttachFileVO.getFileExtsn());
|
||||
}
|
||||
|
||||
if(StringUtil.isEmpty(retAttachFileVO.getOrignlFileNm())) {
|
||||
retAttachFileVO.setOrignlFileNm("첨부파일." + retAttachFileVO.getFileExtsn());
|
||||
}
|
||||
|
||||
String fullPath = retAttachFileVO.getFileStreCours() + retAttachFileVO.getStreFileNm();
|
||||
|
||||
log.debug("downloadAttachFile > fullPath = " + fullPath);
|
||||
|
||||
@ -266,7 +279,7 @@ public class FileUploadController {
|
||||
|
||||
mv.setViewName("downloadView"); // dispatcher-servlet.xml내 BeanNameViewResolver 정의
|
||||
mv.addObject("downloadFile", file);
|
||||
mv.addObject("fname", attachFileVO.getFileName());
|
||||
mv.addObject("fname", attachFileVO.getOrignlFileNm());
|
||||
|
||||
return mv;
|
||||
}
|
||||
|
||||
@ -49,8 +49,14 @@ public class UUID {
|
||||
return articleID;
|
||||
}
|
||||
|
||||
public static String getNewFileMask() {
|
||||
return StringUtil.getTimeStamp("yyyyMMddhhmmss") + getNewUUIDWithAlphaNum();
|
||||
public static String getNewAttachFileId() {
|
||||
//return StringUtil.getTimeStamp("yyyyMMddhhmmss") + getNewUUIDWithAlphaNum();
|
||||
return getNlibCommonID("AT", 35);
|
||||
}
|
||||
|
||||
public static String getNewStreFileNm() {
|
||||
// NQ202109300311510712
|
||||
return "NQ" + StringUtil.getTimeStamp() + getNlibCommonID(null, 5);
|
||||
}
|
||||
|
||||
public static String getNewFileId() {
|
||||
|
||||
@ -5,74 +5,114 @@
|
||||
|
||||
<select id="listAttachFiles" parameterType="String" resultType="AttachFileVO">
|
||||
SELECT
|
||||
A.FILE_MASK
|
||||
, A.FILE_ID
|
||||
, A.FILE_SEQ
|
||||
, A.FILE_NAME
|
||||
, A.FILE_SIZE
|
||||
, A.FILE_TYPE_CD
|
||||
, A.DOWNLOAD_COUNT
|
||||
, A.DOWNLOAD_EXPIRE_DATE
|
||||
, A.DOWNLOAD_LIMIT_COUNT
|
||||
, DATE_FORMAT(A.REG_DATE, '%Y-%m-%d') AS REG_DD
|
||||
, A.DELETE_YN
|
||||
, A.STREAMING_URL
|
||||
, A.CONTENT
|
||||
, A.ATCH_TYPE_CD
|
||||
FROM J_ATTACHFILE A
|
||||
WHERE A.FILE_ID = #{attachFileId}
|
||||
ORDER BY A.FILE_SEQ
|
||||
B.ATTACH_FILE_ID
|
||||
, B.FILE_SN
|
||||
, B.FILE_STRE_COURS
|
||||
, B.STRE_FILE_NM
|
||||
, B.ORIGNL_FILE_NM
|
||||
, B.FILE_EXTSN
|
||||
, B.FILE_CN
|
||||
, B.FILE_SIZE
|
||||
FROM BD_FILE A
|
||||
JOIN BD_FILEDETAIL B ON (A.ATTACH_FILE_ID = B.ATTACH_FILE_ID)
|
||||
WHERE A.ATTACH_FILE_ID = #{attachFileId}
|
||||
AND A.USE_AT = 'Y'
|
||||
AND B.USE_AT = 'Y'
|
||||
ORDER BY B.FILE_SN
|
||||
</select>
|
||||
|
||||
<select id="selectAttachFile" parameterType="AttachFileVO" resultType="AttachFileVO">
|
||||
SELECT
|
||||
B.ATTACH_FILE_ID
|
||||
, B.FILE_SN
|
||||
, B.FILE_STRE_COURS
|
||||
, B.STRE_FILE_NM
|
||||
, B.ORIGNL_FILE_NM
|
||||
, B.FILE_EXTSN
|
||||
, B.FILE_CN
|
||||
, B.FILE_SIZE
|
||||
FROM BD_FILE A
|
||||
JOIN BD_FILEDETAIL B ON (A.ATTACH_FILE_ID = B.ATTACH_FILE_ID)
|
||||
WHERE A.ATTACH_FILE_ID = #{attachFileId}
|
||||
AND B.FILE_SN = #{fileSn}
|
||||
AND A.USE_AT = 'Y'
|
||||
AND B.USE_AT = 'Y'
|
||||
</select>
|
||||
|
||||
<insert id="insertAttachFile" parameterType="AttachFileVO">
|
||||
INSERT INTO J_ATTACHFILE (
|
||||
FILE_MASK
|
||||
, FILE_ID
|
||||
, FILE_SEQ
|
||||
, FILE_NAME
|
||||
, FILE_SIZE
|
||||
, FILE_TYPE_CD
|
||||
, DOWNLOAD_COUNT
|
||||
, DOWNLOAD_EXPIRE_DATE
|
||||
, DOWNLOAD_LIMIT_COUNT
|
||||
, REG_DATE
|
||||
, DELETE_YN
|
||||
, STREAMING_URL
|
||||
, CONTENT
|
||||
, ATCH_TYPE_CD
|
||||
<select id="checkAttachFileDownload" parameterType="AttachFileVO" resultType="String">
|
||||
SELECT 'Y' AS checkResult
|
||||
<if test='bdType != null and bdType.equals("QNA")'>
|
||||
FROM BD_NLIB_QNA
|
||||
WHERE BD_TYPE = 'QNA'
|
||||
AND BD_ATTACH_FILE_ID = #{attachFileId}
|
||||
AND (SECRET_YN = 'N' OR REG_ID = #{mbInfoId})
|
||||
AND USE_YN = 'Y'
|
||||
</if>
|
||||
<if test='bdType != null and bdType.equals("FAQ")'>
|
||||
FROM BD_NLIB_QNA
|
||||
WHERE BD_TYPE = UPPER('FAQ')
|
||||
AND BD_ATTACH_FILE_ID = #{attachFileId}
|
||||
AND USE_YN = 'Y'
|
||||
</if>
|
||||
<if test='bdType != null and bdType.equals("ANCMNT")'>
|
||||
FROM BD_NLIB_ANCMNT
|
||||
WHERE BD_ATTACH_FILE_ID = #{attachFileId}
|
||||
AND OPEN_YN = 'Y'
|
||||
AND DELETE_YN = 'N'
|
||||
AND DATE_FORMAT(NOW(), '%Y%m%d') BETWEEN IFNULL(POST_START_DATE,'00010101') AND IFNULL(POST_END_DATE, '99991231')
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<insert id="insertAttachFileGroup" parameterType="AttachFileVO">
|
||||
INSERT INTO BD_FILE (
|
||||
ATTACH_FILE_ID
|
||||
, REG_DD
|
||||
, USE_AT
|
||||
) VALUES (
|
||||
#{fileMask}
|
||||
, #{fileId}
|
||||
, #{fileSeq}
|
||||
, #{fileName}
|
||||
, #{fileSize}
|
||||
, #{fileTypeCd}
|
||||
, 0
|
||||
, NULL
|
||||
, NULL
|
||||
#{attachFileId}
|
||||
, NOW()
|
||||
, 'N'
|
||||
, NULL
|
||||
, NULL
|
||||
, #{atchTypeCd}
|
||||
, 'Y'
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="deleteAttachFile" parameterType="AttachFileVO">
|
||||
UPDATE J_ATTACHFILE SET DELETE_YN = 'Y'
|
||||
WHERE FILE_MASK = #{fileMask}
|
||||
AND FILE_ID = #{fileId}
|
||||
AND FILE_SEQ = #{fileSeq}
|
||||
<insert id="insertAttachFile" parameterType="AttachFileVO">
|
||||
<selectKey resultType="int" keyProperty="fileSn" order="BEFORE">
|
||||
SELECT IFNULL(MAX(FILE_SN) + 1, 1)
|
||||
FROM BD_FILEDETAIL
|
||||
WHERE ATTACH_FILE_ID = #{attachFileId}
|
||||
</selectKey>
|
||||
INSERT INTO BD_FILEDETAIL (
|
||||
ATTACH_FILE_ID
|
||||
, FILE_SN
|
||||
, FILE_STRE_COURS
|
||||
, STRE_FILE_NM
|
||||
, ORIGNL_FILE_NM
|
||||
, FILE_EXTSN
|
||||
, FILE_CN
|
||||
, FILE_SIZE
|
||||
, USE_AT
|
||||
) VALUES (
|
||||
#{attachFileId}
|
||||
, IFNULL(#{fileSn}, 1)
|
||||
, #{fileStreCours}
|
||||
, #{streFileNm}
|
||||
, #{orignlFileNm}
|
||||
, #{fileExtsn}
|
||||
, NULL
|
||||
, #{fileSize}
|
||||
, 'Y'
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="deleteAttachFileGroup" parameterType="AttachFileVO">
|
||||
UPDATE BD_FILE SET USE_AT = 'N'
|
||||
WHERE ATTACH_FILE_ID = #{attachFileId}
|
||||
</update>
|
||||
|
||||
<update id="increaseDownloadCount" parameterType="AttachFileVO">
|
||||
<![CDATA[
|
||||
UPDATE J_ATTACHFILE SET DOWNLOAD_COUNT = (IFNULL(DOWNLOAD_COUNT, 0) + 1)
|
||||
WHERE FILE_MASK = #{fileMask}
|
||||
AND FILE_ID = #{fileId}
|
||||
AND FILE_SEQ = #{fileSeq}
|
||||
AND IFNULL(DOWNLOAD_COUNT, 0) < IFNULL(DOWNLOAD_LIMIT_COUNT, (IFNULL(DOWNLOAD_COUNT, 0) + 1))
|
||||
]]>
|
||||
</update>
|
||||
<update id="deleteAttachFile" parameterType="AttachFileVO">
|
||||
UPDATE BD_FILEDETAIL SET USE_AT = 'N'
|
||||
WHERE ATTACH_FILE_ID = #{attachFileId}
|
||||
AND FILE_SN = #{fileSn}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
||||
@ -69,7 +69,7 @@ $(window.document).ready(function() {
|
||||
// 파일 업로드 처리 : 시작
|
||||
//--------------------------------------------------------------------
|
||||
// 파일업로드 객체 생성
|
||||
myDropzone = new Dropzone("form#myDropzone", { url: "${pageContext.request.contextPath}/fileupload/uploadFilesAjax.do?subPathKey=fileupload.bbs.qna.subpath"});
|
||||
myDropzone = new Dropzone("form#myDropzone", { url: "${pageContext.request.contextPath}/fileupload/uploadFilesAjax.do?subPathKey=fileupload.bbs.qna.subpath&attachFileId=${searchArticle.bdAttachFileId}"});
|
||||
|
||||
// 각 파일별 업로드 성공시 호출됨 (1th called)
|
||||
myDropzone.on("success", function(file, responseText) {
|
||||
@ -77,13 +77,13 @@ $(window.document).ready(function() {
|
||||
console.log("file upload success : responseText = " + responseText);
|
||||
console.log("fileUpDone count : " + fileList.length);
|
||||
var idx = fileList.length;
|
||||
fileList[idx] = {
|
||||
"fileMask" : jobj[0].fileMask,
|
||||
"fileId" : jobj[0].fileId,
|
||||
"fileSeq" : (idx+1),
|
||||
"fileName" : jobj[0].fileName,
|
||||
"fileSize" : jobj[0].fileSize,
|
||||
"atchTypeCd" : jobj[0].atchTypeCd,
|
||||
fileList[idx++] = {
|
||||
"attachFileId" : jobj[0].attachFileId,
|
||||
"streFileNm" : jobj[0].streFileNm,
|
||||
"orignlFileNm" : jobj[0].orignlFileNm,
|
||||
"fileExtsn" : jobj[0].fileExtsn,
|
||||
"fileSn" : jobj[0].fileSn,
|
||||
"fileSize" : jobj[0].fileSize
|
||||
};
|
||||
console.log("success : " + file.name + " -> " + "data > " + jobj[0].streFileNm);
|
||||
});
|
||||
|
||||
@ -58,32 +58,21 @@ function fn_delete() {
|
||||
}
|
||||
|
||||
// 파일 다운로드
|
||||
function fn_downloadFile(fileMask, fileId, fileSeq, fileName) {
|
||||
function fn_downloadFile(attachFileId, fileSn) {
|
||||
|
||||
if(fileMask == null || fileMask.trim().length < 1) {
|
||||
if(attachFileId == null || attachFileId.trim().length < 1) {
|
||||
alert("파일정보를 확인해 주시기 바랍니다.[1]");
|
||||
return;
|
||||
}
|
||||
|
||||
if(fileId == null || fileId.trim().length < 1) {
|
||||
alert("파일정보를 확인해 주시기 바랍니다.[2]");
|
||||
return;
|
||||
}
|
||||
|
||||
if(fileSeq < 1) {
|
||||
if(fileSn < 1) {
|
||||
alert("파일정보를 확인해 주시기 바랍니다.[3]");
|
||||
return;
|
||||
}
|
||||
|
||||
if(fileName == null || fileName.trim().length < 1) {
|
||||
alert("파일정보를 확인해 주시기 바랍니다.[4]");
|
||||
return;
|
||||
}
|
||||
|
||||
$("#fileMask").val(fileMask);
|
||||
$("#fileId").val(fileId);
|
||||
$("#fileSeq").val(fileSeq);
|
||||
$("#fileName").val(fileName);
|
||||
$("#attachFileId").val(attachFileId);
|
||||
$("#fileSn").val(fileSn);
|
||||
|
||||
$("#downloadFileForm").submit();
|
||||
|
||||
}
|
||||
@ -153,7 +142,7 @@ function fn_downloadFile(fileMask, fileId, fileSeq, fileName) {
|
||||
// 파일정보 : 저장파일ID=원파일명
|
||||
%>
|
||||
<c:forEach var="attachFile" items="${article.attachFiles }">
|
||||
<a href="javascript:void(0);" onclick="fn_downloadFile('${attachFile.fileMask}', '${attachFile.fileId}', ${attachFile.fileSeq}, '${attachFile.fileName}')">${attachFile.fileName} (${attachFile.fileSize} byte(s))</a><br/>
|
||||
<a href="javascript:void(0);" onclick="fn_downloadFile('${attachFile.attachFileId}', ${attachFile.fileSn})">${attachFile.orignlFileNm} (${attachFile.fileSize} byte(s))</a><br/>
|
||||
</c:forEach>
|
||||
</td>
|
||||
</tr>
|
||||
@ -187,11 +176,12 @@ function fn_downloadFile(fileMask, fileId, fileSeq, fileName) {
|
||||
<form name="downloadFileForm" id="downloadFileForm"
|
||||
action="${pageContext.request.contextPath}/fileupload/downloadAttachFile.do"
|
||||
method="post">
|
||||
<input type="text" name="subPathKey" id="subPathKey" value="fileupload.bbs.qna.subpath" readonly />
|
||||
<input type="text" name="fileMask" id="fileMask" value="" readonly />
|
||||
<input type="text" name="fileId" id="fileId" value="" readonly />
|
||||
<input type="text" name="fileSeq" id="fileSeq" value="" readonly />
|
||||
<input type="text" name="fileName" id="fileName" value="" readonly />
|
||||
<input type="text" name="bdType" id="bdType" value="QNA" readonly />
|
||||
<input type="text" name="attachFileId" id="attachFileId" value="" readonly />
|
||||
<input type="text" name="streFileNm" id="streFileNm" value="" readonly />
|
||||
<input type="text" name="fileSn" id="fileSn" value="" readonly />
|
||||
<input type="text" name="orignlFileNm" id="orignlFileNm" value="" readonly />
|
||||
|
||||
</form>
|
||||
|
||||
</body>
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
<title>서비스 이동중</title>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
//$("#frm").submit();
|
||||
$("#frm").submit();
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user