From 1437a15eea6c1e1a9a1a87ba69807df0ca646bdb Mon Sep 17 00:00:00 2001 From: whereami0404 Date: Tue, 21 May 2024 20:54:11 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=ED=83=9C=EA=B7=B8=20=EC=9D=B4=EB=A6=84?= =?UTF-8?q?=20=EA=B2=80=EC=83=89=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= =?UTF-8?q?(#115)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domainmodule/domain/tag/repository/TagRepository.kt | 1 + .../domainmodule/domain/tag/service/TagReader.kt | 4 ++++ .../bamyanggang/persistence/tag/TagRepositoryImpl.java | 8 +++++++- .../persistence/tag/jpa/repository/TagJpaRepository.java | 2 ++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/tag/repository/TagRepository.kt b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/tag/repository/TagRepository.kt index 98db685d..b0152cc3 100644 --- a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/tag/repository/TagRepository.kt +++ b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/tag/repository/TagRepository.kt @@ -11,4 +11,5 @@ interface TagRepository { fun deleteByTagId(tagId: UUID) fun isExistById(tagId: UUID): Boolean fun findByParentTagIds(tagParentTagIds: List): List + fun findByNameContains(search: String): List } diff --git a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/tag/service/TagReader.kt b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/tag/service/TagReader.kt index 5fbfe60c..a539aab9 100644 --- a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/tag/service/TagReader.kt +++ b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/tag/service/TagReader.kt @@ -24,4 +24,8 @@ class TagReader( fun readByIds(parentTagIds: List): List { return tagRepository.findByParentTagIds(parentTagIds) } + + fun readIdsByNameContains(search: String) : List { + return tagRepository.findByNameContains(search).map { it.id } + } } diff --git a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/tag/TagRepositoryImpl.java b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/tag/TagRepositoryImpl.java index 1c967db8..53bbc2a5 100644 --- a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/tag/TagRepositoryImpl.java +++ b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/tag/TagRepositoryImpl.java @@ -3,7 +3,6 @@ import com.bamyanggang.domainmodule.domain.tag.aggregate.Tag; import com.bamyanggang.domainmodule.domain.tag.exception.TagException.NotFoundTag; import com.bamyanggang.domainmodule.domain.tag.repository.TagRepository; -import com.bamyanggang.persistence.common.exception.PersistenceException.NotFound; import com.bamyanggang.persistence.tag.jpa.entity.TagJpaEntity; import com.bamyanggang.persistence.tag.jpa.repository.TagJpaRepository; import com.bamyanggang.persistence.tag.mapper.TagMapper; @@ -57,4 +56,11 @@ public Tag findById(UUID tagId) { TagJpaEntity tagJpaEntity = tagJpaRepository.findById(tagId).orElseThrow(NotFoundTag::new); return tagMapper.toDomainEntity(tagJpaEntity); } + + @Override + public List findByNameContains(String search) { + List tagJpaEntities = tagJpaRepository.findByNameContaining(search); + + return tagJpaEntities.stream().map(tagMapper::toDomainEntity).toList(); + } } diff --git a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/tag/jpa/repository/TagJpaRepository.java b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/tag/jpa/repository/TagJpaRepository.java index 885f69da..1c2f0123 100644 --- a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/tag/jpa/repository/TagJpaRepository.java +++ b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/tag/jpa/repository/TagJpaRepository.java @@ -9,4 +9,6 @@ public interface TagJpaRepository extends JpaRepository { List findAllByUserIdAndParentTagIdIsNull(UUID userId); List findAllByUserIdAndParentTagId(UUID parentTagId, UUID parentId); + + List findByNameContaining(String search); }