댓글 업데이트 로직 변경
All checks were successful
LocalNet_front/pipeline/head This commit looks good

This commit is contained in:
nevermoregb 2025-03-17 22:47:57 +09:00
parent 942f2c660c
commit c730ea6cd3

View File

@ -71,7 +71,11 @@
</div> </div>
<!-- HTML 콘텐츠 렌더링 --> <!-- HTML 콘텐츠 렌더링 -->
<div class="board-content text-body mw-100 overflow-hidden text-break" style="line-height: 1.6" v-html="$common.contentToHtml(boardContent)"></div> <div
class="board-content text-body mw-100 overflow-hidden text-break"
style="line-height: 1.6"
v-html="$common.contentToHtml(boardContent)"
></div>
<!-- 좋아요 버튼 --> <!-- 좋아요 버튼 -->
<div class="row justify-content-center my-10"> <div class="row justify-content-center my-10">
@ -300,7 +304,7 @@
LOCGOBBAD: isDislike ? 'T' : 'F', LOCGOBBAD: isDislike ? 'T' : 'F',
}); });
await fetchComments(); fetchComments(pagination.value.currentPage);
}; };
// //
@ -324,8 +328,10 @@
profileImg: comment.profileImg || '', profileImg: comment.profileImg || '',
likeClicked: comment.likeClicked || false, likeClicked: comment.likeClicked || false,
dislikeClicked: comment.dislikeClicked || false, dislikeClicked: comment.dislikeClicked || false,
createdAtRaw: new Date(comment.LOCCMTRDT), // // createdAtRaw: new Date(comment.LOCCMTRDT), //
createdAt: formattedDate(comment.LOCCMTRDT), // // createdAt: formattedDate(comment.LOCCMTRDT), //
createdAtRaw: new Date(comment.LOCCMTUDT), //
createdAt: formattedDate(comment.LOCCMTUDT), //
children: [], // children: [], //
updateAtRaw: comment.LOCCMTUDT, updateAtRaw: comment.LOCCMTUDT,
})); }));
@ -348,8 +354,10 @@
boardId: reply.LOCBRDSEQ, boardId: reply.LOCBRDSEQ,
parentId: reply.LOCCMTPNT, // ID parentId: reply.LOCCMTPNT, // ID
content: reply.LOCCMTRPY || '내용 없음', content: reply.LOCCMTRPY || '내용 없음',
createdAtRaw: new Date(reply.LOCCMTRDT), // createdAtRaw: new Date(reply.LOCCMTRDT),
createdAt: formattedDate(reply.LOCCMTRDT), // createdAt: formattedDate(reply.LOCCMTRDT),
createdAtRaw: new Date(reply.LOCCMTUDT),
createdAt: formattedDate(reply.LOCCMTUDT),
likeCount: reply.likeCount || 0, likeCount: reply.likeCount || 0,
dislikeCount: reply.dislikeCount || 0, dislikeCount: reply.dislikeCount || 0,
likeClicked: false, likeClicked: false,
@ -426,27 +434,16 @@
// //
const handleCommentReply = async reply => { const handleCommentReply = async reply => {
try { const response = await axios.post(`board/${currentBoardId.value}/comment`, {
const response = await axios.post(`board/${currentBoardId.value}/comment`, { LOCBRDSEQ: currentBoardId.value,
LOCBRDSEQ: currentBoardId.value, LOCCMTRPY: reply.comment,
LOCCMTRPY: reply.comment, LOCCMTPWD: reply.password || null,
LOCCMTPWD: reply.password || null, LOCCMTPNT: reply.parentId,
LOCCMTPNT: reply.parentId, LOCBRDTYP: reply.isCheck ? '300102' : null,
LOCBRDTYP: reply.isCheck ? '300102' : null, });
});
if (response.status === 200) { if (response.status === 200) {
if (response.data.code === 200) { fetchComments(pagination.value.currentPage);
await fetchComments();
} else {
alert('대댓글 작성을 실패했습니다.');
}
}
} catch (error) {
if (error.response) {
alert('오류가 발생했습니다.');
}
alert('오류가 발생했습니다.');
} }
}; };
@ -490,7 +487,7 @@
return null; return null;
}; };
// ( ) // ( )
const editComment = comment => { const editComment = comment => {
password.value = ''; password.value = '';
passwordCommentAlert.value = ''; passwordCommentAlert.value = '';
@ -676,9 +673,6 @@
passwordCommentAlert.value = '비밀번호가 일치하지 않습니다.'; passwordCommentAlert.value = '비밀번호가 일치하지 않습니다.';
} }
} catch (error) { } catch (error) {
if (error.response?.status === 401) {
passwordCommentAlert.value = '비밀번호가 일치하지 않습니다';
}
passwordCommentAlert.value = '비밀번호가 일치하지 않습니다'; passwordCommentAlert.value = '비밀번호가 일치하지 않습니다';
} }
}; };
@ -720,7 +714,7 @@
}); });
if (response.data.code === 200) { if (response.data.code === 200) {
await fetchComments(); await fetchComments(pagination.value.currentPage);
closeAllPasswordAreas(); closeAllPasswordAreas();
if (targetComment) { if (targetComment) {
@ -740,28 +734,27 @@
// //
const handleSubmitEdit = async (comment, editedContent) => { const handleSubmitEdit = async (comment, editedContent) => {
if (!checkValidation(comment, editedContent)) return; if (!checkValidation(comment, editedContent)) return; //
togglePassword(); togglePassword();
try {
const response = await axios.put(`board/comment/${comment.commentId}`, {
LOCCMTSEQ: comment.commentId,
LOCCMTRPY: editedContent,
});
if (response.status === 200) { const response = await axios.put(`board/comment/${comment.commentId}`, {
const targetComment = findCommentById(comment.commentId, comments.value); LOCCMTSEQ: comment.commentId,
if (targetComment) { LOCCMTRPY: editedContent.trim(),
targetComment.content = editedContent; // });
targetComment.isEditTextarea = false; //
togglePassword('close'); if (response.status === 200) {
} else { togglePassword('close');
toastStore.onToast('수정할 댓글을 찾을 수 없습니다.', 'e'); fetchComments(pagination.value.currentPage);
} return;
} else { // const targetComment = findCommentById(comment.commentId, comments.value);
toastStore.onToast('댓글 수정 실패했습니다.', 'e');
} // if (targetComment) {
} catch (error) { // targetComment.content = editedContent.trim(); //
toastStore.onToast('댓글 수정 중 오류가 발생하였습니다.', 'e'); // targetComment.isEditTextarea = false; //
// togglePassword('close');
// }
} else {
toastStore.onToast('댓글 수정을 실패하였습니다', 'e');
} }
}; };