junekeunsong 4 jaren geleden
bovenliggende
commit
8035b58c37

+ 30 - 6
src/main/java/com/lemon/lifecenter/controller/BoardController.java

@@ -499,15 +499,35 @@ public class BoardController extends LifeCenterController {
     @RequestMapping("/qna/content/answer")
     public String boardQnaAnswer(HttpServletRequest request, HttpServletResponse response,
             @ModelAttribute("dto") final BoardDTO dto) {
+
+        String sesGroupIdx = LifeCenterSessionController.getSession(request, "sesGroupIdx");
         
-        logger.error("postSeq -- > " + dto.getPostSeq());
-        logger.error("answerId -- > " + dto.getAnswerId());
-        logger.error("answerContent -- > " + dto.getAnswerContent());
+        if (!sesGroupIdx.equals("1")) {
+            LifeCenterFunction.scriptMessage( response, "alertBox({ txt: '권한이 없습니다.', callBack : function(){ location.href='./list'; } });" );
+            return "/common/blank";
+        }
+
         boardService.qnaAnswerInsert(dto);
         
         return "redirect:/qna/content?postSeq=" + dto.getPostSeq();
     }
     
+    @RequestMapping("/qna/content/answerDelete")
+    public String boardQnaAnswerDelete(HttpServletRequest request, HttpServletResponse response,
+            @ModelAttribute("dto") final BoardDTO dto) {
+        
+        String sesGroupIdx = LifeCenterSessionController.getSession(request, "sesGroupIdx");
+        
+        if (!sesGroupIdx.equals("1")) {
+            LifeCenterFunction.scriptMessage( response, "alertBox({ txt: '권한이 없습니다.', callBack : function(){ location.href='./list'; } });" );
+            return "/common/blank";
+        }
+        
+        dto.setAnswerContent("");
+        boardService.qnaAnswerInsert(dto);
+        return "redirect:/qna/content?postSeq=" + dto.getPostSeq(); 
+    }
+    
     @RequestMapping("/qna/edit")
     public ModelAndView boarQnadEdit(HttpServletRequest request, HttpServletResponse response,
             @RequestParam(value="postSeq", required=false, defaultValue="") int postSeq) {
@@ -596,12 +616,16 @@ public class BoardController extends LifeCenterController {
             @RequestParam(value="fileName", required=false, defaultValue="") String fileName) {
         
         String sesId = LifeCenterSessionController.getSession(request, "sesId");
+        String sesGroupIdx = LifeCenterSessionController.getSession(request, "sesGroupIdx");
         
-        if (!sesId.equals(createBy)) {
-            LifeCenterFunction.scriptMessage( response, "alertBox({ txt: '해당 글을 삭제할 수 없습니다.', callBack : function(){ location.href='/qna/list'; } });" );
-            return "/common/blank";
+        if (!sesGroupIdx.equals("1")) {
+            if (!sesId.equals(createBy)) {
+                LifeCenterFunction.scriptMessage( response, "alertBox({ txt: '해당 글을 삭제할 수 없습니다.', callBack : function(){ location.href='/qna/list'; } });" );
+                return "/common/blank";
+            }
         }
         
+        
         BoardDTO dto = new BoardDTO();
         dto.setPostSeq(postSeq);
         dto.setBoardType("Q");

+ 1 - 1
src/main/resources/config.properties

@@ -12,4 +12,4 @@ config.nonface.api.appVC  = https://lemon.medihere.com/app/vc
 config.nonface.api.key    = 94e1ab361de9b8ca057c84c19cf1d907
 config.nonface.api.secret = 56a06414162da198f450e604a736ab7a550e3cc1095e142f9847d3533a044a26
 config.nonface.clint.id   = mohw
-config.file.path = ../notice-temp
+config.file.path = ../attach-file

+ 4 - 1
src/main/resources/mybatis/mapper/board/board.xml

@@ -115,6 +115,7 @@
               FROM BOARD_NOTICE BN
               LEFT JOIN BOARD_ATTACH_FILE BAF
                 ON BN.POST_SEQ = BAF.POST_SEQ
+               AND BAF.BOARD_TYPE = 'N'
              WHERE 1 = 1
                AND BN.POST_SEQ = #{postSeq}
         ]]>
@@ -234,7 +235,8 @@
                    VIEWS                                         AS views,
                    (SELECT FILE_EXTENSION
                       FROM BOARD_ATTACH_FILE BAF
-                    WHERE BAF.POST_SEQ = BR.POST_SEQ)            AS fileExtension
+                    WHERE BAF.POST_SEQ = BR.POST_SEQ)            AS fileExtension,
+                   ANSWER_ID                                     AS answerId
               FROM BOARD_REQUEST BR
              WHERE 1 = 1
          ]]>
@@ -301,6 +303,7 @@
               FROM BOARD_REQUEST BR
               LEFT JOIN BOARD_ATTACH_FILE BAF
                 ON BR.POST_SEQ = BAF.POST_SEQ
+               AND BAF.BOARD_TYPE = 'Q'
              WHERE 1 = 1
                AND BR.POST_SEQ = #{postSeq}
         ]]>

+ 11 - 8
src/main/webapp/WEB-INF/jsp/notice/content.jsp

@@ -83,8 +83,8 @@ function goListPage(){
                                                 <th class="text-center">작성일</th>
                                                 <td><c:out value="${content.createDate}" /></td>
                                                 
-                                                <th>조회수</th>
-                                                <td><c:out value="${content.views}"></c:out></td>
+                                                <th class="text-center">조회수</th>
+                                                <td><fmt:formatNumber value="${content.views}" pattern="#,###" /></td>
                                             </tr>
                                             
                                             <tr>
@@ -93,12 +93,15 @@ function goListPage(){
                                                  </td>
                                             </tr>
                                             
-                                            <tr>
-                                                <td colspan="6">
-                                                    <span class="badge bg-primary">첨부파일</span>
-                                                    <a href="./content/file?postSeq=${content.postSeq}" class="text-dark" target="_blank"><c:out value="${content.fileOriginalName}" /></a>
-                                                </td>
-                                            </tr>
+                                            <c:if test="${content.fileOriginalName ne ''}">
+                                                <tr>
+                                                    <td colspan="6">
+                                                        <span class="badge bg-primary">첨부파일</span>
+                                                        <a href="./content/file?postSeq=${content.postSeq}" class="text-dark" target="_blank"><c:out value="${content.fileOriginalName}" /></a>
+                                                    </td>
+                                                </tr>
+                                            </c:if>
+
                                         </table>
                                         
                                         <table class="mt-3 table mobile-table">

+ 2 - 2
src/main/webapp/WEB-INF/jsp/notice/list.jsp

@@ -112,11 +112,11 @@
                                                             <tr>
                                                                 <td><c:out value="${pageNum}" /></td>
                                                                 <td class="text-left">
-                                                                    <a href="./content?postSeq=${l.postSeq}"><c:out value="${l.title}" /></a> <span class="badge badge-danger font-weight-normal" style="font-size:13px;">답변 완료</span>
+                                                                    <a href="./content?postSeq=${l.postSeq}"><c:out value="${l.title}" /></a>
                                                                 </td>
                                                                 <td><c:out value="${l.createByName}(${l.createBy})" /></td>
                                                                 <td><c:out value="${l.createDate}" /></td>
-                                                                <td><c:out value="${l.views}" /></td>
+                                                                <td><fmt:formatNumber value="${l.views}" pattern="#,###" /></td>
                                                                 <td>
                                                                     <c:if test="${l.fileExtension eq ''}">
                                                                         -

+ 85 - 24
src/main/webapp/WEB-INF/jsp/qna/content.jsp

@@ -40,6 +40,42 @@ function answerConfirm(){
     return false;
 }
 
+function answerDelete() {
+    alertBox({ type : "confirm", 
+        txt : "정말 답변을 삭제하시겠습니까? (답변삭제 시 복구가 볼가능합니다.)", 
+        callBack : function( result ){
+            console.log( result );
+            if( result ){
+                var newForm = $( "#sendForm" ).clone();
+                newForm.attr("id", "answerFormDelete");
+                newForm.attr("method", "post");
+                newForm.attr("action", "./content/answerDelete");
+
+                $(document.body).append(newForm);
+                newForm.submit();
+                $("#answerForm").remove();
+            }
+        }
+    });
+}
+
+function answerUpdate() {
+    if( $("#updateBtn").prop( "accessKey" ) == "false" ){
+        $("#answerContent").hide();
+        $("#answerContentHide").show();
+        $("#updateBtn").text("취소");
+        $("#updateBtn").prop( "accessKey", "true" );
+        $("#insertBtn").show();
+    } else {
+        $("#answerContent").show();
+        $("#answerContentHide").hide();
+        $("#updateBtn").text("수정");
+        $("#updateBtn").prop( "accessKey", "false" );
+        $("#insertBtn").hide();
+    }
+    
+}
+
 var listPage = '<c:out value="${referer}"/>'.replaceAll( "&amp;", "&" );
 if( listPage.includes( '/qna/list' ) ) {
     encodeURIComponent(listPage);
@@ -86,36 +122,45 @@ function goListPage(){
                                     <div class="card-body">
                                         <table class="table mobile-table">
                                             <colgroup>
-                                                <col style="width:75%">
-                                                <col style="width:">
+                                                <col style="width:10%">
+                                                <col style="width:20%">
+                                                <col style="width:10%">
+                                                <col style="width:20%">
+                                                <col style="width:10%">
                                                 <col style="width:">
                                             </colgroup>
                                             
                                             <tr>
-                                                <td>조회수 : <c:out value="${content.views}"></c:out></td>
-                                                <th class="text-center">작성자</th>
-                                                <td><c:out value="${content.createByName}(${content.createBy})" /></td>
+                                                <td colspan="6" class="text-bold text-info" style="font-size:16px;"><c:out value="${content.title}" /></td>
                                             </tr>
                                             
                                             <tr>
-                                                <td class="text-bold text-info"><c:out value="${content.title}" /></td>
+                                                <th class="text-center">작성자</th>
+                                                <td><c:out value="${content.createByName}(${content.createBy})" /></td>
+                                                
                                                 <th class="text-center">작성일</th>
                                                 <td><c:out value="${content.createDate}" /></td>
+                                                
+                                                <th class="text-center">조회수</th>
+                                                <td><fmt:formatNumber value="${content.views}" pattern="#,###" /></td>
                                             </tr>
                                             
                                             <tr>
-                                                <td colspan="3" style="white-space: pre-line;"><div style="min-height:200px;"><c:out value="${content.content}" /></div></td>
+                                                <td colspan="6" style="white-space: pre-line;"><div style="min-height:200px;"><c:out value="${content.content}" /></div></td>
                                             </tr>
                                             
-                                            <tr>
-                                                <td colspan="3">
-                                                    <span class="badge bg-primary">첨부파일</span>
-                                                    <a href="./content/file?postSeq=${content.postSeq}" class="text-dark" target="_blank"><c:out value="${content.fileOriginalName}" /></a>
-                                                </td>
-                                            </tr>
+                                            <c:if test="${content.fileOriginalName ne ''}">
+                                                <tr>
+                                                    <td colspan="6">
+                                                        <span class="badge bg-primary">첨부파일</span>
+                                                        <a href="./content/file?postSeq=${content.postSeq}" class="text-dark" target="_blank"><c:out value="${content.fileOriginalName}" /></a>
+                                                    </td>
+                                                </tr>
+                                            </c:if>
+
                                         </table>
                                         
-                                        <c:if test="${groupIdx eq 1}">
+                                        <c:if test="${groupIdx eq 1 or content.answerContent ne ''}">
                                             <input type="hidden" name="answerId" value="${sesId}">
                                             <table class="mt-3 table mobile-table">
                                                 <colgroup>
@@ -125,15 +170,12 @@ function goListPage(){
                                                 
                                                 <tr>
                                                     <th>작성자</th>
-<!--                                                     <td> -->
-<%--                                                         <c:out value="${sesName}(${sesId})" /> --%>
-<!--                                                     </td> -->
-                                                    <c:if test="${content.answerId eq ''}">
+                                                    <c:if test="${content.answerContent eq ''}">
                                                         <td>
                                                             <c:out value="${sesName}(${sesId})" />
                                                         </td>
                                                     </c:if>
-                                                    <c:if test="${content.answerId ne ''}">
+                                                    <c:if test="${content.answerContent ne ''}">
                                                         <td>
                                                             <c:out value="${content.answerName}(${content.answerId})" />
                                                         </td>
@@ -147,12 +189,12 @@ function goListPage(){
                                                         </td>
                                                     </c:if>
                                                     <c:if test="${content.answerContent ne ''}">
-                                                        <td colspan="3" style="white-space: pre-line;"><div style="min-height:100px;"><c:out value="${content.answerContent}" /></div></td>
+                                                        <td colspan="3" style="white-space: pre-line;"><div id="answerContent"><c:out value="${content.answerContent}" /></div><textarea class="form-control" style="display:none;" id="answerContentHide" rows="2" cols="" name="answerContent" placeholder="내용을 입력하세요" maxlength="1000" required><c:out value="${item.content}" /></textarea></td>
                                                     </c:if>
                                                 </tr>
                                             </table>
                                             
-                                            <c:if test="${content.answerId eq ''}">
+                                            <c:if test="${content.answerContent eq ''}">
                                                 <div class="row mt-3">
                                                     <div class="col-12">
                                                         <div class="text-right">
@@ -161,7 +203,19 @@ function goListPage(){
                                                     </div>
                                                 </div>
                                             </c:if>
-
+                                            <c:if test="${groupIdx eq 1}">
+                                                <c:if test="${content.answerContent ne ''}">
+                                                    <div class="row mt-3">
+                                                        <div class="col-12">
+                                                            <div class="text-right">
+                                                                <button type="button" id="deleteBtn" onclick="answerDelete();" class="answer-btn btn btn-danger w100">삭제</button>
+                                                                <button type="button" id="updateBtn" accessKey="false" onclick="answerUpdate();" class="answer-btn btn btn-primary w100">수정</button>
+                                                                <button type="button" id="insertBtn" onclick="answerConfirm();" class="answer-btn btn btn-secondary w100" style="display:none;">등록</button>
+                                                            </div>
+                                                        </div>
+                                                    </div>
+                                                </c:if>
+                                            </c:if>
                                         </c:if>
                                         
                                         <table class="mt-3 table mobile-table">
@@ -198,8 +252,15 @@ function goListPage(){
                                             <div class="col-12">
                                                 <div class="text-right">
                                                     <c:if test="${sesId eq content.createBy}">
-                                                        <button type="button" onclick="location.href='./edit?postSeq=${content.postSeq}';" class="btn btn-primary w100">수정</button>
-                                                        <button type="button" onclick="deleteConfirm();" class="btn btn-danger w100">삭제</button>
+                                                        <c:if test="${content.answerContent eq ''}">
+                                                            <button type="button" onclick="location.href='./edit?postSeq=${content.postSeq}';" class="btn btn-primary w100">수정</button>
+                                                            <button type="button" onclick="deleteConfirm();" class="btn btn-danger w100">삭제</button>
+                                                        </c:if>
+                                                    </c:if>
+                                                    <c:if test="${sesId ne content.createBy}">
+                                                        <c:if test="${groupIdx eq '1'}">
+                                                            <button type="button" onclick="deleteConfirm();" class="btn btn-danger w100">원글 삭제</button>
+                                                        </c:if>
                                                     </c:if>
                                                     <button type="button" class="btn btn-outline-primary w100" onclick="goListPage();">목록</button>
                                                 </div>

+ 5 - 3
src/main/webapp/WEB-INF/jsp/qna/list.jsp

@@ -106,16 +106,18 @@
                                                 
                                                     <c:when test="${total > 0}">
                                                         <c:forEach var="l" items="${list}" varStatus="lStatus">
-                                                        
                                                             <c:set var="pageNum" value="${ ( total - lStatus.index ) - ( (page - 1) * pageSize ) }" />
                                                             <tr>
                                                                 <td><c:out value="${pageNum}" /></td>
-                                                                <td>
+                                                                <td class="text-left">
                                                                     <a href="./content?postSeq=${l.postSeq}"><c:out value="${l.title}" /></a>
+                                                                    <c:if test="${l.answerId ne ''}">
+                                                                        <span class="badge badge-danger font-weight-normal" style="font-size:13px;">답변 완료</span>
+                                                                    </c:if>
                                                                 </td>
                                                                 <td><c:out value="${l.createByName}(${l.createBy})" /></td>
                                                                 <td><c:out value="${l.createDate}" /></td>
-                                                                <td><c:out value="${l.views}" /></td>
+                                                                <td><fmt:formatNumber value="${l.views}" pattern="#,###" /></td>
                                                                 <td>
                                                                     <c:if test="${l.fileExtension eq ''}">
                                                                         -