Skip to content

Commit

Permalink
feat: 태그 이름 검색 기능 구현(#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
whereami2048 committed May 21, 2024
1 parent cd6bbdb commit 1437a15
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ interface TagRepository {
fun deleteByTagId(tagId: UUID)
fun isExistById(tagId: UUID): Boolean
fun findByParentTagIds(tagParentTagIds: List<UUID>): List<Tag>
fun findByNameContains(search: String): List<Tag>
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,8 @@ class TagReader(
fun readByIds(parentTagIds: List<UUID>): List<Tag> {
return tagRepository.findByParentTagIds(parentTagIds)
}

fun readIdsByNameContains(search: String) : List<UUID> {
return tagRepository.findByNameContains(search).map { it.id }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -57,4 +56,11 @@ public Tag findById(UUID tagId) {
TagJpaEntity tagJpaEntity = tagJpaRepository.findById(tagId).orElseThrow(NotFoundTag::new);
return tagMapper.toDomainEntity(tagJpaEntity);
}

@Override
public List<Tag> findByNameContains(String search) {
List<TagJpaEntity> tagJpaEntities = tagJpaRepository.findByNameContaining(search);

return tagJpaEntities.stream().map(tagMapper::toDomainEntity).toList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ public interface TagJpaRepository extends JpaRepository<TagJpaEntity, UUID> {
List<TagJpaEntity> findAllByUserIdAndParentTagIdIsNull(UUID userId);

List<TagJpaEntity> findAllByUserIdAndParentTagId(UUID parentTagId, UUID parentId);

List<TagJpaEntity> findByNameContaining(String search);
}

0 comments on commit 1437a15

Please sign in to comment.