첨부파일 제한 처리 완료 (5건, 각 파일 10MB)
This commit is contained in:
parent
8627c2b3f0
commit
e9ce7294a3
@ -56,6 +56,15 @@ public interface QnaService extends BoardService
|
|||||||
*/
|
*/
|
||||||
public String canModify(ArticleVO articleVO) throws Exception;
|
public String canModify(ArticleVO articleVO) throws Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 해당 QNA 글을 변경할 수 있는지 여부를 확인한다.
|
||||||
|
*
|
||||||
|
* @param articleVO
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public String canModify(ArticleVO articleVO, String mbInfoId) throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 해당 QNA 글을 읽을 수 있는지 여부를 확인한다.
|
* 해당 QNA 글을 읽을 수 있는지 여부를 확인한다.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -185,6 +185,7 @@ public class QnaServiceImpl extends BoardServiceImpl implements QnaService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 해당 QNA 글을 변경할 수 있는지 여부를 확인한다.
|
* 해당 QNA 글을 변경할 수 있는지 여부를 확인한다.
|
||||||
|
* (articleVO.getLoginedMbInfoId() 값을 확인하여 DB에 저장된 게시글을 조회하여 검사하므로 호출 전 설정 필요)
|
||||||
*
|
*
|
||||||
* @param articleVO
|
* @param articleVO
|
||||||
* @return
|
* @return
|
||||||
@ -196,13 +197,30 @@ public class QnaServiceImpl extends BoardServiceImpl implements QnaService
|
|||||||
return "로그인 후, 이용하실 수 있습니다.";
|
return "로그인 후, 이용하실 수 있습니다.";
|
||||||
}
|
}
|
||||||
|
|
||||||
ArticleVO savedArticleVO = selectArticle(articleVO);
|
return canModify(selectArticle(articleVO), articleVO.getLoginedMbInfoId());
|
||||||
|
}
|
||||||
|
|
||||||
if(!"Y".equals(savedArticleVO.getMyQnaYn())) {
|
/**
|
||||||
|
* 해당 QNA 글을 변경할 수 있는지 여부를 확인한다.
|
||||||
|
*
|
||||||
|
* @param articleVO
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public String canModify(ArticleVO articleVO, String mbInfoId) throws Exception {
|
||||||
|
if(StringUtil.isEmpty(mbInfoId)) {
|
||||||
|
return "로그인 후, 이용하실 수 있습니다.";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(articleVO == null) {
|
||||||
|
return "대상 게시글 정보가 없습니다.";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!"Y".equals(articleVO.getMyQnaYn())) {
|
||||||
return "본인의 글만 변경할 수 있습니다.";
|
return "본인의 글만 변경할 수 있습니다.";
|
||||||
}
|
}
|
||||||
|
|
||||||
if("Y".equals(savedArticleVO.getAnswerYn())) {
|
if("Y".equals(articleVO.getAnswerYn())) {
|
||||||
return "이미 답변완료된 글은 변경할 수 없습니다.";
|
return "이미 답변완료된 글은 변경할 수 없습니다.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -250,8 +250,6 @@ public class QnaController extends NlibCommonController {
|
|||||||
, RedirectAttributes redirectAttrs
|
, RedirectAttributes redirectAttrs
|
||||||
, ModelMap model) throws Exception {
|
, ModelMap model) throws Exception {
|
||||||
|
|
||||||
log.debug("========================================> insertQna : 진입함");
|
|
||||||
|
|
||||||
NlibLoginVO loginVO = getNlibLoginVO(authentication);
|
NlibLoginVO loginVO = getNlibLoginVO(authentication);
|
||||||
|
|
||||||
String message = null;
|
String message = null;
|
||||||
@ -307,7 +305,6 @@ public class QnaController extends NlibCommonController {
|
|||||||
|
|
||||||
String attachFileId = (String)(fileListObj.get(0).get("attachFileId"));
|
String attachFileId = (String)(fileListObj.get(0).get("attachFileId"));
|
||||||
if(StringUtil.isEmpty(attachFileId)) {
|
if(StringUtil.isEmpty(attachFileId)) {
|
||||||
log.error("첨부파일 아이디(attachFileId) 값은 필수 항목입니다. 첨부파일 처리에 실패하였습니다. 그러나, 게시물 등록은 계속 진행됩니다.");
|
|
||||||
attachFileId = UUID.getNewAttachFileId();
|
attachFileId = UUID.getNewAttachFileId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -381,7 +378,10 @@ public class QnaController extends NlibCommonController {
|
|||||||
|
|
||||||
// 권한 및 변경 가능 상태 체크
|
// 권한 및 변경 가능 상태 체크
|
||||||
articleVO.setLoginedMbInfoId(getMbInfoId(request));
|
articleVO.setLoginedMbInfoId(getMbInfoId(request));
|
||||||
String message = qnaService.canModify(articleVO);
|
|
||||||
|
ArticleVO articleOrg = qnaService.selectArticle(articleVO);
|
||||||
|
String message = qnaService.canModify(articleOrg, getMbInfoId(request));
|
||||||
|
|
||||||
if(message != null) {
|
if(message != null) {
|
||||||
redirectAttrs.addFlashAttribute("searchArticle", articleVO);
|
redirectAttrs.addFlashAttribute("searchArticle", articleVO);
|
||||||
redirectAttrs.addFlashAttribute("message", message);
|
redirectAttrs.addFlashAttribute("message", message);
|
||||||
@ -422,38 +422,35 @@ public class QnaController extends NlibCommonController {
|
|||||||
|
|
||||||
if(fileListObj != null && fileListObj.size() > 0) {
|
if(fileListObj != null && fileListObj.size() > 0) {
|
||||||
|
|
||||||
String attachFileId = (String)(fileListObj.get(0).get("attachFileId"));
|
String attachFileId = articleOrg.getBdAttachFileId();
|
||||||
if(StringUtil.isEmpty(attachFileId)) {
|
if(StringUtil.isEmpty(attachFileId)) {
|
||||||
log.error("첨부파일 아이디(attachFileId) 값은 필수 항목입니다. 첨부파일 처리에 실패하였습니다. 그러나, 게시물 등록은 계속 진행됩니다.");
|
attachFileId = UUID.getNewAttachFileId();
|
||||||
|
articleVO.setBdAttachFileId(attachFileId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(StringUtil.isNotEmpty(attachFileId)) {
|
if(StringUtil.isNotEmpty(articleVO.getBdAttachFileId())) articleVO.setBdAttachFileId(attachFileId);
|
||||||
if(StringUtil.isNotEmpty(articleVO.getBdAttachFileId())) articleVO.setBdAttachFileId(attachFileId);
|
|
||||||
|
|
||||||
String fileSStreCours = NlibProperty.getProperty("fileupload.base.path") + NlibProperty.getProperty("fileupload.bbs.qna.subpath") + "/";
|
String fileSStreCours = NlibProperty.getProperty("fileupload.base.path") + NlibProperty.getProperty("fileupload.bbs.qna.subpath") + "/";
|
||||||
List<AttachFileVO> attachFiles = new ArrayList<AttachFileVO>();
|
List<AttachFileVO> attachFiles = new ArrayList<AttachFileVO>();
|
||||||
|
|
||||||
for(int i=0; i<fileListObj.size(); i++) {
|
for(int i=0; i<fileListObj.size(); i++) {
|
||||||
Map finfo = fileListObj.get(i);
|
Map finfo = fileListObj.get(i);
|
||||||
AttachFileVO fVO = new AttachFileVO();
|
AttachFileVO fVO = new AttachFileVO();
|
||||||
|
|
||||||
fVO.setAttachFileId(attachFileId);
|
fVO.setAttachFileId(attachFileId);
|
||||||
fVO.setFileStrePath(fileSStreCours);
|
fVO.setFileStrePath(fileSStreCours);
|
||||||
fVO.setStreFileNm((String)finfo.get("streFileNm"));
|
fVO.setStreFileNm((String)finfo.get("streFileNm"));
|
||||||
fVO.setOrignlFileNm((String)finfo.get("orignlFileNm"));
|
fVO.setOrignlFileNm((String)finfo.get("orignlFileNm"));
|
||||||
fVO.setFileExt((String)finfo.get("fileExt"));
|
fVO.setFileExt((String)finfo.get("fileExt"));
|
||||||
fVO.setFileSize(((Integer)finfo.get("fileSize")).intValue());
|
fVO.setFileSize(((Integer)finfo.get("fileSize")).intValue());
|
||||||
|
|
||||||
File f = new File(fVO.getFileStrePath() + fVO.getStreFileNm());
|
File f = new File(fVO.getFileStrePath() + fVO.getStreFileNm());
|
||||||
if(!f.exists() || !f.isFile()) continue;
|
if(!f.exists() || !f.isFile()) continue;
|
||||||
|
|
||||||
attachFiles.add(fVO);
|
|
||||||
}
|
|
||||||
articleVO.setAttachFiles(attachFiles);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
attachFiles.add(fVO);
|
||||||
|
}
|
||||||
|
articleVO.setAttachFiles(attachFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 첨부파일 삭제
|
// 첨부파일 삭제
|
||||||
@ -484,11 +481,13 @@ public class QnaController extends NlibCommonController {
|
|||||||
if(removedFileListObj != null && removedFileListObj.size() > 0) {
|
if(removedFileListObj != null && removedFileListObj.size() > 0) {
|
||||||
|
|
||||||
String attachFileId = (String)(removedFileListObj.get(0).get("attachFileId"));
|
String attachFileId = (String)(removedFileListObj.get(0).get("attachFileId"));
|
||||||
|
if(StringUtil.isEmpty(attachFileId)) attachFileId = articleOrg.getBdAttachFileId();
|
||||||
|
|
||||||
if(StringUtil.isEmpty(attachFileId)) {
|
if(StringUtil.isEmpty(attachFileId)) {
|
||||||
log.error("첨부파일 아이디(attachFileId) 값은 필수 항목입니다. 첨부파일 삭제에 실패하였습니다. 그러나, 게시물 변경은 계속 진행됩니다.");
|
log.error("첨부파일 아이디(attachFileId) 값은 필수 항목입니다. 첨부파일 삭제에 실패하였습니다. 그러나, 게시물 변경은 계속 진행됩니다.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(StringUtil.isNotEmpty(attachFileId) && attachFileId.equals(articleVO.getBdAttachFileId())) {
|
if(StringUtil.isNotEmpty(attachFileId) && attachFileId.equals(articleOrg.getBdAttachFileId())) {
|
||||||
|
|
||||||
List<AttachFileVO> removedAttachFiles = new ArrayList<AttachFileVO>();
|
List<AttachFileVO> removedAttachFiles = new ArrayList<AttachFileVO>();
|
||||||
|
|
||||||
|
|||||||
@ -51,15 +51,15 @@
|
|||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
var myDropzone = null; <% // 파일드롭다운 객체 %>
|
var myDropzone = null; <% // 파일드롭다운 객체 %>
|
||||||
var fileList = new Array(); <% // 업로드된 파일 정보 %>
|
var fileList = new Array(); <% // 업로드된 파일 정보 %>
|
||||||
var delFileList = new Array(); <% // 삭제된 파일 정보 %>
|
var delFileList = new Array(); <% // 삭제된 파일 정보 %>
|
||||||
var IN_PROC = false; <% // 현재 상태가 업로드처리중에 있는지 여부 %>
|
var IN_PROC = false; <% // 현재 상태가 업로드처리중에 있는지 여부 %>
|
||||||
|
var UPLOADING_FILE_CNT = 0; <% // 업로드할 파일 수 %>
|
||||||
var isModified = false;
|
var isModified = false;
|
||||||
|
|
||||||
var oEditors = [];
|
var oEditors = [];
|
||||||
|
|
||||||
|
|
||||||
$(window.document).ready(function() {
|
$(window.document).ready(function() {
|
||||||
fn_setPageTitle("<c:out value='${pageTitle}'/>");
|
fn_setPageTitle("<c:out value='${pageTitle}'/>");
|
||||||
|
|
||||||
@ -151,17 +151,13 @@ $(window.document).ready(function() {
|
|||||||
|
|
||||||
// 모든 업로드 처리 완료 시 호출됨
|
// 모든 업로드 처리 완료 시 호출됨
|
||||||
myDropzone.on("queuecomplete", function() {
|
myDropzone.on("queuecomplete", function() {
|
||||||
var targetCnt = this.getAcceptedFiles().length;
|
|
||||||
var uploadCnt = fileList.length;
|
var uploadCnt = fileList.length;
|
||||||
|
|
||||||
console.log(targetCnt + " > " + uploadCnt);
|
|
||||||
|
|
||||||
if(uploadCnt > 0) {
|
if(uploadCnt > 0) {
|
||||||
$("#fileList").val(JSON.stringify(JSON.stringify(fileList)));
|
$("#fileList").val(JSON.stringify(JSON.stringify(fileList)));
|
||||||
}
|
}
|
||||||
if(IN_PROC) {
|
if(IN_PROC) {
|
||||||
if(targetCnt > 0 && targetCnt != uploadCnt) {
|
if(UPLOADING_FILE_CNT > 0 && UPLOADING_FILE_CNT != uploadCnt) {
|
||||||
alert("일부 첨부파일 등록이 실패하였습니다.\n총 " + targetCnt + "건의 첨부파일 중 " + uploadCnt + "건이 정상적으로 업로드 되었습니다.\n글 등록을 계속 진행합니다.");
|
alert("일부 첨부파일 등록이 실패하였습니다.\n총 " + UPLOADING_FILE_CNT + "건의 업로드할 첨부파일 중 " + uploadCnt + "건이 정상적으로 업로드 되었습니다.\n글 등록(수정)을 계속 진행합니다.");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn_saveSubmit();
|
fn_saveSubmit();
|
||||||
@ -250,7 +246,8 @@ function fn_save() {
|
|||||||
$("#delFileList").val(JSON.stringify(JSON.stringify(delFileList)));
|
$("#delFileList").val(JSON.stringify(JSON.stringify(delFileList)));
|
||||||
|
|
||||||
// 파일 업로드 처리
|
// 파일 업로드 처리
|
||||||
if(myDropzone.getAcceptedFiles().length > 0) {
|
UPLOADING_FILE_CNT = myDropzone.countAcceptedUploadingFiles();
|
||||||
|
if(UPLOADING_FILE_CNT > 0) {
|
||||||
myDropzone.processQueue();
|
myDropzone.processQueue();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -524,6 +524,22 @@
|
|||||||
return _results;
|
return _results;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// NLIB : 새로 올려질 파일 건수 확인
|
||||||
|
Dropzone.prototype.countAcceptedUploadingFiles = function() {
|
||||||
|
var file, _i, _len, _ref, _results;
|
||||||
|
_ref = this.files;
|
||||||
|
var _retCnt = 0;
|
||||||
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
|
file = _ref[_i];
|
||||||
|
|
||||||
|
if (file.fileUploadType == 'uploaded') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
_retCnt++;
|
||||||
|
}
|
||||||
|
return _retCnt;
|
||||||
|
};
|
||||||
|
|
||||||
Dropzone.prototype.getRejectedFiles = function() {
|
Dropzone.prototype.getRejectedFiles = function() {
|
||||||
var file, _i, _len, _ref, _results;
|
var file, _i, _len, _ref, _results;
|
||||||
_ref = this.files;
|
_ref = this.files;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user