묻고답하기 삭제기능 추가
This commit is contained in:
parent
c34019243d
commit
aafd4bee61
7
data/dataxml/uac.service.board.qna_DELETE.xml
Normal file
7
data/dataxml/uac.service.board.qna_DELETE.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<!-- uac.service.board.qna_DELETE.xml -->
|
||||
<result>
|
||||
<!-- 상세내용 -->
|
||||
<articleNo>10</articleNo>
|
||||
</result>
|
||||
|
||||
@ -58,7 +58,8 @@ public class BoardDAO extends DataApi
|
||||
}
|
||||
|
||||
public DataApiResVO deleteQnA(DataApiReqVO reqVO) {
|
||||
return null;
|
||||
reqVO.setReqUrl(RESOURCE_URI);
|
||||
return delete(reqVO);
|
||||
}
|
||||
|
||||
public DataApiResVO insertQnA(DataApiReqVO reqVO) {
|
||||
|
||||
@ -59,7 +59,7 @@ public class BoardServiceImpl implements BoardService
|
||||
}
|
||||
|
||||
public DataApiResVO deleteQnA(DataApiReqVO reqVO) {
|
||||
return null;
|
||||
return boardDAO.deleteQnA(reqVO);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -100,10 +100,12 @@ public class BoardController extends NlibCommonController
|
||||
String searchKeyword = paramMap.get("searchKeyword");
|
||||
String pageIndex = StringUtil.getString(paramMap.get("pageIndex"), "1");
|
||||
String pageSize = StringUtil.getString(paramMap.get("pageSize") , DEFUALT_PAGE_SIZE);
|
||||
String message = paramMap.get("message");
|
||||
|
||||
log.debug("listQnAs > pageIndex = " + pageIndex);
|
||||
log.debug("listQnAs > pageSize = " + pageSize);
|
||||
log.debug("listQnAs > searchKeyword = " + searchKeyword);
|
||||
log.debug("listQnAs > message = " + message);
|
||||
|
||||
// 페이징 사이즈 코드 목록 조회
|
||||
DataApiReqVO reqVOforPageSize = new DataApiReqVO();
|
||||
@ -117,6 +119,7 @@ public class BoardController extends NlibCommonController
|
||||
model.addAttribute("pageSize" , pageSize);
|
||||
model.addAttribute("searchKeyword", searchKeyword);
|
||||
model.addAttribute("pageSizeCodes", resVOforPageSize.getList());
|
||||
model.addAttribute("message" , message);
|
||||
|
||||
return "nlib/board/listQnAs";
|
||||
}
|
||||
@ -262,7 +265,7 @@ public class BoardController extends NlibCommonController
|
||||
return "redirect:/board/insertQnAForm.do";
|
||||
}
|
||||
|
||||
return "redirect:nlib/board/listQnAs";
|
||||
return "redirect:/board/listQnAs.do";
|
||||
}
|
||||
|
||||
@RequestMapping("/board/verifyWriter.do")
|
||||
@ -405,26 +408,99 @@ public class BoardController extends NlibCommonController
|
||||
// 처리결과 확인
|
||||
if(!updateResVO.isSuccess()) {
|
||||
message = updateResVO.getResultMessage();
|
||||
addParamsToModel(paramMap, model);
|
||||
model.addAttribute("message", message);
|
||||
addParamsToModel(paramMap, model, null, "pageIndex,pageSize,searchKeyword,articleNo");
|
||||
addParamsToModel(paramMap, model, "article"
|
||||
, "articleNo,articleType,"
|
||||
+ "articleTypeName,title,articlePassword,readCount,"
|
||||
+ "regDate, reguserName, repStats, "
|
||||
+ "email, contentQeust, "
|
||||
+ "contentQuestFile");
|
||||
|
||||
return "redirect:/board/updateQnAForm.do";
|
||||
}
|
||||
|
||||
// 반환 정보
|
||||
model.addAttribute("articleNo" , updateResVO.getInfoItem("articleNo")); // 신규등록된 게시물 ID
|
||||
model.addAttribute("article" , resVO.getInfo());
|
||||
model.addAttribute("message" , "성공적으로 수정처리되었습니다.");
|
||||
model.addAttribute("message" , "성공적으로 수정되었습니다.");
|
||||
|
||||
// 검색 정보
|
||||
model.addAttribute("pageIndex" , pageIndex);
|
||||
model.addAttribute("pageSize" , pageSize);
|
||||
model.addAttribute("searchKeyword", searchKeyword);
|
||||
|
||||
return "redirect:nlib/board/selectQnA";
|
||||
return "redirect:/board/selectQnA.do";
|
||||
}
|
||||
|
||||
@RequestMapping("/board/deleteQnA.do")
|
||||
public String deleteQnA(HttpServletRequest req) {
|
||||
return "nlib/board/deleteQnA";
|
||||
public String deleteQnA(HttpServletRequest req, Authentication authentication, @RequestParam Map<String, String> paramMap, ModelMap model) {
|
||||
|
||||
String message = null;
|
||||
|
||||
// 목록 이동시 전달할 매개변수
|
||||
String searchKeyword = paramMap.get("searchKeyword");
|
||||
String pageIndex = paramMap.get("pageIndex");
|
||||
String pageSize = paramMap.get("pageSize");
|
||||
|
||||
// 게시물 번호
|
||||
String articleNo = paramMap.get("articleNo");
|
||||
String articlePassword = paramMap.get("articlePassword");
|
||||
|
||||
log.debug("deleteQnA > pageIndex = " + pageIndex);
|
||||
log.debug("deleteQnA > pageSize = " + pageSize);
|
||||
log.debug("deleteQnA > searchKeyword = " + searchKeyword);
|
||||
log.debug("deleteQnA > articleNo = " + articleNo);
|
||||
log.debug("deleteQnA > articlePassword = " + articlePassword);
|
||||
|
||||
if(StringUtil.isEmpty(articlePassword)) {
|
||||
model.addAttribute("message", "비밀빈호가 올바르지 않습니다.(D1)");
|
||||
return "redirect:/board/selectQnA.do";
|
||||
}
|
||||
|
||||
//-------------------------------
|
||||
// REQ VO 구성
|
||||
//-------------------------------
|
||||
DataApiReqVO reqVO = new DataApiReqVO();
|
||||
reqVO.setAuthKey(createAuthKey(req, authentication));
|
||||
reqVO.setPageIndex(pageIndex);
|
||||
reqVO.setPageSize(pageSize);
|
||||
reqVO.addInfoItem("boardNo", "QNA"); // 게시판ID
|
||||
reqVO.addInfoItem("articleNo", articleNo); // 게시물번호
|
||||
|
||||
// 요청
|
||||
DataApiResVO resVO = boardService.selectQnA(reqVO);
|
||||
|
||||
// 비밀번호 확인
|
||||
HashMap<String, Object> article = resVO.getInfo();
|
||||
String shaArticlePassword = nlibPasswordEncoder.encode(articlePassword);
|
||||
log.debug("updateQnAForm > 입력받은 비밀번호를 SHA256 암호화한 값 : " + shaArticlePassword);
|
||||
|
||||
if(!shaArticlePassword.equals(article.get("articlePassword"))) {
|
||||
model.addAttribute("message", "비밀번호가 올바르지 않습니다.(D2)");
|
||||
return "redirect:/board/selectQnA.do";
|
||||
}
|
||||
|
||||
// 삭제 처리
|
||||
DataApiResVO delResVO = boardService.deleteQnA(reqVO);
|
||||
|
||||
// 처리결과 확인
|
||||
if(!delResVO.isSuccess()) {
|
||||
message = delResVO.getResultMessage();
|
||||
model.addAttribute("message", message);
|
||||
addParamsToModel(paramMap, model, null, "pageIndex,pageSize,searchKeyword,articleNo");
|
||||
|
||||
return "redirect:/board/selectQnA.do";
|
||||
}
|
||||
|
||||
// 반환 정보
|
||||
model.addAttribute("message" , "성공적으로 삭제되었습니다.");
|
||||
|
||||
// 검색 정보
|
||||
model.addAttribute("pageIndex" , pageIndex);
|
||||
model.addAttribute("pageSize" , pageSize);
|
||||
model.addAttribute("searchKeyword", searchKeyword);
|
||||
|
||||
return "redirect:/board/listQnAs.do";
|
||||
}
|
||||
|
||||
}
|
||||
@ -183,13 +183,31 @@ public class NlibCommonController {
|
||||
}
|
||||
public ModelMap addParamsToModel(Map<String, String> paramMap, ModelMap model, String upperMapName, String itemNames) {
|
||||
|
||||
|
||||
if(paramMap == null || paramMap.size() < 1) return model;
|
||||
if(model == null) return model;
|
||||
|
||||
String filter = null;
|
||||
if(StringUtil.isNotEmpty(itemNames)) {
|
||||
filter = "," + itemNames + ",";
|
||||
filter = filter.replaceAll(" ", "");
|
||||
}
|
||||
|
||||
boolean existUpperMap = StringUtil.isNotEmpty(upperMapName);
|
||||
Map<String, String> uppperMap = new HashMap<String, String>();
|
||||
Map<String, String> uppperMap = null;
|
||||
if(existUpperMap) uppperMap = new HashMap<String, String>();
|
||||
|
||||
for(String key : paramMap.keySet()) {
|
||||
model.addAttribute(key, paramMap.get(key));
|
||||
|
||||
if(filter != null && !filter.contains("," + key + ",")) {
|
||||
continue;
|
||||
}
|
||||
if(existUpperMap) {
|
||||
uppperMap.put(key, paramMap.get(key));
|
||||
} else {
|
||||
model.addAttribute(key, paramMap.get(key));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return model;
|
||||
|
||||
@ -161,6 +161,8 @@ function fn_searchArticle(pageSize, pageIndex) {
|
||||
|
||||
<h1>${pageTitle }</h1>
|
||||
|
||||
메시지 : ${message}
|
||||
<br/>
|
||||
<form name="articleForm" id="articleForm"
|
||||
action="${pageContext.request.contextPath}/board/listQnAs.do"
|
||||
method="post">
|
||||
|
||||
@ -37,6 +37,57 @@
|
||||
<html lang="ko">
|
||||
<head>
|
||||
<title>${pageTitle}</title>
|
||||
|
||||
<script type="text/javaScript" language="javascript">
|
||||
|
||||
//선택한 게시글 상세 보기로 이동
|
||||
function fn_view_detail(articleNo) {
|
||||
$("#articleNo").val(articleNo);
|
||||
$("#articleForm").attr("action", "${pageContext.request.contextPath}/board/selectQnA.do");
|
||||
$("#articleForm").submit();
|
||||
}
|
||||
|
||||
// 선택한 게시글 상세 보기로 이동
|
||||
function fn_list() {
|
||||
$("#articleForm").attr("action", "${pageContext.request.contextPath}/board/listQnAs.do");
|
||||
$("#articleForm").submit();
|
||||
}
|
||||
|
||||
// 수정 화면 이동
|
||||
function fn_updateForm(passwd) {
|
||||
if(passwd == null || passwd == "") {
|
||||
alert("수정을 위한 게시물의 비밀번호를 입력하여 주시기 바랍니다.");
|
||||
return;
|
||||
}
|
||||
|
||||
$("#articlePassword").val(passwd);
|
||||
$("#articleForm").attr("action", "${pageContext.request.contextPath}/board/updateQnAForm.do");
|
||||
$("#articleForm").submit();
|
||||
}
|
||||
|
||||
// 게시글 수정위한 비밀번호 확인
|
||||
function fn_updatePassword() {
|
||||
fn_promptPassword("수정을 위한 글 비밀번호를 입력하여 주시기 바랍니다.", "111", "fn_updateForm")
|
||||
}
|
||||
|
||||
// 게시글 삭제위한 비밀번호 확인
|
||||
function fn_deletePassword() {
|
||||
fn_promptPassword("삭제를 위한 글 비밀번호를 입력하여 주시기 바랍니다.", "111", "fn_delete")
|
||||
}
|
||||
|
||||
// 삭제 처리
|
||||
function fn_delete(passwd) {
|
||||
if(passwd == null || passwd == "") {
|
||||
alert("삭제를 위한 게시물의 비밀번호를 입력하여 주시기 바랍니다.");
|
||||
return;
|
||||
}
|
||||
|
||||
$("#articlePassword").val(passwd);
|
||||
$("#articleForm").attr("action", "${pageContext.request.contextPath}/board/deleteQnA.do");
|
||||
$("#articleForm").submit();
|
||||
}
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@ -103,50 +154,15 @@
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
<button type="button" name="btnNew" id="btnNew" class="float"
|
||||
<!-- 관련 작업 버튼 -->
|
||||
<button type="button" name="btnList" id="btnList" class="float"
|
||||
onclick="fn_list()">목록</button>
|
||||
<button type="button" name="btnNew" id="btnNew" class="float"
|
||||
<button type="button" name="btnUpdate" id="btnUpdate" class="float"
|
||||
onclick="fn_updatePassword()">수정</button>
|
||||
|
||||
<button type="button" name="btnDelete" id="btnDelete" class="float"
|
||||
onclick="fn_deletePassword()">삭제</button>
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
<script type="text/javaScript" language="javascript">
|
||||
|
||||
//선택한 게시글 상세 보기로 이동
|
||||
function fn_view_detail(articleNo) {
|
||||
$("#articleNo").val(articleNo);
|
||||
$("#articleForm").attr("action", "${pageContext.request.contextPath}/board/selectQnA.do");
|
||||
$("#articleForm").submit();
|
||||
}
|
||||
|
||||
// 선택한 게시글 상세 보기로 이동
|
||||
function fn_list() {
|
||||
$("#articleForm").attr("action", "${pageContext.request.contextPath}/board/listQnAs.do");
|
||||
$("#articleForm").submit();
|
||||
}
|
||||
|
||||
// 수정을 위한 비밀번호 입력
|
||||
function fn_updateForm(passwd) {
|
||||
if(passwd == null || passwd == "") {
|
||||
alert("수정을 위한 게시물의 비밀번호를 입력하여 주시기 바랍니다.");
|
||||
return;
|
||||
}
|
||||
|
||||
$("#articlePassword").val(passwd);
|
||||
$("#articleForm").attr("action", "${pageContext.request.contextPath}/board/updateQnAForm.do");
|
||||
$("#articleForm").submit();
|
||||
}
|
||||
|
||||
// 게시글 수정 화면으로 이동
|
||||
function fn_updatePassword() {
|
||||
fn_promptPassword("비밀번호를 입력하여 주시기 바랍니다.", "111", "fn_updateForm")
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user