From 99d89008ed6c49014df651a69cada0c61c6e1150 Mon Sep 17 00:00:00 2001 From: dyhj625 Date: Tue, 25 Feb 2025 10:04:41 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=EB=8C=93=EA=B8=80=EA=B3=BC=20=EB=8C=80?= =?UTF-8?q?=EB=8C=93=EA=B8=80=20=EC=9D=B5=EB=AA=85=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EC=A0=80=EC=9E=A5=EC=9E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/board/BoardComment.vue | 13 +- src/components/board/BoardCommentArea.vue | 24 +-- src/views/board/BoardView.vue | 174 +++++++++++++++------- 3 files changed, 138 insertions(+), 73 deletions(-) diff --git a/src/components/board/BoardComment.vue b/src/components/board/BoardComment.vue index 0dafc9a..4e82bb7 100644 --- a/src/components/board/BoardComment.vue +++ b/src/components/board/BoardComment.vue @@ -48,7 +48,7 @@ - +
  • -
  • @@ -124,7 +124,8 @@ const toggleComment = () => { // 부모 컴포넌트에 대댓글 추가 요청 const submitComment = (newComment) => { - emit('submitComment', { parentId: props.comment.commentId, ...newComment }); + console.log(newComment) + emit('submitComment', { parentId: props.comment.commentId, ...newComment, LOCBRDTYP: newComment.LOCBRDTYP }); isComment.value = false; }; @@ -141,7 +142,7 @@ const handleUpdateReaction = (reactionData) => { // 비밀번호 확인 const logPasswordAndEmit = () => { emit('submitPassword', props.comment, password.value); - password.value = ""; + password.value = ""; }; watch(() => props.comment.isEditTextarea, (newVal) => { diff --git a/src/components/board/BoardCommentArea.vue b/src/components/board/BoardCommentArea.vue index 30e9084..f1a4294 100644 --- a/src/components/board/BoardCommentArea.vue +++ b/src/components/board/BoardCommentArea.vue @@ -23,7 +23,7 @@
    - +
    -
    +
    @@ -60,7 +59,7 @@ diff --git a/src/views/board/BoardView.vue b/src/views/board/BoardView.vue index d2b37b4..c7a5dcc 100644 --- a/src/views/board/BoardView.vue +++ b/src/views/board/BoardView.vue @@ -59,10 +59,10 @@
--> - +
- +

현재 로그인한 사용자 ID: {{ currentUserId }}

게시글 작성자: {{ authorId }}

-

isAuthor 값: {{ isAuthor }}

+

isAuthor 값: {{ isAuthor }}

- +
- +
-
+
@@ -59,7 +60,7 @@ diff --git a/src/views/board/BoardView.vue b/src/views/board/BoardView.vue index c7a5dcc..1c8b6b2 100644 --- a/src/views/board/BoardView.vue +++ b/src/views/board/BoardView.vue @@ -366,17 +366,26 @@ const fetchComments = async (page = 1) => { // const isSubmitting = ref(false); // 댓글 작성 -const handleCommentSubmit = async (data) => { - const { comment, password } = data; - const LOCBRDTYP = data.LOCBRDTYP || null; // undefined 방지 +const handleCommentSubmit = async ({ comment, password }) => { + console.log('댓글') + //비밀번호 입력 안했을시 + // if (!password) { + // passwordAlert.value = "비밀번호를 입력해야 합니다."; + // return; + // } + + // console.log('비밀번호 눌렀음') + + // 중복 실행 방지 + // if (isSubmitting.value) return; + // isSubmitting.value = true; try { const response = await axios.post(`board/${currentBoardId.value}/comment`, { LOCBRDSEQ: currentBoardId.value, LOCCMTRPY: comment, LOCCMTPWD: password, - LOCCMTPNT: 1, - LOCBRDTYP // 익명 여부 전달 + LOCCMTPNT: 1 }); if (response.status === 200) { @@ -390,121 +399,48 @@ const handleCommentSubmit = async (data) => { } }; -// const handleCommentSubmit = async ({ comment, password, LOCBRDTYP }) => { -// console.log('댓글') -// //비밀번호 입력 안했을시 -// // if (!password) { -// // passwordAlert.value = "비밀번호를 입력해야 합니다."; -// // return; -// // } - -// // console.log('비밀번호 눌렀음') - -// // 중복 실행 방지 -// // if (isSubmitting.value) return; -// // isSubmitting.value = true; - -// try { -// // const response = await axios.post(`board/${currentBoardId.value}/comment`, { -// // LOCBRDSEQ: currentBoardId.value, -// // LOCCMTRPY: comment, -// // LOCCMTPWD: password, -// // LOCCMTPNT: 1 -// // }); - -// if (response.status === 200) { -// console.log('댓글 작성 성공:', response.data.message); -// await fetchComments(); -// } else { -// console.log('댓글 작성 실패:', response.data.message); -// } -// } catch (error) { -// console.log('댓글 작성 중 오류 발생:', error); -// } -// }; - // 대댓글 추가 (부모 `BoardCommentList`로부터 이벤트 받아서 처리) const handleCommentReply = async (reply) => { try { - // 익명 여부 체크 (체크박스가 체크되었을 경우 LOCBRDTYP을 300102로 설정) + // console.log('대댓글 작성 요청 데이터:', { + // LOCBRDSEQ: currentBoardId.value, + // LOCCMTRPY: reply.comment, + // LOCCMTPWD: reply.password || null, + // LOCCMTPNT: reply.parentId + // }); - const requestBody = { + const response = await axios.post(`board/${currentBoardId.value}/comment`, { LOCBRDSEQ: currentBoardId.value, LOCCMTRPY: reply.comment, LOCCMTPWD: reply.password || null, - LOCCMTPNT: reply.parentId, - LOCBRDTYP: reply.isCheck ? "300102" : null - }; - console.log(requestBody) - const response = await axios.post(`board/${currentBoardId.value}/comment`, requestBody); + LOCCMTPNT: reply.parentId + }); + + // 응답 데이터를 자세히 로그로 확인 + // console.log('대댓글 작성 응답:', { + // status: response.status, + // data: response.data, + // headers: response.headers + // }); if (response.status === 200) { - if (response.data.code === 200) { - console.log('✅ 대댓글 작성 성공:', response.data); - await fetchComments(); + if (response.data.code === 200) { // 서버 응답 코드도 확인 + console.log('대댓글 작성 성공:', response.data); + await fetchComments(); // 댓글 목록 새로고침 } else { - console.log('❌ 대댓글 작성 실패 - 서버 응답:', response.data); + console.log('대댓글 작성 실패 - 서버 응답:', response.data); alert('대댓글 작성에 실패했습니다.'); } } } catch (error) { - console.error('🚨 대댓글 작성 중 오류 발생:', error); + console.error('대댓글 작성 중 오류 발생:', error); if (error.response) { - console.error('📌 서버 응답 에러:', error.response.data); + console.error('서버 응답 에러:', error.response.data); } - alert('❌ 대댓글 작성 중 오류가 발생했습니다.'); + alert('대댓글 작성 중 오류가 발생했습니다.'); } -}; - -// const handleCommentReply = async (reply) => { -// try { -// // console.log('대댓글 작성 요청 데이터:', { -// // LOCBRDSEQ: currentBoardId.value, -// // LOCCMTRPY: reply.comment, -// // LOCCMTPWD: reply.password || null, -// // LOCCMTPNT: reply.parentId -// // }); - -// // const response = await axios.post(`board/${currentBoardId.value}/comment`, { -// // LOCBRDSEQ: currentBoardId.value, -// // LOCCMTRPY: reply.comment, -// // LOCCMTPWD: reply.password || null, -// // LOCCMTPNT: reply.parentId -// // }); -// const requestBody = { -// LOCBRDSEQ: currentBoardId.value, -// LOCCMTRPY: reply.comment, -// LOCCMTPWD: reply.password || null, -// LOCCMTPNT: reply.parentId, -// LOCBRDTYP -// }; - -// // 응답 데이터를 자세히 로그로 확인 -// // console.log('대댓글 작성 응답:', { -// // status: response.status, -// // data: response.data, -// // headers: response.headers -// // }); - -// const response = await axios.post(`board/${currentBoardId.value}/comment`, requestBody); -// if (response.status === 200) { -// if (response.data.code === 200) { // 서버 응답 코드도 확인 -// console.log('대댓글 작성 성공:', response.data); -// await fetchComments(); // 댓글 목록 새로고침 -// } else { -// console.log('대댓글 작성 실패 - 서버 응답:', response.data); -// alert('대댓글 작성에 실패했습니다.'); -// } -// } -// } catch (error) { -// console.error('대댓글 작성 중 오류 발생:', error); -// if (error.response) { -// console.error('서버 응답 에러:', error.response.data); -// } -// alert('대댓글 작성 중 오류가 발생했습니다.'); -// } -// } +} // 게시글 수정 버튼 클릭 const editClick = (unknown) => {