-
Notifications
You must be signed in to change notification settings - Fork 7
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
태그 목록 검색 기능 리팩터링 #637
Merged
Merged
태그 목록 검색 기능 리팩터링 #637
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f27d12a
refactor: 입력된 문자열로 태그 목록 검색 기능 리팩터링
hyena0608 175c648
refactor: TagQueryService 태그 목록 검색 기능 리팩터링
hyena0608 62d67df
chore: 러너 게시글 태그 패키지 이동
hyena0608 08ce851
refactor: TagQueryController 태그 목록 검색 기능 리팩터링
hyena0608 0730bfd
test: 인수 테스트 검증용 TestTagQueryRepository 수정
hyena0608 456c08f
Merge remote-tracking branch 'origin/dev/BE' into feat/635
hyena0608 ed7edd3
refactor: 태그 목록 검색 조건인 TagReducedName 이 null 이거나 공백일 경우 빈 목록을 서비스 계층에…
hyena0608 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
13 changes: 0 additions & 13 deletions
13
...d/baton/src/main/java/touch/baton/domain/tag/command/repository/TagCommandRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,12 @@ | ||
package touch.baton.domain.tag.command.repository; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
import touch.baton.domain.common.vo.TagName; | ||
import touch.baton.domain.tag.command.Tag; | ||
import touch.baton.domain.tag.command.vo.TagReducedName; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
public interface TagCommandRepository extends JpaRepository<Tag, Long> { | ||
|
||
Optional<Tag> findByTagName(final TagName tagName); | ||
|
||
@Query(""" | ||
select t | ||
from Tag t | ||
where t.tagReducedName like :tagReducedName% | ||
order by t.tagReducedName asc | ||
limit 10 | ||
""") | ||
List<Tag> readTagsByReducedName(@Param("tagReducedName") TagReducedName tagReducedName); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 9 additions & 2 deletions
11
...on/src/main/java/touch/baton/domain/tag/query/controller/response/TagSearchResponses.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,19 @@ | ||
package touch.baton.domain.tag.query.controller.response; | ||
|
||
import touch.baton.domain.tag.command.Tag; | ||
|
||
import java.util.List; | ||
|
||
public record TagSearchResponses() { | ||
|
||
public record Detail(List<TagSearchResponse.TagResponse> data) { | ||
public static Detail from(final List<TagSearchResponse.TagResponse> data) { | ||
return new Detail(data); | ||
|
||
public static Detail from(final List<Tag> tags) { | ||
final List<TagSearchResponse.TagResponse> response = tags.stream() | ||
.map(TagSearchResponse.TagResponse::from) | ||
.toList(); | ||
|
||
return new Detail(response); | ||
} | ||
} | ||
} |
25 changes: 0 additions & 25 deletions
25
backend/baton/src/main/java/touch/baton/domain/tag/query/repository/TagQueryRepository.java
This file was deleted.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
...nd/baton/src/main/java/touch/baton/domain/tag/query/repository/TagQuerydslRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package touch.baton.domain.tag.query.repository; | ||
|
||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import jakarta.annotation.Nullable; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Repository; | ||
import touch.baton.domain.tag.command.Tag; | ||
import touch.baton.domain.tag.command.vo.TagReducedName; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import static touch.baton.domain.tag.command.QTag.tag; | ||
|
||
@RequiredArgsConstructor | ||
@Repository | ||
public class TagQuerydslRepository { | ||
|
||
private final JPAQueryFactory queryFactory; | ||
|
||
public List<Tag> findByTagReducedName(@Nullable final TagReducedName tagReducedName, final int limit) { | ||
if (isTagReducedNameIsNullOrBlank(tagReducedName)) { | ||
return Collections.emptyList(); | ||
} | ||
|
||
return queryFactory.selectFrom(tag) | ||
.where(tag.tagReducedName.value.startsWith(tagReducedName.getValue())) | ||
.orderBy(tag.tagReducedName.value.asc(), tag.tagName.value.desc()) | ||
.limit(limit) | ||
.fetch(); | ||
} | ||
|
||
private boolean isTagReducedNameIsNullOrBlank(@Nullable final TagReducedName tagReducedName) { | ||
return tagReducedName == null || tagReducedName.getValue().isBlank(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 17 additions & 2 deletions
19
backend/baton/src/test/java/touch/baton/assure/repository/TestTagQueryRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,21 @@ | ||
package touch.baton.assure.repository; | ||
|
||
import touch.baton.domain.tag.query.repository.TagQueryRepository; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
import touch.baton.domain.tag.command.Tag; | ||
import touch.baton.domain.tag.command.vo.TagReducedName; | ||
|
||
public interface TestTagQueryRepository extends TagQueryRepository { | ||
import java.util.List; | ||
|
||
public interface TestTagQueryRepository extends JpaRepository<Tag, Long> { | ||
|
||
@Query(""" | ||
select t | ||
from Tag t | ||
where t.tagReducedName like :tagReducedName% | ||
order by t.tagReducedName asc | ||
limit 10 | ||
""") | ||
List<Tag> findTagsByReducedName(@Param("tagReducedName") final TagReducedName tagReducedName); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 0 additions & 85 deletions
85
backend/baton/src/test/java/touch/baton/assure/tag/support/query/TagAssuredSupport.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
limit!
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.
의도한건가요?