-
Notifications
You must be signed in to change notification settings - Fork 1
Feat/sw 45 - 북마크 로직 리팩터링 #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a97769b
91836dd
13abaa9
3ba9db4
7f641e0
44a73f1
a0cec34
228f28f
152616f
bef39e4
503c263
7877f9b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| package com.web.SearchWeb.bookmark.controller.dto; | ||
|
|
||
| import com.web.SearchWeb.bookmark.service.command.BookmarkSearchCommand; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import lombok.Data; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| /** | ||
| * Bookmark Controller 전용 Request DTO | ||
| * - Controller에서만 사용하며, Service 계층에는 개별 파라미터로 전달 | ||
| */ | ||
| public class BookmarkRequests { | ||
|
|
||
| /** | ||
| * 북마크 생성 요청 Dto | ||
| */ | ||
| public static class CreateDto { | ||
| public Long bookmarkId; // 북마크 ID (PK, Insert 시 생성된 키 저장용) | ||
| public Long memberFolderId; // 폴더 ID (null이면 기본 폴더) | ||
| public String displayTitle; // 표시 제목 | ||
| public String url; // 저장할 URL | ||
| public String note; // 메모 | ||
| public Long primaryCategoryId; // 카테고리 ID | ||
| public Long createdByMemberId; // 저장한 회원 | ||
| public String tags; // 태그 문자열 (공백/콤마 구분) | ||
| } | ||
|
|
||
|
|
||
| /** | ||
| * 북마크 목록 조회 요청 Dto (Search Params) | ||
| */ | ||
| @Data | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| public static class SearchDto { | ||
| public Long folderId; | ||
| public String sort = "Newest"; // 기본값 설정 | ||
| public String query; | ||
| public Long categoryId; | ||
|
|
||
| public BookmarkSearchCommand toCommand(Long memberId) { | ||
| return BookmarkSearchCommand.builder() | ||
| .memberId(memberId) | ||
| .folderId(this.folderId) | ||
| .sort(this.sort) | ||
| .query(this.query) | ||
| .categoryId(this.categoryId) | ||
| .build(); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| /** | ||
| * 북마크 수정 요청 Dto | ||
| */ | ||
| @Data | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| public static class UpdateDto { | ||
| public Long memberFolderId; // 폴더 ID | ||
| public String displayTitle; // 표시 제목 | ||
| public String note; // 메모 | ||
| public Long primaryCategoryId; // 카테고리 ID | ||
| public String tags; // 태그 문자열 (공백/콤마 구분) | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,39 +2,48 @@ | |
|
|
||
| import com.web.SearchWeb.bookmark.domain.Bookmark; | ||
| import com.web.SearchWeb.bookmark.domain.Link; | ||
| import com.web.SearchWeb.bookmark.dto.BookmarkDto; | ||
| import com.web.SearchWeb.bookmark.dto.request.BookmarkSearchRequestDto; | ||
| import com.web.SearchWeb.bookmark.dto.MemberTagResultDto; | ||
| import com.web.SearchWeb.bookmark.service.command.BookmarkSearchCommand; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public interface BookmarkDao { | ||
| //북마크 링크 중복 확인 (동일 폴더에 동일 링크) | ||
| int checkBookmarkExists(Long memberId, Long folderId, Long linkId); | ||
|
|
||
| //북마크 추가 | ||
| int insertBookmark(BookmarkDto bookmark, Long linkId); | ||
| int insertBookmark(Bookmark bookmark); | ||
|
|
||
| //북마크 단일 조회 | ||
| Bookmark selectBookmark(Long memberId, Long bookmarkId); | ||
|
|
||
| //북마크 목록 조회 | ||
| List<Bookmark> selectBookmarkList(BookmarkSearchRequestDto searchRequest); | ||
| List<Bookmark> selectBookmarkList(BookmarkSearchCommand searchCommand); | ||
|
|
||
| //북마크 수정 | ||
| int updateBookmark(BookmarkDto bookmarkDto, Long bookmarkId); | ||
| int updateBookmark(Bookmark bookmark); | ||
|
|
||
| //북마크 삭제 | ||
| int deleteBookmark(Long memberId, Long bookmarkId); | ||
|
|
||
| //북마크 태그 연결 삭제 | ||
| int deleteBookmarkTags(Long bookmarkId, Long memberId); | ||
|
|
||
| //북마크 삭제 (Link ID 기반 - soft delete) | ||
| int deleteBookmarkByLink(Long memberId, Long linkId); | ||
|
|
||
| //링크 조회 (canonical_url로) | ||
| Link selectLinkByCanonicalUrl(String canonicalUrl); | ||
| //북마크 링크 중복 확인 (동일 폴더에 동일 링크) | ||
| int checkBookmarkExists(Long memberId, Long folderId, Long linkId); | ||
|
|
||
| //링크 조회 (url로) | ||
| Link selectLinkByUrl(String url); | ||
|
|
||
| //링크 추가 (link 테이블) | ||
| int insertLink(Link link); | ||
|
|
||
| //URL 기반 북마크 존재 여부 확인 (Board Bridge용) | ||
| int checkBookmarkExistsByUrl(Long memberId, String url); | ||
|
|
||
| // 태그 등록 및 조회 (Insert & Select) | ||
| List<MemberTagResultDto> insertAndSelectTags(Long memberId, List<String> tagNames); | ||
|
|
||
| // 북마크-태그 연결 일괄 추가 (Bulk Insert) | ||
| int insertBookmarkTags(Long bookmarkId, List<Long> tagIds); | ||
|
Comment on lines
+44
to
+48
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Description: Check if `@Param` is used elsewhere in DAO interfaces and if mybatis config enables useActualParamName
echo "=== Checking `@Param` usage in DAO interfaces ==="
rg -n '@Param' --type=java -g '*Dao.java' -A1
echo ""
echo "=== Checking if any *Dao.java files exist and their method signatures ==="
fd '*Dao.java' -x cat -n {}
echo ""
echo "=== Checking MyBatis configuration in application properties ==="
fd -e yml -e yaml -e properties | xargs grep -i 'mybatis\|actual-param' 2>/dev/null | head -20
echo ""
echo "=== Checking pom.xml for compiler configuration ==="
fd 'pom.xml' -x cat {} | grep -A10 'maven-compiler-plugin\|mybatis-spring-boot' | head -30
echo ""
echo "=== Checking build.gradle if exists ==="
fd 'build.gradle' -x cat {} 2>/dev/null | head -50Repository: Searchweb-Dev/Searchweb-Back Length of output: 3094 🏁 Script executed: #!/bin/bash
echo "=== BookmarkDao.java current state ==="
fd 'BookmarkDao.java' -x cat -n {}
echo ""
echo "=== BookmarkDao mapper XML file ==="
fd 'BookmarkDao.xml' -o 'BookmarkMapper.xml' -x cat -n {}Repository: Searchweb-Dev/Searchweb-Back Length of output: 6044 🏁 Script executed: #!/bin/bash
echo "=== Searching for BookmarkDao mapper XML ==="
fd -e xml | grep -i bookmark
echo ""
echo "=== Checking mapper directory contents ==="
fd -e xml -type f | head -20
echo ""
echo "=== Looking for parameter usage in bookmark mapper XML ==="
fd -e xml | xargs grep -l 'insertAndSelectTags\|insertBookmarkTags' 2>/dev/nullRepository: Searchweb-Dev/Searchweb-Back Length of output: 500 🏁 Script executed: #!/bin/bash
echo "=== Reading bookmark-mapper.xml ==="
cat -n src/main/resources/mapper/bookmark-mapper.xml | grep -A15 -B2 'insertAndSelectTags\|insertBookmarkTags'Repository: Searchweb-Dev/Searchweb-Back Length of output: 1415 🏁 Script executed: #!/bin/bash
echo "=== Full application.properties content ==="
cat -n src/main/resources/application.properties
echo ""
echo "=== Checking other DAO interfaces for `@Param` patterns ==="
fd 'Dao.java' --type f -x grep -l 'interface' {} \; | xargs -I {} sh -c 'echo "=== {} ===" && head -50 {}'
echo ""
echo "=== Checking if build.gradle has -parameters flag ==="
grep -i 'parameters\|compilerArgs' build.gradleRepository: Searchweb-Dev/Searchweb-Back Length of output: 9316 새 메서드에 프로젝트의 다른 DAO인 BoardDao.java에서 다중 파라미터 메서드에 명시적으로 🛡️ 권장 수정 // 태그 등록 및 조회 (Insert & Select)
- List<MemberTagResultDto> insertAndSelectTags(Long memberId, List<String> tagNames);
+ List<MemberTagResultDto> insertAndSelectTags(`@Param`("memberId") Long memberId, `@Param`("tagNames") List<String> tagNames);
// 북마크-태그 연결 일괄 추가 (Bulk Insert)
- int insertBookmarkTags(Long bookmarkId, List<Long> tagIds);
+ int insertBookmarkTags(`@Param`("bookmarkId") Long bookmarkId, `@Param`("tagIds") List<Long> tagIds);🤖 Prompt for AI Agents |
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving URL from required query param to
request.urlmeans create calls can reach the service withnull/blank URL, which is no longer rejected at request binding time. In that caseinsertBookmarkproceeds to link creation and can fail with a server-side data error (thelinktable requires non-null URL columns), returning a 5xx instead of a client 4xx validation error.Useful? React with 👍 / 👎.