-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: 입력된 문자열로 태그 목록 검색 기능 리팩터링 * refactor: TagQueryService 태그 목록 검색 기능 리팩터링 * chore: 러너 게시글 태그 패키지 이동 * refactor: TagQueryController 태그 목록 검색 기능 리팩터링 * test: 인수 테스트 검증용 TestTagQueryRepository 수정 * refactor: 태그 목록 검색 조건인 TagReducedName 이 null 이거나 공백일 경우 빈 목록을 서비스 계층에서 반환하도록 수정
- Loading branch information
Showing
25 changed files
with
357 additions
and
359 deletions.
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.
26 changes: 26 additions & 0 deletions
26
...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,26 @@ | ||
package touch.baton.domain.tag.query.repository; | ||
|
||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
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.List; | ||
|
||
import static touch.baton.domain.tag.command.QTag.tag; | ||
|
||
@RequiredArgsConstructor | ||
@Repository | ||
public class TagQuerydslRepository { | ||
|
||
private final JPAQueryFactory queryFactory; | ||
|
||
public List<Tag> findByTagReducedName(final TagReducedName tagReducedName, final int limit) { | ||
return queryFactory.selectFrom(tag) | ||
.where(tag.tagReducedName.value.startsWith(tagReducedName.getValue())) | ||
.orderBy(tag.tagReducedName.value.asc(), tag.tagName.value.desc()) | ||
.limit(limit) | ||
.fetch(); | ||
} | ||
} |
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
6 changes: 0 additions & 6 deletions
6
backend/baton/src/test/java/touch/baton/assure/repository/TestTagQueryRepository.java
This file was deleted.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
backend/baton/src/test/java/touch/baton/assure/repository/TestTagQuerydslRepository.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,13 @@ | ||
package touch.baton.assure.repository; | ||
|
||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import org.springframework.stereotype.Repository; | ||
import touch.baton.domain.tag.query.repository.TagQuerydslRepository; | ||
|
||
@Repository | ||
public class TestTagQuerydslRepository extends TagQuerydslRepository { | ||
|
||
public TestTagQuerydslRepository(final JPAQueryFactory queryFactory) { | ||
super(queryFactory); | ||
} | ||
} |
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.