[COMMUNITY] 커뮤니티 폼 데이터 처리 통일 및 코드리뷰 반영#44
[COMMUNITY] 커뮤니티 폼 데이터 처리 통일 및 코드리뷰 반영#44usn757 merged 2 commits intoPETTY-HUB:mainfrom LimPark996:main
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Summary by CodeRabbit
Walkthrough이 변경사항은 주로 폼 입력 필드의 name 속성 표준화, 클라이언트 측 입력 검증 및 오류 메시지 표시 개선, 서버 측 로깅 및 예외 처리 강화, 게시글 카운트 일괄 업데이트 기능의 효율화, 그리고 관련 저장소 및 서비스 계층의 리팩토링을 포함합니다. 주요 API 시그니처 일부가 관리자 권한 검증을 위해 수정되었습니다. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Frontend(JS)
participant Server(Controller)
participant Service
participant Repository
User->>Frontend(JS): 폼 입력 및 제출
Frontend(JS)->>Frontend(JS): FormData로 입력값 추출 및 검증
alt 필수값 누락
Frontend(JS)-->>User: 오류 alert 표시 및 입력 focus
else 검증 통과
Frontend(JS)->>Server(Controller): 유효한 데이터 전송
Server(Controller)->>Service: 요청 처리
Service->>Repository: DB 작업(이미지 일괄 삭제/업데이트 등)
Repository-->>Service: 결과 반환
Service-->>Server(Controller): 처리 완료
Server(Controller)-->>Frontend(JS): 응답 반환
Frontend(JS)-->>User: 결과 반영
end
sequenceDiagram
participant Admin
participant Server(PostController)
participant Service
participant Repository
Admin->>Server(PostController): updateAllPostCounts() 요청
Server(PostController)->>Server(PostController): 관리자 권한 검증
alt 권한 없음
Server(PostController)-->>Admin: 403 Forbidden 응답
else 권한 있음
Server(PostController)->>Service: updateAllPostCounts() 호출
Service->>Repository: updateAllPostCounts() (JPQL/Native 일괄 쿼리)
Repository-->>Service: 처리 완료
Service-->>Server(PostController): 완료 알림
Server(PostController)-->>Admin: 성공 응답
end
Possibly related PRs
Poem
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (2)
src/main/java/io/github/petty/community/controller/PostController.java (1)
103-109: 중복 권한 검사 최적화 필요
@PreAuthorize("hasRole('ADMIN')")와 수동 권한 검사가 동시에 있어 중복됩니다. Spring Security의 어노테이션 기반 접근 제어가 이미 메서드 실행 전에 권한을 검증하므로, 수동 검사는 불필요합니다.다음 diff를 적용하여 중복을 제거하세요:
@PostMapping("/update-counts") @PreAuthorize("hasRole('ADMIN')") -public ResponseEntity<?> updateAllPostCounts(@AuthenticationPrincipal CustomUserDetails userDetails) { - // 관리자 권한 확인 - if (!userDetails.getAuthorities().stream() - .anyMatch(a -> a.getAuthority().equals("ROLE_ADMIN"))) { - return ResponseEntity.status(403).body("관리자 권한이 필요합니다."); - } +public ResponseEntity<?> updateAllPostCounts() { postService.updateAllPostCounts(); return ResponseEntity.ok(Map.of("message", "모든 게시글의 댓글 수와 좋아요 수가 업데이트되었습니다.")); }src/main/resources/static/js/common/edit-showoff.js (1)
40-67: 에러 메시지 표시 시스템이 잘 구현되었습니다.사용자 친화적인 알림 시스템으로 UX가 크게 개선되었습니다. 자동 제거 기능과 기존 알림 정리 로직도 적절합니다.
다만 XSS 보안 취약점을 방지하기 위해
innerHTML대신 안전한 방법을 사용하는 것을 권장합니다.보안 강화를 위해 다음과 같이 수정을 권장합니다:
- alertDiv.innerHTML = ` - <span class="alert-icon">⚠️</span> - <span class="alert-message">${message}</span> - <button class="alert-close" onclick="this.parentElement.remove()">×</button> - `; + const iconSpan = document.createElement('span'); + iconSpan.className = 'alert-icon'; + iconSpan.textContent = '⚠️'; + + const messageSpan = document.createElement('span'); + messageSpan.className = 'alert-message'; + messageSpan.textContent = message; + + const closeButton = document.createElement('button'); + closeButton.className = 'alert-close'; + closeButton.textContent = '×'; + closeButton.onclick = () => alertDiv.remove(); + + alertDiv.appendChild(iconSpan); + alertDiv.appendChild(messageSpan); + alertDiv.appendChild(closeButton);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (17)
src/main/java/io/github/petty/community/controller/CommentController.java(3 hunks)src/main/java/io/github/petty/community/controller/PostController.java(2 hunks)src/main/java/io/github/petty/community/dto/CommentRequest.java(1 hunks)src/main/java/io/github/petty/community/dto/PostRequest.java(1 hunks)src/main/java/io/github/petty/community/repository/PostRepository.java(2 hunks)src/main/java/io/github/petty/community/service/PostImageServiceImpl.java(2 hunks)src/main/java/io/github/petty/community/service/PostServiceImpl.java(1 hunks)src/main/resources/static/js/common/edit-qna.js(3 hunks)src/main/resources/static/js/common/edit-review.js(4 hunks)src/main/resources/static/js/common/edit-showoff.js(3 hunks)src/main/resources/static/js/common/form.js(1 hunks)src/main/resources/templates/edit-qna.html(4 hunks)src/main/resources/templates/edit-review.html(2 hunks)src/main/resources/templates/edit-showoff.html(2 hunks)src/main/resources/templates/post-qna-form.html(3 hunks)src/main/resources/templates/post-review-form.html(2 hunks)src/main/resources/templates/post-showoff-form.html(2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/main/resources/static/js/common/edit-review.js (3)
src/main/resources/static/js/common/edit-qna.js (11)
formData(284-284)form(88-88)resolvedCheckbox(157-157)resolvedCheckbox(221-221)resolvedLabel(158-158)resolvedLabel(222-222)titleElement(209-209)contentElement(210-210)post(181-181)post(207-207)petTypeInputs(216-216)src/main/resources/static/js/common/edit-showoff.js (7)
formData(260-260)form(88-88)titleElement(197-197)contentElement(198-198)post(170-170)post(195-195)petTypeInputs(204-204)src/main/resources/static/js/common/form.js (9)
formData(116-116)formData(189-189)form(188-188)title(192-192)content(193-193)petType(194-194)petName(195-195)region(196-196)isResolved(197-197)
🔇 Additional comments (35)
src/main/java/io/github/petty/community/repository/PostRepository.java (3)
8-8: 필요한 어노테이션 임포트가 정확히 추가되었습니다.
@Modifying과@Transactional임포트가 새로운 벌크 업데이트 메서드들을 위해 적절히 추가되었습니다.Also applies to: 12-12
27-34:Details
✅ Verification successful
JPQL 벌크 업데이트 메서드가 올바르게 구현되었습니다.
N+1 쿼리 문제를 해결하는 효율적인 접근 방식입니다. 서브쿼리를 통해 각 게시글의 댓글 수와 좋아요 수를 한 번의 쿼리로 업데이트합니다.
다음 스크립트를 실행하여 관련 엔티티들의 관계 매핑이 올바른지 확인해주세요:
🏁 Script executed:
#!/bin/bash # 설명: Comment와 PostLike 엔티티의 Post와의 관계 확인 # Comment 엔티티에서 post 필드 확인 ast-grep --pattern $'@Entity class Comment { $$$ @ManyToOne $$$ Post post; $$$ }' # PostLike 엔티티에서 post 필드 확인 ast-grep --pattern $'@Entity class PostLike { $$$ @ManyToOne $$$ Post post; $$$ }'Length of output: 186
아래 스크립트를 실행하여
Comment.java와PostLike.java엔티티 파일이 실제로 존재하는지, 그리고@ManyToOne어노테이션과Post post필드 매핑이 올바른지 재확인해 주세요.
🏁 Script executed:
#!/bin/bash # 1. 엔티티 파일 경로 찾기 comment_file=$(fd -e java Comment.java || echo "") postlike_file=$(fd -e java PostLike.java || echo "") echo "=== Comment 엔티티 파일 ===" echo "$comment_file" if [[ -n "$comment_file" ]]; then grep -n "@Entity" -C2 "$comment_file" grep -n "@ManyToOne" -C2 "$comment_file" grep -n "Post post" -C1 "$comment_file" fi echo echo "=== PostLike 엔티티 파일 ===" echo "$postlike_file" if [[ -n "$postlike_file" ]]; then grep -n "@Entity" -C2 "$postlike_file" grep -n "@ManyToOne" -C2 "$postlike_file" grep -n "Post post" -C1 "$postlike_file" fiLength of output: 2282
JPQL 벌크 업데이트 매핑 검증 완료
Comment 및 PostLike 엔티티에서 Post와의 관계 매핑(
@ManyToOne(fetch = FetchType.LAZY),@JoinColumn(name = "post_id"))이 올바르게 설정되어 있어,
updateAllPostCounts()메서드의 서브쿼리가 정상적으로 작동함을 확인했습니다.
별도 수정 없이 머지하셔도 됩니다.
- src/main/java/io/github/petty/community/entity/Comment.java (22–24행)
- src/main/java/io/github/petty/community/entity/PostLike.java (23–25행)
37-52:Details
✅ Verification successful
네이티브 SQL 쿼리의 테이블/컬럼명 검증이 필요합니다.
네이티브 SQL을 사용한 성능 최적화 접근은 좋습니다만, 실제 데이터베이스 스키마와 일치하는지 확인이 필요합니다.
다음 스크립트를 실행하여 실제 테이블 및 컬럼명을 확인해주세요:
🏁 Script executed:
#!/bin/bash # 설명: 엔티티 클래스에서 실제 테이블명과 컬럼명 확인 # Post 엔티티의 테이블명과 컬럼명 확인 ast-grep --pattern $'@Entity $$$ @Table(name = "$_") $$$ class Post { $$$ }' # Comment 엔티티의 테이블명 확인 ast-grep --pattern $'@Entity $$$ @Table(name = "$_") $$$ class Comment { $$$ }' # PostLike 엔티티의 테이블명 확인 ast-grep --pattern $'@Entity $$$ @Table(name = "$_") $$$ class PostLike { $$$ }'Length of output: 248
아직 엔티티 클래스와 @table(name=…) 어노테이션을 찾지 못했습니다. 실제 엔티티 정의를 확인하기 위해 아래 스크립트를 실행해 주세요.
🏁 Script executed:
#!/bin/bash set -eu echo "### @Entity가 선언된 파일 및 상위 200줄 출력 ###" rg --files-with-matches '@Entity' -g "*.java" | while read -r file; do echo echo "=== $file ===" sed -n '1,200p' "$file" doneLength of output: 25657
네이티브 SQL 테이블·컬럼명 검증 완료
- src/main/java/io/github/petty/community/entity/Post.java
• @table(name="posts")
• commentCount → comment_count, likeCount → like_count- src/main/java/io/github/petty/community/entity/Comment.java
• @table(name="comments")
• @joincolumn(name="post_id")- src/main/java/io/github/petty/community/entity/PostLike.java
• @table(name="post_likes")
• @joincolumn(name="post_id")위 설정이 모두 네이티브 쿼리(
posts,comments,post_likes,comment_count,like_count,post_id)와 일치하므로 추가 수정 없이 진행 가능합니다.src/main/java/io/github/petty/community/dto/PostRequest.java (1)
9-9: Jakarta EE 네임스페이스로의 마이그레이션이 올바르게 수행되었습니다.
javax.validation에서jakarta.validation으로의 변경은 최신 Spring Boot 버전과의 호환성을 위해 필요한 표준 마이그레이션입니다.src/main/java/io/github/petty/community/dto/CommentRequest.java (1)
7-7: 일관된 Jakarta EE 마이그레이션입니다.PostRequest.java와 일관되게 검증 어노테이션 임포트가 Jakarta 네임스페이스로 업데이트되었습니다.
src/main/resources/templates/post-showoff-form.html (4)
25-25: 제목 입력 필드에 name 속성이 올바르게 추가되었습니다.
name="title"속성 추가로 FormData를 통한 일관된 폼 데이터 처리가 가능해졌습니다.
32-56: 반려동물 타입 라디오 버튼들의 name 속성이 표준화되었습니다.기존
"showoff-petType"에서"petType"으로 변경하여 다른 폼들과의 일관성을 확보했습니다. 모든 라디오 버튼이 동일한 name 속성을 가져 올바른 그룹화가 이루어졌습니다.
64-64: 내용 입력 영역에 name 속성이 적절히 추가되었습니다.
name="content"속성으로 폼 데이터 추출 시 일관된 처리가 가능해졌습니다.
74-74: 이미지 파일 입력에 name 속성이 올바르게 설정되었습니다.
name="imageFiles"속성 추가로 다중 파일 업로드 시 FormData를 통한 일관된 처리가 가능해졌습니다.src/main/resources/templates/post-qna-form.html (3)
25-25: 폼 데이터 처리를 위한 name 속성 추가가 적절합니다.제목 입력 필드에
name="title"속성이 추가되어 FormData를 통한 일관된 데이터 추출이 가능해졌습니다.
64-64: 콘텐츠 필드의 name 속성 추가가 올바릅니다.textarea 요소에
name="content"속성이 추가되어 폼 제출 시 콘텐츠 데이터가 올바르게 식별됩니다.
74-74: 이미지 파일 입력의 name 속성이 적절히 설정되었습니다.파일 입력 요소에
name="imageFiles"속성이 추가되어 다중 파일 업로드 시 데이터 처리가 표준화됩니다.src/main/resources/templates/edit-showoff.html (4)
25-25: 제목 필드의 name 속성 추가로 일관성이 향상되었습니다.제목 입력 필드에
name="title"속성 추가로 다른 폼 템플릿과의 일관성이 확보되었습니다.
32-57: 라디오 버튼의 name 속성 표준화가 적절합니다.반려동물 종류 라디오 버튼의 name 속성이
edit-showoff-petType에서petType으로 변경되어 다른 폼 템플릿과 일관된 네이밍 규칙을 따르게 되었습니다. 이는 JavaScript에서 FormData 처리를 통일할 수 있게 합니다.
64-64: 콘텐츠 textarea의 name 속성이 올바르게 추가되었습니다.자랑 내용 입력 필드에
name="content"속성이 추가되어 폼 데이터 추출이 표준화되었습니다.
74-74: 파일 입력의 name 속성 추가가 적절합니다.이미지 파일 입력에
name="imageFiles"속성이 추가되어 파일 업로드 처리가 일관성을 가지게 되었습니다.src/main/resources/templates/edit-review.html (3)
25-35: 기본 입력 필드들의 name 속성 추가가 완벽합니다.제목, 반려동물 이름, 여행 장소 입력 필드에 각각
name="title",name="petName",name="region"속성이 추가되어 후기 폼의 모든 데이터가 올바르게 식별됩니다.
42-67: 반려동물 종류 라디오 버튼의 name 속성 표준화가 우수합니다.라디오 버튼의 name 속성이
edit-review-petType에서petType으로 통일되어 다른 폼 템플릿과 일관된 네이밍 규칙을 따릅니다. 이는 JavaScript에서 FormData 처리를 단순화합니다.
74-84: 콘텐츠 및 파일 입력의 name 속성이 적절히 설정되었습니다.후기 내용 textarea와 이미지 파일 입력에 각각
name="content",name="imageFiles"속성이 추가되어 폼 데이터 처리의 일관성이 확보되었습니다.src/main/resources/templates/edit-qna.html (1)
25-25: 폼 데이터 바인딩 표준화 완료!모든 폼 입력 요소에 적절한
name속성이 추가되어 FormData 사용을 위한 표준화가 잘 이루어졌습니다. 이는 클라이언트 측 폼 처리 일관성을 크게 향상시킬 것입니다.Also applies to: 32-32, 36-36, 40-40, 44-44, 48-48, 52-52, 56-56, 66-66, 75-75, 85-85
src/main/resources/templates/post-review-form.html (1)
25-25: 폼 입력 요소 표준화 완료!모든 입력 요소에 일관된
name속성이 추가되었고, 특히 반려동물 종류 라디오 버튼이 다른 폼들과 동일한petType으로 통일되어 전체적인 일관성이 확보되었습니다.Also applies to: 30-30, 35-35, 42-42, 46-46, 50-50, 54-54, 58-58, 62-62, 66-66, 74-74, 84-84
src/main/java/io/github/petty/community/controller/CommentController.java (3)
13-13: 구조화된 로깅 도입 승인!
@Slf4j어노테이션 추가로 적절한 로깅 프레임워크 사용이 구현되었습니다. 이는 운영 환경에서의 관찰 가능성을 크게 향상시킬 것입니다.Also applies to: 17-17
34-52: 로깅 개선 및 에러 처리 강화 완료!구조화된 로깅과 상세한 컨텍스트 정보 추가로 디버깅 효율성이 크게 향상되었습니다. 특히
postId와username정보가 포함되어 문제 추적이 용이해졌습니다.
68-82: 삭제 로직 로깅 개선 완료!댓글 삭제 과정의 로깅이 체계적으로 개선되어 운영 환경에서의 추적성이 향상되었습니다. 예외 스택 트레이스와 컨텍스트 정보가 적절히 기록됩니다.
src/main/resources/static/js/common/edit-qna.js (3)
40-66: 에러 메시지 시스템 구현이 우수합니다!새로 추가된 에러 메시지 표시 시스템이 잘 구현되었습니다:
- 자동 해제 기능 (5초)
- 기존 알림 중복 방지
- 사용자 친화적 인터페이스
101-134: FormData 사용으로 폼 처리 개선됨FormData를 사용한 입력값 추출과 검증 로직이 잘 구현되었습니다:
name속성 기반 데이터 추출- 필수 필드 검증 강화
- 사용자 친화적 에러 메시지와 포커스 처리
209-225:Details
❓ Verification inconclusive
name 속성 우선 접근 방식 개선됨
필드 선택 로직이
name속성을 우선으로 하고 ID를 폴백으로 사용하는 방식으로 개선되어 HTML 표준에 더 부합합니다.다만 일관성을 위해 다음 사항을 확인해보세요:
🏁 Script executed:
#!/bin/bash # Description: HTML 템플릿의 name 속성 일관성 확인 # Expected: 모든 폼 필드가 적절한 name 속성을 가지고 있는지 확인 rg -A 3 'edit-qna-title|edit-qna-content|edit-qna-petName|edit-qna-region' --type htmlLength of output: 1027
HTML 폼 필드 name 속성 일관성 재확인 필요
아래 두 필드는 의도한 대로
name속성이 잘 적용되어 있습니다.
src/main/resources/templates/edit-qna.html
<input id="edit-qna-title" name="title" …><textarea id="edit-qna-content" name="content" …>하지만 추가 필드(예: petType, petName, region 등)가 모두
name속성을 일관되게 갖추고 있는지 확인이 필요합니다.
필드가 누락되었거나 다른 속성명으로 정의되어 있지 않은지 검토해주세요.src/main/resources/static/js/common/form.js (1)
188-226: FormData 기반 폼 처리 로직 우수함FormData를 활용한 새로운 폼 처리 방식이 잘 구현되었습니다:
name속성 기반 일관된 데이터 추출- 포괄적인 필수 필드 검증
- 향상된 사용자 피드백
특히 체크박스 처리에서
formData.has('isResolved')사용이 적절합니다.src/main/resources/static/js/common/edit-review.js (1)
159-167: isResolved 토글 기능 우수함체크박스 상태에 따른 라벨 텍스트 동적 업데이트 기능이 잘 구현되었습니다. 사용자 경험을 크게 개선합니다.
src/main/java/io/github/petty/community/service/PostImageServiceImpl.java (3)
77-87: 이미지 일괄 삭제 최적화 우수함개별 삭제 대신 일괄 삭제로 변경하여 성능을 크게 개선했습니다:
- N+1 쿼리 문제 해결
- 트랜잭션 내에서 안전한 일괄 처리
- 파일 삭제도 함께 처리
94-102: 새 이미지 추가 로직 개선됨새 이미지 추가 시 ordering 값의 null 체크와 기본값 설정이 잘 구현되었습니다.
105-115:Details
✅ Verification successful
기존 이미지 매핑으로 성능 최적화
기존 이미지들을 Map으로 변환하여 반복적인 데이터베이스 조회를 방지한 것이 우수합니다.
하지만 삭제된 이미지에 대한 처리를 확인해보세요:
🏁 Script executed:
#!/bin/bash # Description: 삭제된 이미지가 맵에서 제거되는지 확인 # Expected: 삭제 후 맵에서 해당 이미지들이 참조되지 않아야 함 ast-grep --pattern $'if (!Boolean.TRUE.equals($_.getIsDeleted()) && $_.getId() != null && $_.getOrdering() != null) { PostImage image = existingImagesMap.get($_.getId()); $$$ }'Length of output: 959
🏁 Script executed:
#!/bin/bash # Print the relevant part of PostImageServiceImpl to inspect deletion logic sed -n '1,200p' src/main/java/io/github/petty/community/service/PostImageServiceImpl.javaLength of output: 4469
삭제된 이미지 맵 필터링은 이미 처리됩니다
updateImagesFromRequest메소드에서
1️⃣ 삭제 로직(isDeleted == true)으로 DB와 Supabase 에서 제거된 후,
5️⃣ Ordering 업데이트 단계에서!Boolean.TRUE.equals(dto.getIsDeleted())조건으로 해당 DTO가 제외됩니다.
따라서existingImagesMap에 여전히 남아 있어도 참조되지 않아 별도 제거 로직이 필요 없습니다.src/main/resources/static/js/common/edit-showoff.js (3)
101-126: FormData 사용과 폼 검증 로직이 잘 구현되었습니다.FormData를 사용한 표준화된 접근 방식과 포괄적인 필드 검증이 코드의 일관성과 안정성을 크게 향상시켰습니다. 특히 사용자에게 명확한 피드백을 제공하는 점이 우수합니다.
127-133: 페이로드 구성이 검증된 변수를 사용하도록 개선되었습니다.이전의 DOM 직접 조회 방식에서 검증된 변수를 사용하는 방식으로 변경되어 데이터 일관성이 보장됩니다.
197-207: name 속성을 활용한 요소 선택과 펫 타입 처리가 개선되었습니다.HTML의 name 속성을 활용한 표준화된 접근 방식으로 변경되었고, 기존 ID를 fallback으로 사용하는 호환성 로직도 잘 구현되었습니다. 펫 타입 입력 처리의 일관성도 향상되었습니다.
src/main/java/io/github/petty/community/controller/CommentController.java
Show resolved
Hide resolved
| // 🔥 에러 메시지 표시 함수 추가 | ||
| function showErrorMessage(message) { | ||
| // 기존 알림 제거 | ||
| removeExistingAlerts(); | ||
|
|
||
| const alertDiv = document.createElement('div'); | ||
| alertDiv.className = 'alert alert-error'; | ||
| alertDiv.innerHTML = ` | ||
| <span class="alert-icon">⚠️</span> | ||
| <span class="alert-message">${message}</span> | ||
| <button class="alert-close" onclick="this.parentElement.remove()">×</button> | ||
| `; | ||
|
|
||
| document.body.insertBefore(alertDiv, document.body.firstChild); | ||
|
|
||
| // 5초 후 자동 제거 | ||
| setTimeout(() => { | ||
| if (alertDiv.parentElement) { | ||
| alertDiv.remove(); | ||
| } | ||
| }, 5000); | ||
| } | ||
|
|
||
| function removeExistingAlerts() { | ||
| const existingAlerts = document.querySelectorAll('.alert'); | ||
| existingAlerts.forEach(alert => alert.remove()); | ||
| } |
There was a problem hiding this comment.
🛠️ Refactor suggestion
에러 메시지 함수 중복 발견
showErrorMessage와 removeExistingAlerts 함수가 edit-qna.js와 동일하게 구현되었습니다.
공통 유틸리티 함수로 분리하여 코드 중복을 제거하는 것을 권장합니다:
// 새 파일: src/main/resources/static/js/utils/alert-utils.js 생성
+export function showErrorMessage(message) {
+ // 기존 구현 이동
+}
+
+export function removeExistingAlerts() {
+ // 기존 구현 이동
+}
// 각 파일에서:
+import { showErrorMessage, removeExistingAlerts } from '../utils/alert-utils.js';
-// 중복된 함수 정의 제거Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In src/main/resources/static/js/common/edit-review.js around lines 40 to 66, the
functions showErrorMessage and removeExistingAlerts are duplicated from
edit-qna.js. To fix this, extract these functions into a shared utility
JavaScript file and import them where needed, then remove the duplicate
implementations from this file to eliminate code redundancy.
|
고생하셨습니다! 전반적으로 많은 개선 사항이 포함된 중요한 PR로 보입니다. 특히 폼 처리 표준화와 백엔드 성능 최적화 노력이 돋보입니다. [긍정적인 부분]
[제안 및 논의 사항]
전반적으로 매우 훌륭한 기여입니다. 코드의 품질과 성능, 사용자 경험을 한 단계 높이는 데 크게 기여할 것으로 보입니다! |
|
감사합니다!! updateAllPostCounts 네이티브 쿼리 사용 여부: PostRepository에 JPQL 버전과 Native SQL 버전의 updateAllPostCounts가 모두 추가되었습니다. PostServiceImpl에서는 현재 JPQL 버전(postRepository.updateAllPostCounts())을 호출하고 있습니다. Native SQL 버전(updateAllPostCountsNative)은 특정 상황을 위한 것인지, 혹은 향후 전환 가능성이 있는지 궁금합니다. ed9a789 커밋에서 댓글 삭제 실패 시 응답 상태 코드가 400 Bad Request에서 500 Internal Server Error로 변경되었습니다. 이 변경의 구체적인 의도(예: 클라이언트 책임 vs 서버 내부 오류 구분)를 공유해주시면 이해에 도움이 될 것 같습니다 수정 완료하였습니다.! |
🚀 게시글 폼 데이터 처리 통일 및 성능 최적화
📜 PR 내용 요약
이번 PR은 두 가지 주요 개선사항을 포함합니다:
⚒️ 작업 및 변경 내용(상세하게)
🎯 프론트엔드 폼 데이터 처리 표준화
문제점
getElementById()vsquerySelector()vsFormData혼재 사용name속성 누락으로 인한 데이터 손실 위험해결 방안
📁 HTML 파일 수정 (5개 파일)
name속성 추가📁 JavaScript 파일 리팩토링 (4개 파일)
Before (비일관적):
After (통일된 FormData 방식):
개선된 에러 처리
🚀 백엔드 성능 최적화
PostRepository.java
PostServiceImpl.java
Before (N+1 쿼리 문제):
After (최적화된 벌크 업데이트):
📊 성능 개선 효과
📚 기타 참고 사항
✅ 프론트엔드 리뷰 포인트
✅ 백엔드 리뷰 포인트
@Transactional과@Modifying어노테이션 적절성 검토post_id,comment.post_id,post_like.post_id인덱스 존재 여부