댓글 수정하기

dev_bert
kyebyungha 3 years ago
parent 2367e8ea9f
commit ee41f42de7

@ -19,6 +19,9 @@ public interface M_Bf_boardBO {
public abstract int update_bf_board_vote_by_b_no(DataMap paramMap) throws Exception;
public abstract int insert_bf_board_comment(DataMap paramMap) throws Exception;
public abstract int delete_bf_board_comment_by_b_no(DataMap paramMap) throws Exception;
public abstract int update_bf_board(DataMap paramMap) throws Exception;
public abstract Object insert_bf_board(DataMap paramMap) throws Exception;

@ -188,6 +188,29 @@ public class M_Bf_boardBOImpl extends AbstractBOManager implements M_Bf_boardBO
return result;
}
public int delete_bf_board_comment_by_b_no(DataMap paramMap) throws Exception{
int result = 0;
try {
generalDAO.setNamespace(SQLMAP_NAMESPACE);
generalDAO.startTransaction();
result = generalDAO.delete("delete_bf_board_comment_by_b_no", paramMap);
/*
result = generalDAO.delete("delete_bf_board_comment_by_b_no", paramMap);
result = generalDAO.delete("delete_bf_board_like_by_b_no", paramMap);
result = generalDAO.delete("delete_bf_board_img_by_b_no", paramMap);
*/
generalDAO.commitTransaction();
} catch (SQLException e) {
throw e;
}finally{
generalDAO.endTransaction();
}
return result;
}
public int insert_bf_board_like_by_b_no(DataMap paramMap) throws Exception{
int result = 0;
@ -253,8 +276,12 @@ public class M_Bf_boardBOImpl extends AbstractBOManager implements M_Bf_boardBO
generalDAO.setNamespace(SQLMAP_NAMESPACE);
generalDAO.startTransaction();
result = (int) generalDAO.insert("insert_bf_board_comment_by_b_no", paramMap);
if( paramMap.get("ct_no") !=null && !paramMap.get("ct_no").toString().equals("")) {
paramMap.put("ct_no", Integer.parseInt(paramMap.get("ct_no").toString()));
result = (int)generalDAO.update("update_bf_board_comment_by_b_no", paramMap);
}else {
result = (int) generalDAO.insert("insert_bf_board_comment_by_b_no", paramMap);
}
generalDAO.commitTransaction();
} catch (SQLException e) {
throw e;

@ -341,6 +341,34 @@ public class M_Bf_boardController extends AbstractControllerManager {
return rm;
}
@RequestMapping(value="ajax_delete_bf_board_comment", method=RequestMethod.POST)
@ResponseBody
public HashMap<String, Object> ajax_delete_bf_board_comment(@ModelAttribute("model") ModelMap model, HttpServletRequest request, HttpServletResponse response) {
DataMap paramMap = gmUtil.getDataMapFromRequest(request);
HashMap<String, Object> rm = new HashMap<String, Object>();
rm.put("RESULT", ConstantResultCode.RESULT_INIT);
try {
boolean is_login = gmUtil.setSessionForMobileMember(request, paramMap);
if(is_login == false) {
}else{
Object result = bf_boardBo.delete_bf_board_comment_by_b_no(paramMap);
rm.put("result", result);
if(result != null) rm.put("result_txt", "add");
}
} catch (Exception ex1) {
ex1.printStackTrace();
rm.put("RESULT", ConstantResultCode.RESULT_EXCEPTION);
}
return rm;
}
/*
@RequestMapping(value="delete_bf_community_comment")
public String delete_bf_community_comment(@ModelAttribute("model") ModelMap model, HttpServletRequest request, HttpServletResponse response

@ -196,6 +196,12 @@
DELETE FROM tbl_bf_board
WHERE bd_no = #bd_no#
</delete>
<delete id="delete_bf_board_comment_by_b_no" parameterClass="dataMap">
DELETE FROM tbl_bf_board_comment
WHERE bd_no = #bd_no#
and ct_no = #ct_no#
</delete>
<delete id="delete_bf_board_img_by_b_no" parameterClass="dataMap">
DELETE FROM tbl_bf_board_attach
@ -296,6 +302,12 @@
</selectKey>
</insert>
<update id="update_bf_board_comment_by_b_no" parameterClass="dataMap">
UPDATE tbl_bf_board_comment
SET comment = #comment#
WHERE ct_no = #ct_no#
</update>
<select id="select_bf_board_comment_by_b_no" resultClass="dataMap" parameterClass="dataMap">
SELECT
x.ct_no

@ -172,11 +172,11 @@
</div>
</div>
<!-- option -->
<div class="option2_btn">
<div class="option2_btn" data-ctno= ${item['ct_no']!}>
<div href="#" class="option"></div>
</div>
</div>
<div class="comment_text">
<div class="comment_text" data-ctno= ${item['ct_no']!}>
${item['comment']!}
</div>
</div>
@ -244,13 +244,13 @@
<!-- 옵션 모달 -->
<ul>
<li>
<a>
<a id="edit_reply">
<div class="edit_icon reply"></div>
수정하기
</a>
</li>
<li>
<a>
<a id="delete_reply">
<div class="delect_icon reply"></div>
삭제하기
</a>
@ -294,6 +294,7 @@
<script>
var $ct_no ;
function fncRemove(e) {
$(e).parent().remove();
}
@ -350,7 +351,8 @@
function insert_reply(){
var data = {
bd_no : ${model ['rm']['bd_no']!}
bd_no : ${model ['rm']['bd_no']!}
,ct_no : $ct_no
,comment : $("#reply").val()
}
$.ajax({
@ -361,32 +363,47 @@
error:function(request,status,error){
Swal.fire({text:"등록되지 않았습니다"})
},
success:function(result){
Swal.fire({text:"처리 되었습니다"})
var tag ="<div class=\"comment\">";
tag +=" <div class=\"comment_profile\">";
tag +=" <!-- profile -->";
tag +=" <div class=\"profile_cont\">";
tag +=" <div class=\"profile_img\">";
tag +=" <img src=\"${URL_ROOT}/m/img/community/community_writer_img.png\" alt=\"프로필 사진\">";
tag +=" </div>";
tag +=" <div class=\"profile_info\">";
tag +=" <p>"+result.reply.replyer+"</p>";
tag +=" <p>"+result.reply.reg_tm+"</p>";
tag +=" </div>";
tag +=" </div>";
tag +=" <!-- option -->";
tag +=" <div class=\"option2_btn\">";
tag +=" <div href=\"#\" class=\"option\"></div>";
tag +=" <input type='hidden' name='ct_no' vale='"+result.reply.ct_no+"' />";
tag +=" </div>";
tag +=" </div>";
tag +=" <div class=\"comment_text\">";
tag += result.reply.comment;
tag +=" </div>";
tag +="</div>";
$(".community_comment").prepend(tag);
$("#reply").val('');
success:function(result){
if($ct_no == null) {
var tag ="<div class=\"comment\">";
tag +=" <div class=\"comment_profile\">";
tag +=" <!-- profile -->";
tag +=" <div class=\"profile_cont\">";
tag +=" <div class=\"profile_img\">";
tag +=" <img src=\"${URL_ROOT}/m/img/community/community_writer_img.png\" alt=\"프로필 사진\">";
tag +=" </div>";
tag +=" <div class=\"profile_info\">";
tag +=" <p>"+result.reply.replyer+"</p>";
tag +=" <p>"+result.reply.reg_tm+"</p>";
tag +=" </div>";
tag +=" </div>";
tag +=" <!-- option -->";
tag +=" <div class=\"option2_btn\" data-ctno ="+result.reply.ct_no+">";
tag +=" <div href=\"#\" class=\"option\"></div>";
tag +=" </div>";
tag +=" </div>";
tag +=" <div class=\"comment_text\" data-ctno="+result.reply.ct_no+">";
tag += result.reply.comment;
tag +=" </div>";
tag +="</div>";
$(".community_comment").prepend(tag);
} else {
$(".comment_text").each( function(idx,ele) {
if(ele.dataset.ctno == $ct_no) {
ele.innerText = $("#reply").val() ;
return;
}
});
}
debugger;
$ct_no = null;
$("#reply").val('');
Swal.fire({text:"처리 되었습니다"}) ;
$(".option2_btn").on("click", function() {
$("#option2").toggleClass("open");
})
},
});
}
@ -549,6 +566,7 @@
$("#option1").toggleClass("open");
});
$(".option2_btn").on("click", function() {
$ct_no = this.dataset.ctno;
$("#option2").toggleClass("open");
})
$(".shared_btn").on("click", function() {
@ -563,28 +581,64 @@
});
$("#delete_board").on("click", function() {
$("#option1").removeClass("open");
Swal.fire({
text: "게시글을 삭제하시겠습니까?",
showCancelButton: true,
confirmButtonText: '네',
cancelButtonText: '취소'
}).then((result) => {
if(result.dismiss == 'cancel') return;
location.href = "${URL_ROOT}/m/bf_board/view_bf_delete_board.do?bd_tp=${model ['rm']['bd_tp']!}&bd_no=${model ['rm']['bd_no']!}";
});
});
$(".star").find("img").click(function(e){
var index = $(".star").find("img").index( this );
$("#star").val(index+1);
$(".star").find("img").each(function(idx, ele){
if(idx<= index){
ele.src ="${URL_STATIC_ROOT}/m/img/nutrition/nutrition_babyfood_search_star_on.png";
}else{
ele.src ="${URL_STATIC_ROOT}/m/img/nutrition/nutrition_babyfood_search_star.png";
}
});
});
$("#edit_reply").on("click", function() {
$("#option2").removeClass("open");
debugger;
$(".comment_text").each( function(idx,ele) {
if(ele.dataset.ctno == $ct_no) {
$("#reply").val(ele.innerText);
return;
}
});
});
$("#delete_reply").on("click", function() {
$("#option2").removeClass("open");
var index = $(".star").find("img").index( this )
var ctno = this.dataset.ctno;
var obj = this;
Swal.fire({
text: "게시글을 삭제하시겠습니까?",
showCancelButton: true,
confirmButtonText: '네',
cancelButtonText: '취소'
}).then((result) => {
if(result.dismiss == 'cancel') return;
var data = {
bd_no : ${model ['rm']['bd_no']!}
,ct_no : $ct_no
}
$.ajax({
url:'${URL_ROOT}/m/bf_board/ajax_delete_bf_board_comment.do?1=1',
type:'post',
data: data,
dataType:'json',
error:function(request,status,error){
Swal.fire({text:"삭제되지 않았습니다"});
},
success:function(result){
$(".option2_btn").each( function(idx,ele) {
if(ele.dataset.ctno == $ct_no) {
$(ele)[0].parentNode.parentNode.remove();
}
});
Swal.fire({text:"삭제 되었습니다"}) ;
}
});
});
});
$('.submit').on('click', function () {
insert_reply();

Loading…
Cancel
Save