From f3118aff20be9e68c0710f2c709553415bf2648f Mon Sep 17 00:00:00 2001 From: whereami0404 Date: Mon, 20 May 2024 23:13:20 +0900 Subject: [PATCH 01/23] =?UTF-8?q?chore:=20=ED=8A=B8=EB=9E=9C=EC=9E=AD?= =?UTF-8?q?=EC=85=98=20=EC=B6=94=EA=B0=80=20=EB=B0=8F=20API=20=EB=AA=85?= =?UTF-8?q?=EC=84=B8=20=EB=88=84=EB=9D=BD=20=EC=B6=94=EA=B0=80(#115)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Api-Module/src/docs/asciidoc/Tag.adoc | 4 ++-- .../apimodule/domain/bookmark/application/BookmarkService.kt | 1 - .../experience/application/service/ExperienceGetService.kt | 5 +++++ .../application/service/StrongPointDeleteService.kt | 3 ++- .../strongpoint/application/service/StrongPointGetService.kt | 2 ++ .../apimodule/domain/tag/presentation/TagControllerTest.kt | 2 +- 6 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Api-Module/src/docs/asciidoc/Tag.adoc b/Api-Module/src/docs/asciidoc/Tag.adoc index 56317819..7d9091aa 100644 --- a/Api-Module/src/docs/asciidoc/Tag.adoc +++ b/Api-Module/src/docs/asciidoc/Tag.adoc @@ -14,7 +14,7 @@ operation::TagControllerTest/createChildTagTest/[snippets='http-request,path-par [[GetParentTagTest]] === 상위 태그 조회 API -operation::TagControllerTest/getAllParentTagByUserRegisterTest/[snippets='http-request,request-headers,http-response,response-fields'] +operation::TagControllerTest/getAllParentTagByUserTest/[snippets='http-request,request-headers,http-response,response-fields'] [[GetTopRankTagTest]] === 연도 내 경험 최근 추가 순 태그 조회 API @@ -24,7 +24,7 @@ operation::TagControllerTest/getTopRankParentTagTest/[snippets='http-request,req [[GetParentTagsByFilter]] === 연도 내 상위 태그 조회 API -operation::TagControllerTest/getParentTagsByFilter/[snippets='http-request,http-response,response-fields'] +operation::TagControllerTest/getParentTagsByYear/[snippets='http-request,http-response,response-fields'] [[GetChildTagTest]] === 하위 태그 전체 조회 API diff --git a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/bookmark/application/BookmarkService.kt b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/bookmark/application/BookmarkService.kt index 07bc3671..be28926d 100644 --- a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/bookmark/application/BookmarkService.kt +++ b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/bookmark/application/BookmarkService.kt @@ -20,5 +20,4 @@ class BookmarkService( bookmarkModifier.modifyBookmarkStatus(it) } ?: bookmarkAppender.appendBookmark(jobDescriptionId, experienceId) } - } diff --git a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/application/service/ExperienceGetService.kt b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/application/service/ExperienceGetService.kt index 2b0559df..f4889ab3 100644 --- a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/application/service/ExperienceGetService.kt +++ b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/application/service/ExperienceGetService.kt @@ -8,6 +8,7 @@ import com.bamyanggang.domainmodule.domain.experience.service.ExperienceReader import com.bamyanggang.domainmodule.domain.strongpoint.service.StrongPointReader import com.bamyanggang.domainmodule.domain.tag.service.TagReader import org.springframework.stereotype.Service +import org.springframework.transaction.annotation.Transactional import java.util.* @Service @@ -16,11 +17,13 @@ class ExperienceGetService( private val strongPointReader: StrongPointReader, private val tagReader: TagReader, ) { + @Transactional(readOnly = true) fun getExperienceDetailById(experienceId: UUID) : GetExperience.DetailExperience { val oneExperience = experienceReader.readExperience(experienceId) return createExperienceDetailResponse(oneExperience) } + @Transactional(readOnly = true) fun getAllYearsByExistExperience(): ExperienceYear.Response { val currentUserId = getAuthenticationPrincipal() @@ -28,6 +31,7 @@ class ExperienceGetService( .let { ExperienceYear.Response(it) } } + @Transactional(readOnly = true) fun getExperienceByYearAndParentTag(year: Int, parentTagId: UUID): GetExperience.Response { val experiences = experienceReader.readByYearAndParentTagId(year, parentTagId).map { createExperienceDetailResponse(it) @@ -36,6 +40,7 @@ class ExperienceGetService( return GetExperience.Response(experiences) } + @Transactional(readOnly = true) fun getExperienceByYearAndChildTag(year: Int, childTagId: UUID): GetExperience.Response { val experiences = experienceReader.readByYearAndParentTagId(year, childTagId).map { createExperienceDetailResponse(it) diff --git a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/strongpoint/application/service/StrongPointDeleteService.kt b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/strongpoint/application/service/StrongPointDeleteService.kt index 93022637..c8ba5485 100644 --- a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/strongpoint/application/service/StrongPointDeleteService.kt +++ b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/strongpoint/application/service/StrongPointDeleteService.kt @@ -1,14 +1,15 @@ package com.bamyanggang.apimodule.domain.strongpoint.application.service -import ch.qos.logback.core.rolling.helper.ArchiveRemover import com.bamyanggang.domainmodule.domain.strongpoint.service.StrongPointRemover import org.springframework.stereotype.Service +import org.springframework.transaction.annotation.Transactional import java.util.* @Service class StrongPointDeleteService( private val strongPointRemover: StrongPointRemover ) { + @Transactional fun deleteStrongPoint(strongPointId: UUID) { strongPointRemover.removeStrongPoint(strongPointId) } diff --git a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/strongpoint/application/service/StrongPointGetService.kt b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/strongpoint/application/service/StrongPointGetService.kt index d57f7099..381bb97f 100644 --- a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/strongpoint/application/service/StrongPointGetService.kt +++ b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/strongpoint/application/service/StrongPointGetService.kt @@ -4,11 +4,13 @@ import com.bamyanggang.apimodule.common.getAuthenticationPrincipal import com.bamyanggang.apimodule.domain.strongpoint.application.dto.GetStrongPoint import com.bamyanggang.domainmodule.domain.strongpoint.service.StrongPointReader import org.springframework.stereotype.Service +import org.springframework.transaction.annotation.Transactional @Service class StrongPointGetService( private val strongPointReader: StrongPointReader, ) { + @Transactional(readOnly = true) fun getAllStrongPoints(): GetStrongPoint.Response { return getAuthenticationPrincipal().let { val detailStrongPoints = strongPointReader.readAllByUserId(it).map { strongPoint -> diff --git a/Api-Module/src/test/kotlin/com/bamyanggang/apimodule/domain/tag/presentation/TagControllerTest.kt b/Api-Module/src/test/kotlin/com/bamyanggang/apimodule/domain/tag/presentation/TagControllerTest.kt index 15e55e8f..db85d1d7 100644 --- a/Api-Module/src/test/kotlin/com/bamyanggang/apimodule/domain/tag/presentation/TagControllerTest.kt +++ b/Api-Module/src/test/kotlin/com/bamyanggang/apimodule/domain/tag/presentation/TagControllerTest.kt @@ -317,7 +317,7 @@ class TagControllerTest : BaseRestDocsTest() { fieldWithPath("tags[].name").description("태그 이름"), ) ) - ) + ) } @Test From 15e6a7cbd6446afddef67d7e1c98fdf5f1ec1a91 Mon Sep 17 00:00:00 2001 From: whereami0404 Date: Tue, 21 May 2024 02:37:45 +0900 Subject: [PATCH 02/23] =?UTF-8?q?feat:=20=EA=B2=BD=ED=97=98=20id=20?= =?UTF-8?q?=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EC=A1=B0=ED=9A=8C=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EA=B5=AC=ED=98=84(#115)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/experience/repository/ExperienceRepository.kt | 1 + .../domain/experience/service/ExperienceReader.kt | 4 ++++ .../persistence/experience/ExperienceRepositoryImpl.java | 6 ++++++ .../experience/jpa/repository/ExperienceJpaRepository.java | 7 +++++++ 4 files changed, 18 insertions(+) diff --git a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/repository/ExperienceRepository.kt b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/repository/ExperienceRepository.kt index f2679125..e958b2b2 100644 --- a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/repository/ExperienceRepository.kt +++ b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/repository/ExperienceRepository.kt @@ -11,4 +11,5 @@ interface ExperienceRepository { fun findByUserIdAndYearDesc(year: Int, userId: UUID): List fun findByYearAndParentTagId(year: Int, parentTagId: UUID): List fun findByYearAndChildTagId(year: Int, childTagId: UUID): List + fun findByIds(experienceIds: List): List } diff --git a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/service/ExperienceReader.kt b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/service/ExperienceReader.kt index 29849643..9dfdbbfb 100644 --- a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/service/ExperienceReader.kt +++ b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/service/ExperienceReader.kt @@ -37,4 +37,8 @@ class ExperienceReader( fun readByYearAndChildTagId(year: Int, childTagId: UUID): List { return experienceRepository.findByYearAndChildTagId(year, childTagId) } + + fun readByIds(experienceIds: List) : List { + return experienceRepository.findByIds(experienceIds) + } } diff --git a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/ExperienceRepositoryImpl.java b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/ExperienceRepositoryImpl.java index 28119760..5c284b0e 100644 --- a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/ExperienceRepositoryImpl.java +++ b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/ExperienceRepositoryImpl.java @@ -75,4 +75,10 @@ public List findByYearAndChildTagId(int year, UUID childTagId) { return experienceJpaEntities.stream().map(experienceMapper::toExperienceDomainEntity).toList(); } + + @Override + public List findByIds(List experienceIds) { + List experienceJpaEntities = experienceJpaRepository.findByIds(experienceIds); + return experienceJpaEntities.stream().map(experienceMapper::toExperienceDomainEntity).toList(); + } } diff --git a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/jpa/repository/ExperienceJpaRepository.java b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/jpa/repository/ExperienceJpaRepository.java index a8ad4f05..60c73e70 100644 --- a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/jpa/repository/ExperienceJpaRepository.java +++ b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/jpa/repository/ExperienceJpaRepository.java @@ -5,10 +5,17 @@ import java.util.List; import java.util.UUID; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; public interface ExperienceJpaRepository extends JpaRepository { List findAllByUserId(UUID userId); List findByUserIdAndCreatedAtBetweenOrderByCreatedAtDesc(UUID userId, LocalDateTime startYear, LocalDateTime endYear); List findByParentTagIdAndCreatedAtBetweenOrderByCreatedAtDesc(UUID parentTagId, LocalDateTime startYear, LocalDateTime endYear); List findByChildTagIdAndCreatedAtBetweenOrderByCreatedAtDesc(UUID childTagId, LocalDateTime startYear, LocalDateTime endYear); + + @Modifying + @Query("select e from ExperienceTagJpaEntity e where e.experienceId in :experienceIds") + List findByIds(@Param("experienceIds") List experienceIds); } From 253c09b7a19fca054555eb3b0593e115b7a9a5b8 Mon Sep 17 00:00:00 2001 From: whereami0404 Date: Tue, 21 May 2024 02:39:01 +0900 Subject: [PATCH 03/23] =?UTF-8?q?feat:=20=EB=B6=81=EB=A7=88=ED=81=AC=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84(?= =?UTF-8?q?=EC=A7=81=EB=AC=B4=20=EA=B3=B5=EA=B3=A0,=20=EC=83=81=ED=83=9C?= =?UTF-8?q?=20=EA=B8=B0=EC=A4=80)(#115)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bookmark/repository/BookmarkRepository.kt | 3 ++- .../domain/bookmark/service/BookmarkReader.kt | 5 +++++ .../bookmark/BookmarkRepositoryImpl.java | 13 +++++++++++++ .../jpa/repository/BookmarkJpaRepository.java | 4 +++- 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/bookmark/repository/BookmarkRepository.kt b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/bookmark/repository/BookmarkRepository.kt index fad1e5f1..f9dead80 100644 --- a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/bookmark/repository/BookmarkRepository.kt +++ b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/bookmark/repository/BookmarkRepository.kt @@ -1,6 +1,7 @@ package com.bamyanggang.domainmodule.domain.bookmark.repository import com.bamyanggang.domainmodule.domain.bookmark.aggregate.Bookmark +import com.bamyanggang.domainmodule.domain.bookmark.enums.BookmarkStatus import java.util.* interface BookmarkRepository { @@ -8,5 +9,5 @@ interface BookmarkRepository { fun findByIds(jobDescriptionId : UUID, experienceId : UUID) : Bookmark? fun save(bookmark: Bookmark) - + fun findByStatusOnAndJobDescriptionId(jobDescriptionId: UUID, status: BookmarkStatus): List } diff --git a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/bookmark/service/BookmarkReader.kt b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/bookmark/service/BookmarkReader.kt index f75abc1d..836b4731 100644 --- a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/bookmark/service/BookmarkReader.kt +++ b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/bookmark/service/BookmarkReader.kt @@ -1,6 +1,7 @@ package com.bamyanggang.domainmodule.domain.bookmark.service import com.bamyanggang.domainmodule.domain.bookmark.aggregate.Bookmark +import com.bamyanggang.domainmodule.domain.bookmark.enums.BookmarkStatus import com.bamyanggang.domainmodule.domain.bookmark.repository.BookmarkRepository import org.springframework.stereotype.Service import java.util.* @@ -14,4 +15,8 @@ class BookmarkReader( return bookmarkRepository.findByIds(jobDescriptionId, experienceId) } + fun readByStatusOnAndJobDescriptionId(jobDescriptionId: UUID): List { + return bookmarkRepository.findByStatusOnAndJobDescriptionId(jobDescriptionId, BookmarkStatus.ON) + } + } diff --git a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/bookmark/BookmarkRepositoryImpl.java b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/bookmark/BookmarkRepositoryImpl.java index 9a0c6bf9..6ee12dfd 100644 --- a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/bookmark/BookmarkRepositoryImpl.java +++ b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/bookmark/BookmarkRepositoryImpl.java @@ -1,10 +1,13 @@ package com.bamyanggang.persistence.bookmark; import com.bamyanggang.domainmodule.domain.bookmark.aggregate.Bookmark; +import com.bamyanggang.domainmodule.domain.bookmark.enums.BookmarkStatus; import com.bamyanggang.domainmodule.domain.bookmark.repository.BookmarkRepository; import com.bamyanggang.persistence.bookmark.jpa.entity.BookmarkJpaEntity; import com.bamyanggang.persistence.bookmark.jpa.repository.BookmarkJpaRepository; import com.bamyanggang.persistence.bookmark.mapper.BookmarkMapper; +import com.bamyanggang.persistence.experience.mapper.ExperienceMapper; +import java.util.List; import java.util.UUID; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Repository; @@ -14,6 +17,7 @@ public class BookmarkRepositoryImpl implements BookmarkRepository { private final BookmarkJpaRepository bookmarkJpaRepository; private final BookmarkMapper bookmarkMapper; + private final ExperienceMapper experienceMapper; @Override public Bookmark findByIds(UUID jobDescriptionId, UUID experienceId) { @@ -28,4 +32,13 @@ public void save(Bookmark bookmark) { bookmarkJpaRepository.save(bookmarkJpaEntity); } + @Override + public List findByStatusOnAndJobDescriptionId( + UUID jobDescriptionId, + BookmarkStatus status) { + List bookmarkJpaEntities = bookmarkJpaRepository + .findByBookmarkStatusAndJobDescriptionId(status, jobDescriptionId); + + return bookmarkJpaEntities.stream().map(bookmarkMapper::toDomainEntity).toList(); + } } diff --git a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/bookmark/jpa/repository/BookmarkJpaRepository.java b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/bookmark/jpa/repository/BookmarkJpaRepository.java index 48085863..9ec67a0e 100644 --- a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/bookmark/jpa/repository/BookmarkJpaRepository.java +++ b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/bookmark/jpa/repository/BookmarkJpaRepository.java @@ -1,6 +1,8 @@ package com.bamyanggang.persistence.bookmark.jpa.repository; +import com.bamyanggang.domainmodule.domain.bookmark.enums.BookmarkStatus; import com.bamyanggang.persistence.bookmark.jpa.entity.BookmarkJpaEntity; +import java.util.List; import java.util.Optional; import java.util.UUID; import org.springframework.data.jpa.repository.JpaRepository; @@ -8,5 +10,5 @@ public interface BookmarkJpaRepository extends JpaRepository { Optional findByJobDescriptionIdAndExperienceId(UUID jobDescriptionId, UUID experienceId); - + List findByBookmarkStatusAndJobDescriptionId(BookmarkStatus status, UUID jobDescriptionId); } From 7f033e4469c984c4f01d49fdc27d0ea90b8b4417 Mon Sep 17 00:00:00 2001 From: whereami0404 Date: Tue, 21 May 2024 02:39:13 +0900 Subject: [PATCH 04/23] =?UTF-8?q?feat:=20=EB=B6=81=EB=A7=88=ED=81=AC?= =?UTF-8?q?=ED=95=9C=20=EA=B2=BD=ED=97=98=20=EC=A1=B0=ED=9A=8C=20APi=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84(#115)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/ExperienceGetService.kt | 53 ++++++++++++++----- .../experience/presentation/ExperienceApi.kt | 1 + .../presentation/ExperienceController.kt | 12 ++++- 3 files changed, 53 insertions(+), 13 deletions(-) diff --git a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/application/service/ExperienceGetService.kt b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/application/service/ExperienceGetService.kt index f4889ab3..a3690691 100644 --- a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/application/service/ExperienceGetService.kt +++ b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/application/service/ExperienceGetService.kt @@ -3,7 +3,10 @@ package com.bamyanggang.apimodule.domain.experience.application.service import com.bamyanggang.apimodule.common.getAuthenticationPrincipal import com.bamyanggang.apimodule.domain.experience.application.dto.ExperienceYear import com.bamyanggang.apimodule.domain.experience.application.dto.GetExperience +import com.bamyanggang.domainmodule.domain.bookmark.service.BookmarkReader import com.bamyanggang.domainmodule.domain.experience.aggregate.Experience +import com.bamyanggang.domainmodule.domain.experience.aggregate.ExperienceContent +import com.bamyanggang.domainmodule.domain.experience.aggregate.ExperienceStrongPoint import com.bamyanggang.domainmodule.domain.experience.service.ExperienceReader import com.bamyanggang.domainmodule.domain.strongpoint.service.StrongPointReader import com.bamyanggang.domainmodule.domain.tag.service.TagReader @@ -16,6 +19,7 @@ class ExperienceGetService( private val experienceReader: ExperienceReader, private val strongPointReader: StrongPointReader, private val tagReader: TagReader, + private val bookMarkReader: BookmarkReader ) { @Transactional(readOnly = true) fun getExperienceDetailById(experienceId: UUID) : GetExperience.DetailExperience { @@ -49,11 +53,36 @@ class ExperienceGetService( return GetExperience.Response(experiences) } + @Transactional(readOnly = true) + fun getBookMarkExperiences(jobDescriptionId: UUID): GetExperience.Response { + val experienceIds = bookMarkReader.readByStatusOnAndJobDescriptionId(jobDescriptionId).map { it.experienceId } + + val detailExperiences = experienceReader.readByIds(experienceIds).map { + val detailParentTag = convertParentTag(it.parentTagId) + val detailChildTag = convertChildTag(it.childTagId) + val detailStrongPoints = convertStrongPoints(it.strongPoints) + val detailContents = convertDetailExperienceContent(it.contents) + + GetExperience.DetailExperience( + id = it.id, + title = it.title, + parentTag = detailParentTag, + childTag = detailChildTag, + strongPoints = detailStrongPoints, + contents = detailContents, + startedAt = it.startedAt, + endedAt = it.endedAt + ) + } + + return GetExperience.Response(detailExperiences) + } + private fun createExperienceDetailResponse(experience: Experience): GetExperience.DetailExperience { - val detailExperienceContents = convertDetailExperienceContent(experience) - val strongPointDetails = convertStrongPoints(experience) - val detailParentTag = convertParentTag(experience) - val detailChildTag = convertChildTag(experience) + val detailExperienceContents = convertDetailExperienceContent(experience.contents) + val strongPointDetails = convertStrongPoints(experience.strongPoints) + val detailParentTag = convertParentTag(experience.parentTagId) + val detailChildTag = convertChildTag(experience.childTagId) return GetExperience.DetailExperience( id = experience.id, @@ -67,31 +96,31 @@ class ExperienceGetService( ) } - private fun convertChildTag(oneExperience: Experience) = - tagReader.readById(oneExperience.childTagId).let { + private fun convertChildTag(childTagId: UUID) = + tagReader.readById(childTagId).let { GetExperience.DetailTag( it.id, it.name ) } - private fun convertParentTag(oneExperience: Experience) = - tagReader.readById(oneExperience.parentTagId).let { + private fun convertParentTag(parentTagId: UUID) = + tagReader.readById(parentTagId).let { GetExperience.DetailTag( it.id, it.name ) } - private fun convertDetailExperienceContent(experience: Experience) = - experience.contents.map { GetExperience.DetailExperienceContent( + private fun convertDetailExperienceContent(contents: List) = + contents.map { GetExperience.DetailExperienceContent( it.question, it.answer ) } - private fun convertStrongPoints(experience: Experience) = - experience.strongPoints.map { it.strongPointId }.let { + private fun convertStrongPoints(strongPoints: List) = + strongPoints.map { it.strongPointId }.let { strongPointReader.readByIds(it).map { strongPoint -> GetExperience.DetailStrongPoint( strongPoint.id, diff --git a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/presentation/ExperienceApi.kt b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/presentation/ExperienceApi.kt index 9f597e3f..5319b617 100644 --- a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/presentation/ExperienceApi.kt +++ b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/presentation/ExperienceApi.kt @@ -4,4 +4,5 @@ object ExperienceApi { const val BASE_URL = "/api/experiences" const val EXPERIENCE_PATH_VARIABLE_URL = "$BASE_URL/{experienceId}" const val ALL_YEARS = "$BASE_URL/all-years" + const val BOOKMARK_EXPERIENCE_URL = "$BASE_URL/{jobDescriptionId}" } diff --git a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/presentation/ExperienceController.kt b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/presentation/ExperienceController.kt index e412fb6c..0cd422aa 100644 --- a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/presentation/ExperienceController.kt +++ b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/presentation/ExperienceController.kt @@ -1,6 +1,9 @@ package com.bamyanggang.apimodule.domain.experience.presentation -import com.bamyanggang.apimodule.domain.experience.application.dto.* +import com.bamyanggang.apimodule.domain.experience.application.dto.CreateExperience +import com.bamyanggang.apimodule.domain.experience.application.dto.EditExperience +import com.bamyanggang.apimodule.domain.experience.application.dto.ExperienceYear +import com.bamyanggang.apimodule.domain.experience.application.dto.GetExperience import com.bamyanggang.apimodule.domain.experience.application.service.ExperienceCreateService import com.bamyanggang.apimodule.domain.experience.application.service.ExperienceDeleteService import com.bamyanggang.apimodule.domain.experience.application.service.ExperienceEditService @@ -15,6 +18,13 @@ class ExperienceController( private val experienceEditService: ExperienceEditService, private val experienceGetService: ExperienceGetService ) { + @GetMapping(ExperienceApi.BOOKMARK_EXPERIENCE_URL) + fun getBookMarkExperiences( + @PathVariable("jobDescriptionId") jobDescriptionId: UUID + ) : GetExperience.Response{ + return experienceGetService.getBookMarkExperiences(jobDescriptionId) + } + @GetMapping(ExperienceApi.BASE_URL) fun getExperienceByFilter(@RequestParam("year") year: Int, @RequestParam("parent-tag") parentTagId: UUID, From e211d1942199b626bca88a1a399a73ec4cba4aca Mon Sep 17 00:00:00 2001 From: whereami0404 Date: Tue, 21 May 2024 17:21:34 +0900 Subject: [PATCH 05/23] =?UTF-8?q?feat:=20JD=20id=20&=20=EC=83=81=ED=83=9C?= =?UTF-8?q?=20=EB=B3=84=20=EB=B6=81=EB=A7=88=ED=81=AC=20=EC=A1=B0=ED=9A=8C?= =?UTF-8?q?=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84(#115)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/bookmark/repository/BookmarkRepository.kt | 2 +- .../domainmodule/domain/bookmark/service/BookmarkReader.kt | 4 ++-- .../persistence/bookmark/BookmarkRepositoryImpl.java | 4 +--- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/bookmark/repository/BookmarkRepository.kt b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/bookmark/repository/BookmarkRepository.kt index f9dead80..5f963adf 100644 --- a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/bookmark/repository/BookmarkRepository.kt +++ b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/bookmark/repository/BookmarkRepository.kt @@ -9,5 +9,5 @@ interface BookmarkRepository { fun findByIds(jobDescriptionId : UUID, experienceId : UUID) : Bookmark? fun save(bookmark: Bookmark) - fun findByStatusOnAndJobDescriptionId(jobDescriptionId: UUID, status: BookmarkStatus): List + fun findByStatusAndJobDescriptionId(jobDescriptionId: UUID, status: BookmarkStatus): List } diff --git a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/bookmark/service/BookmarkReader.kt b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/bookmark/service/BookmarkReader.kt index 836b4731..cf7b41d9 100644 --- a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/bookmark/service/BookmarkReader.kt +++ b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/bookmark/service/BookmarkReader.kt @@ -15,8 +15,8 @@ class BookmarkReader( return bookmarkRepository.findByIds(jobDescriptionId, experienceId) } - fun readByStatusOnAndJobDescriptionId(jobDescriptionId: UUID): List { - return bookmarkRepository.findByStatusOnAndJobDescriptionId(jobDescriptionId, BookmarkStatus.ON) + fun readByStatusAndJobDescriptionId(jobDescriptionId: UUID, status: BookmarkStatus): List { + return bookmarkRepository.findByStatusAndJobDescriptionId(jobDescriptionId, status) } } diff --git a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/bookmark/BookmarkRepositoryImpl.java b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/bookmark/BookmarkRepositoryImpl.java index 6ee12dfd..1770f85f 100644 --- a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/bookmark/BookmarkRepositoryImpl.java +++ b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/bookmark/BookmarkRepositoryImpl.java @@ -33,9 +33,7 @@ public void save(Bookmark bookmark) { } @Override - public List findByStatusOnAndJobDescriptionId( - UUID jobDescriptionId, - BookmarkStatus status) { + public List findByStatusAndJobDescriptionId(UUID jobDescriptionId, BookmarkStatus status) { List bookmarkJpaEntities = bookmarkJpaRepository .findByBookmarkStatusAndJobDescriptionId(status, jobDescriptionId); From 3709f5c4ba35d5dae9b9fe24d864b78cdb6d8873 Mon Sep 17 00:00:00 2001 From: whereami0404 Date: Tue, 21 May 2024 17:21:53 +0900 Subject: [PATCH 06/23] =?UTF-8?q?feat:=20=EB=B6=81=EB=A7=88=ED=81=AC=20Boo?= =?UTF-8?q?lean=20=EC=83=81=ED=83=9C=20=EA=B0=92=20=EC=B6=94=EA=B0=80(#115?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domainmodule/domain/bookmark/enums/BookmarkStatus.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/bookmark/enums/BookmarkStatus.kt b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/bookmark/enums/BookmarkStatus.kt index 93f1b305..62147d34 100644 --- a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/bookmark/enums/BookmarkStatus.kt +++ b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/bookmark/enums/BookmarkStatus.kt @@ -1,6 +1,6 @@ package com.bamyanggang.domainmodule.domain.bookmark.enums -enum class BookmarkStatus { - ON, - OFF +enum class BookmarkStatus(val boolStatus: Boolean) { + ON(true), + OFF(false) } From 20d0956c2e414e098af93770bc3dd024d65f360c Mon Sep 17 00:00:00 2001 From: whereami0404 Date: Tue, 21 May 2024 17:22:07 +0900 Subject: [PATCH 07/23] =?UTF-8?q?feat:=20=EB=B6=81=EB=A7=88=ED=81=AC=20?= =?UTF-8?q?=EA=B2=BD=ED=97=98=20=EC=A0=84=EC=B2=B4=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?API=20=EA=B5=AC=ED=98=84(#115)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/dto/GetExperience.kt | 17 ++++++ .../service/ExperienceGetService.kt | 53 +++++++++++-------- .../experience/presentation/ExperienceApi.kt | 2 +- .../presentation/ExperienceController.kt | 6 +-- 4 files changed, 53 insertions(+), 25 deletions(-) diff --git a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/application/dto/GetExperience.kt b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/application/dto/GetExperience.kt index 38c65b01..8ce97b26 100644 --- a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/application/dto/GetExperience.kt +++ b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/application/dto/GetExperience.kt @@ -19,6 +19,23 @@ class GetExperience { val endedAt: LocalDateTime, ) + data class BookmarkResponse( + val experience: List + ) + + data class BookmarkDetailExperience( + val id: UUID, + val title: String, + val parentTag: DetailTag, + val childTag: DetailTag, + val strongPoints: List, + val contents: List, + val startedAt: LocalDateTime, + val endedAt: LocalDateTime, + val bookmarked: Boolean, + ) + + data class DetailExperienceContent( val question: String, val answer: String, diff --git a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/application/service/ExperienceGetService.kt b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/application/service/ExperienceGetService.kt index a3690691..87bc7bd9 100644 --- a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/application/service/ExperienceGetService.kt +++ b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/application/service/ExperienceGetService.kt @@ -3,6 +3,7 @@ package com.bamyanggang.apimodule.domain.experience.application.service import com.bamyanggang.apimodule.common.getAuthenticationPrincipal import com.bamyanggang.apimodule.domain.experience.application.dto.ExperienceYear import com.bamyanggang.apimodule.domain.experience.application.dto.GetExperience +import com.bamyanggang.domainmodule.domain.bookmark.enums.BookmarkStatus import com.bamyanggang.domainmodule.domain.bookmark.service.BookmarkReader import com.bamyanggang.domainmodule.domain.experience.aggregate.Experience import com.bamyanggang.domainmodule.domain.experience.aggregate.ExperienceContent @@ -46,7 +47,7 @@ class ExperienceGetService( @Transactional(readOnly = true) fun getExperienceByYearAndChildTag(year: Int, childTagId: UUID): GetExperience.Response { - val experiences = experienceReader.readByYearAndParentTagId(year, childTagId).map { + val experiences = experienceReader.readByYearAndChildTagId(year, childTagId).map { createExperienceDetailResponse(it) } @@ -54,28 +55,19 @@ class ExperienceGetService( } @Transactional(readOnly = true) - fun getBookMarkExperiences(jobDescriptionId: UUID): GetExperience.Response { - val experienceIds = bookMarkReader.readByStatusOnAndJobDescriptionId(jobDescriptionId).map { it.experienceId } - - val detailExperiences = experienceReader.readByIds(experienceIds).map { - val detailParentTag = convertParentTag(it.parentTagId) - val detailChildTag = convertChildTag(it.childTagId) - val detailStrongPoints = convertStrongPoints(it.strongPoints) - val detailContents = convertDetailExperienceContent(it.contents) - - GetExperience.DetailExperience( - id = it.id, - title = it.title, - parentTag = detailParentTag, - childTag = detailChildTag, - strongPoints = detailStrongPoints, - contents = detailContents, - startedAt = it.startedAt, - endedAt = it.endedAt - ) + fun getAllBookMarkExperiences(jobDescriptionId: UUID): GetExperience.BookmarkResponse { + val experienceIds = bookMarkReader.readByStatusAndJobDescriptionId(jobDescriptionId, BookmarkStatus.ON).map { it.experienceId } + + val userExperiences = experienceReader.readAllByUserId(getAuthenticationPrincipal()) + + val bookmarkExperienceDetails = userExperiences.map { + when { + it.id in experienceIds -> createBookmarkExperienceDetailResponse(it, BookmarkStatus.ON) + else -> createBookmarkExperienceDetailResponse(it, BookmarkStatus.OFF) + } } - return GetExperience.Response(detailExperiences) + return GetExperience.BookmarkResponse(bookmarkExperienceDetails) } private fun createExperienceDetailResponse(experience: Experience): GetExperience.DetailExperience { @@ -96,6 +88,25 @@ class ExperienceGetService( ) } + private fun createBookmarkExperienceDetailResponse(experience: Experience, bookmarkStatus: BookmarkStatus): GetExperience.BookmarkDetailExperience { + val detailExperienceContents = convertDetailExperienceContent(experience.contents) + val strongPointDetails = convertStrongPoints(experience.strongPoints) + val detailParentTag = convertParentTag(experience.parentTagId) + val detailChildTag = convertChildTag(experience.childTagId) + + return GetExperience.BookmarkDetailExperience( + id = experience.id, + title = experience.title, + parentTag = detailParentTag, + childTag = detailChildTag, + strongPoints = strongPointDetails, + contents = detailExperienceContents, + startedAt = experience.startedAt, + endedAt = experience.endedAt, + bookmarked = bookmarkStatus.boolStatus + ) + } + private fun convertChildTag(childTagId: UUID) = tagReader.readById(childTagId).let { GetExperience.DetailTag( diff --git a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/presentation/ExperienceApi.kt b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/presentation/ExperienceApi.kt index 5319b617..2946ca96 100644 --- a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/presentation/ExperienceApi.kt +++ b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/presentation/ExperienceApi.kt @@ -4,5 +4,5 @@ object ExperienceApi { const val BASE_URL = "/api/experiences" const val EXPERIENCE_PATH_VARIABLE_URL = "$BASE_URL/{experienceId}" const val ALL_YEARS = "$BASE_URL/all-years" - const val BOOKMARK_EXPERIENCE_URL = "$BASE_URL/{jobDescriptionId}" + const val BOOKMARK_EXPERIENCE_URL = "$BASE_URL/bookmark/{jobDescriptionId}" } diff --git a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/presentation/ExperienceController.kt b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/presentation/ExperienceController.kt index 0cd422aa..e14fa0e6 100644 --- a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/presentation/ExperienceController.kt +++ b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/presentation/ExperienceController.kt @@ -20,9 +20,9 @@ class ExperienceController( ) { @GetMapping(ExperienceApi.BOOKMARK_EXPERIENCE_URL) fun getBookMarkExperiences( - @PathVariable("jobDescriptionId") jobDescriptionId: UUID - ) : GetExperience.Response{ - return experienceGetService.getBookMarkExperiences(jobDescriptionId) + @PathVariable("jobDescriptionId") jobDescriptionId: UUID, + ) : GetExperience.BookmarkResponse { + return experienceGetService.getAllBookMarkExperiences(jobDescriptionId) } @GetMapping(ExperienceApi.BASE_URL) From 767166062b51bd57ea585e978214acca338c36a4 Mon Sep 17 00:00:00 2001 From: whereami2048 Date: Tue, 21 May 2024 17:37:11 +0900 Subject: [PATCH 08/23] =?UTF-8?q?feat:=20=EA=B2=BD=ED=97=98=20=EA=B2=80?= =?UTF-8?q?=EC=83=89=20API=20=EC=A0=95=EC=9D=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/service/ExperienceGetService.kt | 6 +++++- .../experience/presentation/ExperienceController.kt | 9 ++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/application/service/ExperienceGetService.kt b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/application/service/ExperienceGetService.kt index 87bc7bd9..ad1ccf00 100644 --- a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/application/service/ExperienceGetService.kt +++ b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/application/service/ExperienceGetService.kt @@ -55,7 +55,7 @@ class ExperienceGetService( } @Transactional(readOnly = true) - fun getAllBookMarkExperiences(jobDescriptionId: UUID): GetExperience.BookmarkResponse { + fun getAllBookmarkExperiences(jobDescriptionId: UUID): GetExperience.BookmarkResponse { val experienceIds = bookMarkReader.readByStatusAndJobDescriptionId(jobDescriptionId, BookmarkStatus.ON).map { it.experienceId } val userExperiences = experienceReader.readAllByUserId(getAuthenticationPrincipal()) @@ -139,4 +139,8 @@ class ExperienceGetService( ) } } + + fun getBookmarkExperienceBySearch(search: String): GetExperience.BookmarkResponse { + return GetExperience.BookmarkResponse(emptyList()) + } } diff --git a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/presentation/ExperienceController.kt b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/presentation/ExperienceController.kt index e14fa0e6..fa6898f6 100644 --- a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/presentation/ExperienceController.kt +++ b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/presentation/ExperienceController.kt @@ -21,9 +21,12 @@ class ExperienceController( @GetMapping(ExperienceApi.BOOKMARK_EXPERIENCE_URL) fun getBookMarkExperiences( @PathVariable("jobDescriptionId") jobDescriptionId: UUID, - ) : GetExperience.BookmarkResponse { - return experienceGetService.getAllBookMarkExperiences(jobDescriptionId) - } + @RequestParam("search", required = false) search: String?, + ) : GetExperience.BookmarkResponse = + when (search) { + null -> experienceGetService.getAllBookmarkExperiences(jobDescriptionId) + else -> experienceGetService.getBookmarkExperienceBySearch(search) + } @GetMapping(ExperienceApi.BASE_URL) fun getExperienceByFilter(@RequestParam("year") year: Int, From e4759a62bb5b681451d2f47567b1f6f5f7eb00c8 Mon Sep 17 00:00:00 2001 From: whereami0404 Date: Tue, 21 May 2024 20:51:38 +0900 Subject: [PATCH 09/23] =?UTF-8?q?feat:=20=EB=B6=81=EB=A7=88=ED=81=AC=20?= =?UTF-8?q?=EA=B2=BD=ED=97=98=20=EC=95=84=EC=9D=B4=EB=94=94=EB=A1=9C=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EA=B8=B0=EB=8A=A5=20=EC=A0=95=EC=9D=98(#1?= =?UTF-8?q?15)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/bookmark/repository/BookmarkRepository.kt | 3 ++- .../domainmodule/domain/bookmark/service/BookmarkReader.kt | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/bookmark/repository/BookmarkRepository.kt b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/bookmark/repository/BookmarkRepository.kt index 5f963adf..1f51bb9c 100644 --- a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/bookmark/repository/BookmarkRepository.kt +++ b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/bookmark/repository/BookmarkRepository.kt @@ -6,8 +6,9 @@ import java.util.* interface BookmarkRepository { - fun findByIds(jobDescriptionId : UUID, experienceId : UUID) : Bookmark? + fun findById(jobDescriptionId : UUID, experienceId : UUID) : Bookmark? fun save(bookmark: Bookmark) fun findByStatusAndJobDescriptionId(jobDescriptionId: UUID, status: BookmarkStatus): List + fun findByExperienceIds(): List } diff --git a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/bookmark/service/BookmarkReader.kt b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/bookmark/service/BookmarkReader.kt index cf7b41d9..e5129d3c 100644 --- a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/bookmark/service/BookmarkReader.kt +++ b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/bookmark/service/BookmarkReader.kt @@ -12,11 +12,14 @@ class BookmarkReader( ) { fun readBookmark(jobDescriptionId: UUID, experienceId: UUID) : Bookmark? { - return bookmarkRepository.findByIds(jobDescriptionId, experienceId) + return bookmarkRepository.findById(jobDescriptionId, experienceId) } fun readByStatusAndJobDescriptionId(jobDescriptionId: UUID, status: BookmarkStatus): List { return bookmarkRepository.findByStatusAndJobDescriptionId(jobDescriptionId, status) } + fun readByExperienceIds(experiencesIds: List) : List{ + return bookmarkRepository.findByExperienceIds() + } } From cd6bbdb00f524dd31b234eca19a86f2e5ae83ad0 Mon Sep 17 00:00:00 2001 From: whereami0404 Date: Tue, 21 May 2024 20:53:28 +0900 Subject: [PATCH 10/23] =?UTF-8?q?feat:=20=EA=B2=BD=ED=97=98=20=EA=B2=80?= =?UTF-8?q?=EC=83=89=20=EA=B8=B0=EB=8A=A5=20=EC=A0=95=EC=9D=98(#115)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../experience/repository/ExperienceRepository.kt | 1 + .../domain/experience/service/ExperienceReader.kt | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/repository/ExperienceRepository.kt b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/repository/ExperienceRepository.kt index e958b2b2..dd8bfe2c 100644 --- a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/repository/ExperienceRepository.kt +++ b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/repository/ExperienceRepository.kt @@ -12,4 +12,5 @@ interface ExperienceRepository { fun findByYearAndParentTagId(year: Int, parentTagId: UUID): List fun findByYearAndChildTagId(year: Int, childTagId: UUID): List fun findByIds(experienceIds: List): List + fun findByTitleContains(search: String): List } diff --git a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/service/ExperienceReader.kt b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/service/ExperienceReader.kt index 9dfdbbfb..998ff249 100644 --- a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/service/ExperienceReader.kt +++ b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/service/ExperienceReader.kt @@ -41,4 +41,17 @@ class ExperienceReader( fun readByIds(experienceIds: List) : List { return experienceRepository.findByIds(experienceIds) } + + fun readByTitleContains(search: String): List { + return experienceRepository.findByTitleContains(search).map { it.id } + } + + fun readByContentsContains(userId: UUID, search: String): List { + val experiences = experienceRepository.findAllByUserId(userId) + + return experiences.filter { + it.contents.map { content -> + content.question.contains(search) || content.answer.contains(search) + }.contains(true) }.map { it.id } + } } From 1437a15eea6c1e1a9a1a87ba69807df0ca646bdb Mon Sep 17 00:00:00 2001 From: whereami0404 Date: Tue, 21 May 2024 20:54:11 +0900 Subject: [PATCH 11/23] =?UTF-8?q?feat:=20=ED=83=9C=EA=B7=B8=20=EC=9D=B4?= =?UTF-8?q?=EB=A6=84=20=EA=B2=80=EC=83=89=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84(#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); } From 36734b132f01f55e5bd4b81bc80814eddc1878de Mon Sep 17 00:00:00 2001 From: whereami0404 Date: Tue, 21 May 2024 20:54:28 +0900 Subject: [PATCH 12/23] =?UTF-8?q?feat:=20=EC=97=AD=EB=9F=89=20=ED=82=A4?= =?UTF-8?q?=EC=9B=8C=EB=93=9C=20=EC=9D=B4=EB=A6=84=20=EA=B2=80=EC=83=89=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84(#115)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/strongpoint/repository/StrongPointRepository.kt | 1 + .../domain/strongpoint/service/StrongPointReader.kt | 4 ++++ .../persistence/strongpoint/StrongPointRepositoryImpl.java | 6 ++++++ .../jpa/repository/StrongPointJpaRepository.java | 2 ++ 4 files changed, 13 insertions(+) diff --git a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/strongpoint/repository/StrongPointRepository.kt b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/strongpoint/repository/StrongPointRepository.kt index a7e63cd9..230a1775 100644 --- a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/strongpoint/repository/StrongPointRepository.kt +++ b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/strongpoint/repository/StrongPointRepository.kt @@ -10,4 +10,5 @@ interface StrongPointRepository { fun isExistByStrongPointId(strongPointId: UUID): Boolean fun findByIds(strongPointIds: List) : List fun saveAll(strongPoints: List) + fun findByNameContains(search: String): List } diff --git a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/strongpoint/service/StrongPointReader.kt b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/strongpoint/service/StrongPointReader.kt index 857d30f3..e135bf59 100644 --- a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/strongpoint/service/StrongPointReader.kt +++ b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/strongpoint/service/StrongPointReader.kt @@ -16,4 +16,8 @@ class StrongPointReader( fun readByIds(strongPointIds: List) : List { return strongPointRepository.findByIds(strongPointIds) } + + fun readIdsByNameContains(search: String) : List { + return strongPointRepository.findByNameContains(search).map { it.id } + } } diff --git a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/strongpoint/StrongPointRepositoryImpl.java b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/strongpoint/StrongPointRepositoryImpl.java index f34a2465..f59dfb41 100644 --- a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/strongpoint/StrongPointRepositoryImpl.java +++ b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/strongpoint/StrongPointRepositoryImpl.java @@ -51,4 +51,10 @@ public void saveAll(List strongPoints) { strongPointJpaRepository.saveAll(strongPointJpaEntities); } + + @Override + public List findByNameContains(String search) { + List strongPointJpaEntities = strongPointJpaRepository.findByNameContaining(search); + return strongPointJpaEntities.stream().map(strongPointMapper::toDomainEntity).toList(); + } } diff --git a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/strongpoint/jpa/repository/StrongPointJpaRepository.java b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/strongpoint/jpa/repository/StrongPointJpaRepository.java index 5ddf69d4..21c7b8a3 100644 --- a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/strongpoint/jpa/repository/StrongPointJpaRepository.java +++ b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/strongpoint/jpa/repository/StrongPointJpaRepository.java @@ -14,4 +14,6 @@ public interface StrongPointJpaRepository extends JpaRepository findByIds(@Param("strongPoints") List strongPointIds); + + List findByNameContaining(String search); } From 8e7c404014a4600e1759454a0dd137a92670f5a2 Mon Sep 17 00:00:00 2001 From: whereami0404 Date: Tue, 21 May 2024 20:55:11 +0900 Subject: [PATCH 13/23] =?UTF-8?q?feat:=20=EA=B2=BD=ED=97=98=20=EC=A0=9C?= =?UTF-8?q?=EB=AA=A9=20&=20=EB=82=B4=EC=9A=A9=20=EA=B2=80=EC=83=89=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84=EC=B2=B4=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20=EB=B0=8F=20=EB=B6=81=EB=A7=88=ED=81=AC=20=EA=B2=BD?= =?UTF-8?q?=ED=97=98=20id=20=EB=B0=B0=EC=97=B4=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84(#115)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/bookmark/service/BookmarkReaderTest.kt | 2 +- .../persistence/bookmark/BookmarkRepositoryImpl.java | 2 +- .../persistence/experience/ExperienceRepositoryImpl.java | 5 +++++ .../experience/jpa/repository/ExperienceJpaRepository.java | 1 + 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Domain-Module/src/test/kotlin/com/bamyanggang/domainmodule/domain/bookmark/service/BookmarkReaderTest.kt b/Domain-Module/src/test/kotlin/com/bamyanggang/domainmodule/domain/bookmark/service/BookmarkReaderTest.kt index 7c0b63c2..b1b61d35 100644 --- a/Domain-Module/src/test/kotlin/com/bamyanggang/domainmodule/domain/bookmark/service/BookmarkReaderTest.kt +++ b/Domain-Module/src/test/kotlin/com/bamyanggang/domainmodule/domain/bookmark/service/BookmarkReaderTest.kt @@ -16,7 +16,7 @@ class BookmarkReaderTest: BehaviorSpec({ val jobDescriptionId = UUID.randomUUID() val experienceId = UUID.randomUUID() val expectedBookmark = mockk() - every { mockBookmarkRepository.findByIds(jobDescriptionId, experienceId) } returns expectedBookmark + every { mockBookmarkRepository.findById(jobDescriptionId, experienceId) } returns expectedBookmark `when`("북마크를 조회하면") { val result = bookmarkReader.readBookmark(jobDescriptionId, experienceId) diff --git a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/bookmark/BookmarkRepositoryImpl.java b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/bookmark/BookmarkRepositoryImpl.java index 1770f85f..cacbb10d 100644 --- a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/bookmark/BookmarkRepositoryImpl.java +++ b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/bookmark/BookmarkRepositoryImpl.java @@ -20,7 +20,7 @@ public class BookmarkRepositoryImpl implements BookmarkRepository { private final ExperienceMapper experienceMapper; @Override - public Bookmark findByIds(UUID jobDescriptionId, UUID experienceId) { + public Bookmark findById(UUID jobDescriptionId, UUID experienceId) { return bookmarkJpaRepository.findByJobDescriptionIdAndExperienceId(jobDescriptionId, experienceId) .map(bookmarkMapper::toDomainEntity) .orElse(null); diff --git a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/ExperienceRepositoryImpl.java b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/ExperienceRepositoryImpl.java index 5c284b0e..5338ac30 100644 --- a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/ExperienceRepositoryImpl.java +++ b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/ExperienceRepositoryImpl.java @@ -81,4 +81,9 @@ public List findByIds(List experienceIds) { List experienceJpaEntities = experienceJpaRepository.findByIds(experienceIds); return experienceJpaEntities.stream().map(experienceMapper::toExperienceDomainEntity).toList(); } + + public List findByTitleContains(String search) { + List experienceJpaEntities = experienceJpaRepository.findByTitleContaining(search); + return experienceJpaEntities.stream().map(experienceMapper::toExperienceDomainEntity).toList(); + } } diff --git a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/jpa/repository/ExperienceJpaRepository.java b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/jpa/repository/ExperienceJpaRepository.java index 60c73e70..dd2d62ab 100644 --- a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/jpa/repository/ExperienceJpaRepository.java +++ b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/jpa/repository/ExperienceJpaRepository.java @@ -14,6 +14,7 @@ public interface ExperienceJpaRepository extends JpaRepository findByUserIdAndCreatedAtBetweenOrderByCreatedAtDesc(UUID userId, LocalDateTime startYear, LocalDateTime endYear); List findByParentTagIdAndCreatedAtBetweenOrderByCreatedAtDesc(UUID parentTagId, LocalDateTime startYear, LocalDateTime endYear); List findByChildTagIdAndCreatedAtBetweenOrderByCreatedAtDesc(UUID childTagId, LocalDateTime startYear, LocalDateTime endYear); + List findByTitleContaining(String title); @Modifying @Query("select e from ExperienceTagJpaEntity e where e.experienceId in :experienceIds") From 1f1dc61f219323a42ea6c639b20da60a6c0e7cf6 Mon Sep 17 00:00:00 2001 From: whereami0404 Date: Tue, 21 May 2024 20:55:27 +0900 Subject: [PATCH 14/23] =?UTF-8?q?feat:=20=EA=B2=BD=ED=97=98=20=EA=B2=80?= =?UTF-8?q?=EC=83=89=20=EA=B8=B0=EB=8A=A5=20API=20=EA=B5=AC=ED=98=84(#115)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/ExperienceGetService.kt | 36 ++++++++++++++----- .../presentation/ExperienceController.kt | 2 +- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/application/service/ExperienceGetService.kt b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/application/service/ExperienceGetService.kt index ad1ccf00..29c74c8e 100644 --- a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/application/service/ExperienceGetService.kt +++ b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/application/service/ExperienceGetService.kt @@ -20,7 +20,7 @@ class ExperienceGetService( private val experienceReader: ExperienceReader, private val strongPointReader: StrongPointReader, private val tagReader: TagReader, - private val bookMarkReader: BookmarkReader + private val bookMarkReader: BookmarkReader, ) { @Transactional(readOnly = true) fun getExperienceDetailById(experienceId: UUID) : GetExperience.DetailExperience { @@ -70,8 +70,30 @@ class ExperienceGetService( return GetExperience.BookmarkResponse(bookmarkExperienceDetails) } + @Transactional(readOnly = true) + fun getBookmarkExperienceBySearch(jobDescriptionId: UUID, search: String): GetExperience.BookmarkResponse { + val currentUserId = getAuthenticationPrincipal() + + val experiencesIds = experienceReader.readByTitleContains(search) + + experienceReader.readByContentsContains(currentUserId, search) + + tagReader.readIdsByNameContains(search) + + strongPointReader.readIdsByNameContains(search) + + val searchExperiences = experienceReader.readByIds(experiencesIds) + val bookmarkExperienceIds = bookMarkReader.readByExperienceIds(experiencesIds).map { it.experienceId } + + val bookmarkExperienceDetails = searchExperiences.map { + when { + it.id in bookmarkExperienceIds -> createBookmarkExperienceDetailResponse(it, BookmarkStatus.ON) + else -> createBookmarkExperienceDetailResponse(it, BookmarkStatus.OFF) + } + } + + return GetExperience.BookmarkResponse(bookmarkExperienceDetails) + } + private fun createExperienceDetailResponse(experience: Experience): GetExperience.DetailExperience { - val detailExperienceContents = convertDetailExperienceContent(experience.contents) + val detailExperienceContents = convertExperienceContent(experience.contents) val strongPointDetails = convertStrongPoints(experience.strongPoints) val detailParentTag = convertParentTag(experience.parentTagId) val detailChildTag = convertChildTag(experience.childTagId) @@ -89,7 +111,7 @@ class ExperienceGetService( } private fun createBookmarkExperienceDetailResponse(experience: Experience, bookmarkStatus: BookmarkStatus): GetExperience.BookmarkDetailExperience { - val detailExperienceContents = convertDetailExperienceContent(experience.contents) + val detailExperienceContents = convertExperienceContent(experience.contents) val strongPointDetails = convertStrongPoints(experience.strongPoints) val detailParentTag = convertParentTag(experience.parentTagId) val detailChildTag = convertChildTag(experience.childTagId) @@ -123,7 +145,7 @@ class ExperienceGetService( ) } - private fun convertDetailExperienceContent(contents: List) = + private fun convertExperienceContent(contents: List) = contents.map { GetExperience.DetailExperienceContent( it.question, it.answer @@ -139,8 +161,4 @@ class ExperienceGetService( ) } } - - fun getBookmarkExperienceBySearch(search: String): GetExperience.BookmarkResponse { - return GetExperience.BookmarkResponse(emptyList()) - } -} +} diff --git a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/presentation/ExperienceController.kt b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/presentation/ExperienceController.kt index fa6898f6..b76fc429 100644 --- a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/presentation/ExperienceController.kt +++ b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/presentation/ExperienceController.kt @@ -25,7 +25,7 @@ class ExperienceController( ) : GetExperience.BookmarkResponse = when (search) { null -> experienceGetService.getAllBookmarkExperiences(jobDescriptionId) - else -> experienceGetService.getBookmarkExperienceBySearch(search) + else -> experienceGetService.getBookmarkExperienceBySearch(jobDescriptionId, search) } @GetMapping(ExperienceApi.BASE_URL) From bd224669d782a7ef301d9477f93f99c3dcf83318 Mon Sep 17 00:00:00 2001 From: whereami0404 Date: Tue, 21 May 2024 21:02:14 +0900 Subject: [PATCH 15/23] =?UTF-8?q?feat:=20=EB=B6=81=EB=A7=88=ED=81=AC=20?= =?UTF-8?q?=EA=B2=BD=ED=97=98=20id=20=EB=B0=B0=EC=97=B4=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84(#115)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/bookmark/repository/BookmarkRepository.kt | 3 +-- .../domain/bookmark/service/BookmarkReader.kt | 2 +- .../persistence/bookmark/BookmarkRepositoryImpl.java | 9 +++++++-- .../bookmark/jpa/repository/BookmarkJpaRepository.java | 7 +++++++ 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/bookmark/repository/BookmarkRepository.kt b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/bookmark/repository/BookmarkRepository.kt index 1f51bb9c..c258b238 100644 --- a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/bookmark/repository/BookmarkRepository.kt +++ b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/bookmark/repository/BookmarkRepository.kt @@ -7,8 +7,7 @@ import java.util.* interface BookmarkRepository { fun findById(jobDescriptionId : UUID, experienceId : UUID) : Bookmark? - fun save(bookmark: Bookmark) fun findByStatusAndJobDescriptionId(jobDescriptionId: UUID, status: BookmarkStatus): List - fun findByExperienceIds(): List + fun findByExperienceIds(experiences: List): List } diff --git a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/bookmark/service/BookmarkReader.kt b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/bookmark/service/BookmarkReader.kt index e5129d3c..15ece4bc 100644 --- a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/bookmark/service/BookmarkReader.kt +++ b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/bookmark/service/BookmarkReader.kt @@ -20,6 +20,6 @@ class BookmarkReader( } fun readByExperienceIds(experiencesIds: List) : List{ - return bookmarkRepository.findByExperienceIds() + return bookmarkRepository.findByExperienceIds(experiencesIds) } } diff --git a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/bookmark/BookmarkRepositoryImpl.java b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/bookmark/BookmarkRepositoryImpl.java index cacbb10d..47e6c8df 100644 --- a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/bookmark/BookmarkRepositoryImpl.java +++ b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/bookmark/BookmarkRepositoryImpl.java @@ -6,7 +6,6 @@ import com.bamyanggang.persistence.bookmark.jpa.entity.BookmarkJpaEntity; import com.bamyanggang.persistence.bookmark.jpa.repository.BookmarkJpaRepository; import com.bamyanggang.persistence.bookmark.mapper.BookmarkMapper; -import com.bamyanggang.persistence.experience.mapper.ExperienceMapper; import java.util.List; import java.util.UUID; import lombok.RequiredArgsConstructor; @@ -17,7 +16,6 @@ public class BookmarkRepositoryImpl implements BookmarkRepository { private final BookmarkJpaRepository bookmarkJpaRepository; private final BookmarkMapper bookmarkMapper; - private final ExperienceMapper experienceMapper; @Override public Bookmark findById(UUID jobDescriptionId, UUID experienceId) { @@ -39,4 +37,11 @@ public List findByStatusAndJobDescriptionId(UUID jobDescriptionId, Boo return bookmarkJpaEntities.stream().map(bookmarkMapper::toDomainEntity).toList(); } + + @Override + public List findByExperienceIds(List experienceIds) { + List bookmarkJpaEntities = bookmarkJpaRepository.findByExperienceIds(experienceIds); + + return bookmarkJpaEntities.stream().map(bookmarkMapper::toDomainEntity).toList(); + } } diff --git a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/bookmark/jpa/repository/BookmarkJpaRepository.java b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/bookmark/jpa/repository/BookmarkJpaRepository.java index 9ec67a0e..dbc0e0ee 100644 --- a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/bookmark/jpa/repository/BookmarkJpaRepository.java +++ b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/bookmark/jpa/repository/BookmarkJpaRepository.java @@ -6,9 +6,16 @@ import java.util.Optional; import java.util.UUID; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; public interface BookmarkJpaRepository extends JpaRepository { Optional findByJobDescriptionIdAndExperienceId(UUID jobDescriptionId, UUID experienceId); List findByBookmarkStatusAndJobDescriptionId(BookmarkStatus status, UUID jobDescriptionId); + + @Modifying + @Query("select bm from BookmarkJpaEntity bm where bm.experienceId in :experienceIds") + List findByExperienceIds(@Param("experienceIds") List experienceIds); } From 6b247650595817bae2dfa45ddef8245f6e0b3712 Mon Sep 17 00:00:00 2001 From: whereami0404 Date: Tue, 21 May 2024 23:29:41 +0900 Subject: [PATCH 16/23] =?UTF-8?q?feat:=20=EB=B6=81=EB=A7=88=ED=81=AC=20?= =?UTF-8?q?=EC=83=81=ED=83=9C=20Boolean=20=EA=B0=92=20=EC=A0=9C=EA=B1=B0(#?= =?UTF-8?q?115)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/dto/GetExperience.kt | 3 +- .../service/ExperienceGetService.kt | 3 +- .../presentation/ExperienceController.kt | 2 +- .../presentation/ExperienceControllerTest.kt | 85 +++++++++++++++++++ .../domain/bookmark/enums/BookmarkStatus.kt | 6 +- .../jpa/repository/BookmarkJpaRepository.java | 5 +- 6 files changed, 97 insertions(+), 7 deletions(-) diff --git a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/application/dto/GetExperience.kt b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/application/dto/GetExperience.kt index 8ce97b26..833ec77c 100644 --- a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/application/dto/GetExperience.kt +++ b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/application/dto/GetExperience.kt @@ -1,5 +1,6 @@ package com.bamyanggang.apimodule.domain.experience.application.dto +import com.bamyanggang.domainmodule.domain.bookmark.enums.BookmarkStatus import java.time.LocalDateTime import java.util.* @@ -32,7 +33,7 @@ class GetExperience { val contents: List, val startedAt: LocalDateTime, val endedAt: LocalDateTime, - val bookmarked: Boolean, + val bookmarked: BookmarkStatus, ) diff --git a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/application/service/ExperienceGetService.kt b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/application/service/ExperienceGetService.kt index 29c74c8e..3c41efa3 100644 --- a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/application/service/ExperienceGetService.kt +++ b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/application/service/ExperienceGetService.kt @@ -79,6 +79,7 @@ class ExperienceGetService( tagReader.readIdsByNameContains(search) + strongPointReader.readIdsByNameContains(search) + println(experiencesIds.filter { }) val searchExperiences = experienceReader.readByIds(experiencesIds) val bookmarkExperienceIds = bookMarkReader.readByExperienceIds(experiencesIds).map { it.experienceId } @@ -125,7 +126,7 @@ class ExperienceGetService( contents = detailExperienceContents, startedAt = experience.startedAt, endedAt = experience.endedAt, - bookmarked = bookmarkStatus.boolStatus + bookmarked = bookmarkStatus ) } diff --git a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/presentation/ExperienceController.kt b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/presentation/ExperienceController.kt index b76fc429..c1e64225 100644 --- a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/presentation/ExperienceController.kt +++ b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/presentation/ExperienceController.kt @@ -25,7 +25,7 @@ class ExperienceController( ) : GetExperience.BookmarkResponse = when (search) { null -> experienceGetService.getAllBookmarkExperiences(jobDescriptionId) - else -> experienceGetService.getBookmarkExperienceBySearch(jobDescriptionId, search) + else -> experienceGetService.getBookmarkExperienceBySearch(jobDescriptionId, search.trim()) } @GetMapping(ExperienceApi.BASE_URL) diff --git a/Api-Module/src/test/kotlin/com/bamyanggang/apimodule/domain/experience/presentation/ExperienceControllerTest.kt b/Api-Module/src/test/kotlin/com/bamyanggang/apimodule/domain/experience/presentation/ExperienceControllerTest.kt index 0d66d9b5..d95c9bd0 100644 --- a/Api-Module/src/test/kotlin/com/bamyanggang/apimodule/domain/experience/presentation/ExperienceControllerTest.kt +++ b/Api-Module/src/test/kotlin/com/bamyanggang/apimodule/domain/experience/presentation/ExperienceControllerTest.kt @@ -435,6 +435,91 @@ class ExperienceControllerTest : BaseRestDocsTest() { ) } +// @Test +// @DisplayName("북마크 경험을 전체 조회한다.") +// fun getAllBookmarkExperienceYearTest() { +// val content1 = GetExperience.DetailExperienceContent("질문1", "답변1") +// val content2 = GetExperience.DetailExperienceContent("질문2", "답변2") +// val strongPoint1 = GetExperience.DetailStrongPoint(UUID.randomUUID(), "역량 키워드 이름 1") +// val strongPoint2 = GetExperience.DetailStrongPoint(UUID.randomUUID(), "역량 키워드 이름 2") +// val parentTag = GetExperience.DetailTag(UUID.randomUUID(), "상위 태그 이름") +// val childTag = GetExperience.DetailTag(UUID.randomUUID(), "하위 태그 이름") +// val startedAt = LocalDateTime.now() +// val endedAt = LocalDateTime.now().plusDays(1) +// +// val contentResponse = arrayListOf(content1, content2) +// val strongPointResponse = arrayListOf(strongPoint1, strongPoint2) +// +// val experienceResponses = +// GetExperience.BookmarkResponse( +// arrayListOf( +// GetExperience.BookmarkDetailExperience( +// id = UUID.randomUUID(), +// title = "경험 제목1 ", +// contents = contentResponse, +// strongPoints = strongPointResponse, +// parentTag = parentTag, +// childTag = childTag, +// startedAt = startedAt, +// endedAt = endedAt, +// bookmarked = BookmarkStatus.ON +// ), +// GetExperience.BookmarkDetailExperience( +// id = UUID.randomUUID(), +// title = "경험 제목 2", +// contents = contentResponse, +// strongPoints = strongPointResponse, +// parentTag = parentTag, +// childTag = childTag, +// startedAt = startedAt.minusYears(1), +// endedAt = endedAt, +// bookmarked = BookmarkStatus.OFF +// ) +// ) +// ) +// +// val year = 2024 +// given(experienceGetService.getAllBookmarkExperiences(UUID.randomUUID())).willReturn(experienceResponses) +// +// //given +// val request = RestDocumentationRequestBuilders.get(ExperienceApi.BOOKMARK_EXPERIENCE_URL, UUID.randomUUID()) +// .header("Authorization", "Bearer Access Token") +// .contentType(MediaType.APPLICATION_JSON_VALUE) +// .queryParam("year", year.toString()) +// .queryParam("parent-tag", parentTag.id.toString()) +// +// //when +// val result = mockMvc.perform(request) +// +// //then +// result.andExpect(status().isOk).andDo( +// resultHandler.document( +// requestHeaders( +// headerWithName("Authorization").description("엑세스 토큰") +// ), +// responseFields( +// fieldWithPath("experiences[].id").description("경험 id"), +// fieldWithPath("experiences[].title").description("경험 제목"), +// fieldWithPath("experiences[].contents").description("경험 내용"), +// fieldWithPath("experiences[].contents[].question").description("경험 내용 질문"), +// fieldWithPath("experiences[].contents[].answer").description("경험 내용 답변"), +// fieldWithPath("experiences[].strongPoints").description("관련된 역량 키워드"), +// fieldWithPath("experiences[].strongPoints[].id").description("역량 키워드 id"), +// fieldWithPath("experiences[].strongPoints[].name").description("역량 키워드 이름"), +// fieldWithPath("experiences[].parentTag").description("속한 상위 태그"), +// fieldWithPath("experiences[].parentTag.id").description("상위 태그 id"), +// fieldWithPath("experiences[].parentTag.name").description("상위 태그 이름"), +// fieldWithPath("experiences[].childTag").description("속한 하위 태그"), +// fieldWithPath("experiences[].childTag.id").description("하위 태그 id"), +// fieldWithPath("experiences[].childTag.name").description("하위 태그 이름"), +// fieldWithPath("experiences[].startedAt").description("경험 시작 날짜"), +// fieldWithPath("experiences[].endedAt").description("경험 종료 날짜"), +// fieldWithPath("experiences[].bookmarked").description("북마크 여부"), +// ), +// ) +// ) +// } + @Test @DisplayName("경험 목록을 하위 태그 id를 기준으로 조회한다.") fun getExperienceYearAndChildTagTest() { diff --git a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/bookmark/enums/BookmarkStatus.kt b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/bookmark/enums/BookmarkStatus.kt index 62147d34..93f1b305 100644 --- a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/bookmark/enums/BookmarkStatus.kt +++ b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/bookmark/enums/BookmarkStatus.kt @@ -1,6 +1,6 @@ package com.bamyanggang.domainmodule.domain.bookmark.enums -enum class BookmarkStatus(val boolStatus: Boolean) { - ON(true), - OFF(false) +enum class BookmarkStatus { + ON, + OFF } diff --git a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/bookmark/jpa/repository/BookmarkJpaRepository.java b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/bookmark/jpa/repository/BookmarkJpaRepository.java index dbc0e0ee..e8642f7e 100644 --- a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/bookmark/jpa/repository/BookmarkJpaRepository.java +++ b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/bookmark/jpa/repository/BookmarkJpaRepository.java @@ -13,7 +13,10 @@ public interface BookmarkJpaRepository extends JpaRepository { Optional findByJobDescriptionIdAndExperienceId(UUID jobDescriptionId, UUID experienceId); - List findByBookmarkStatusAndJobDescriptionId(BookmarkStatus status, UUID jobDescriptionId); + + @Query("select bm from BookmarkJpaEntity bm where bm.bookmarkStatus = :status and bm.jobDescriptionId = :jobDescriptionId") + List findByBookmarkStatusAndJobDescriptionId(@Param("status") BookmarkStatus status, + @Param("jobDescriptionId") UUID jobDescriptionId); @Modifying @Query("select bm from BookmarkJpaEntity bm where bm.experienceId in :experienceIds") From 96aafc92e279538d5e838aa253cfd90272fa633b Mon Sep 17 00:00:00 2001 From: whereami0404 Date: Tue, 21 May 2024 23:37:30 +0900 Subject: [PATCH 17/23] =?UTF-8?q?chore:=20=EA=B9=83=20=EC=B6=A9=EB=8F=8C?= =?UTF-8?q?=20=EB=AC=B8=EC=A0=9C=20=ED=95=B4=EA=B2=B0(#115)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../experience/application/service/ExperienceGetService.kt | 1 - .../domain/experience/service/ExperienceReader.kt | 5 +++-- .../persistence/experience/ExperienceRepositoryImpl.java | 1 + .../com/bamyanggang/persistence/tag/TagRepositoryImpl.java | 1 + .../persistence/tag/jpa/repository/TagJpaRepository.java | 1 - 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/application/service/ExperienceGetService.kt b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/application/service/ExperienceGetService.kt index 73d56384..d17ea50f 100644 --- a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/application/service/ExperienceGetService.kt +++ b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/experience/application/service/ExperienceGetService.kt @@ -100,7 +100,6 @@ class ExperienceGetService( tagReader.readIdsByNameContains(search) + strongPointReader.readIdsByNameContains(search) - println(experiencesIds.filter { }) val searchExperiences = experienceReader.readByIds(experiencesIds) val bookmarkExperienceIds = bookMarkReader.readByExperienceIds(experiencesIds).map { it.experienceId } diff --git a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/service/ExperienceReader.kt b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/service/ExperienceReader.kt index 3811a6c0..df0972ab 100644 --- a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/service/ExperienceReader.kt +++ b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/service/ExperienceReader.kt @@ -60,8 +60,9 @@ class ExperienceReader( return experiences.filter { it.contents.map { content -> content.question.contains(search) || content.answer.contains(search) - }.contains(true) }.map { it.id } - + }.contains(true) + }.map { it.id } + } fun readByYear(year: Int): List { return experienceRepository.findByYear(year) } diff --git a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/ExperienceRepositoryImpl.java b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/ExperienceRepositoryImpl.java index f6ed83c8..7fceeab4 100644 --- a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/ExperienceRepositoryImpl.java +++ b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/ExperienceRepositoryImpl.java @@ -84,6 +84,7 @@ public List findByIds(List experienceIds) { public List findByTitleContains(String search) { List experienceJpaEntities = experienceJpaRepository.findByTitleContaining(search); + return experienceJpaEntities.stream().map(experienceMapper::toExperienceDomainEntity).toList(); } public List findByUserIdAndParentTagId(UUID userId, UUID parentTagId) { 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 c4ca1aea..8a28401a 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 @@ -60,6 +60,7 @@ public Tag findById(UUID tagId) { @Override public List findByNameContains(String search) { List tagJpaEntities = tagJpaRepository.findByNameContaining(search); + return tagJpaEntities.stream().map(tagMapper::toDomainEntity).toList(); } public List findAllChildTagsByParentTagId(UUID parentTagId) { 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 3cffd075..121a4b71 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,6 +9,5 @@ public interface TagJpaRepository extends JpaRepository { List findAllByUserIdAndParentTagIdIsNull(UUID userId); List findAllByUserIdAndParentTagId(UUID parentTagId, UUID parentId); List findByNameContaining(String search); - List findAllByUserIdAndParentTagId(UUID userId, UUID parentId); List findAllByParentTagId(UUID parentTagId); } From 544058f36aead6f5d7b3155320738597baf4bb01 Mon Sep 17 00:00:00 2001 From: whereami0404 Date: Wed, 22 May 2024 00:19:15 +0900 Subject: [PATCH 18/23] =?UTF-8?q?fix:=20=EC=97=94=ED=8B=B0=ED=8B=B0=20?= =?UTF-8?q?=EC=98=A4=ED=83=80=20=EC=88=98=EC=A0=95(#115)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../experience/jpa/repository/ExperienceJpaRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/jpa/repository/ExperienceJpaRepository.java b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/jpa/repository/ExperienceJpaRepository.java index cf610970..857349b2 100644 --- a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/jpa/repository/ExperienceJpaRepository.java +++ b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/jpa/repository/ExperienceJpaRepository.java @@ -17,7 +17,7 @@ public interface ExperienceJpaRepository extends JpaRepository findByTitleContaining(String title); @Modifying - @Query("select e from ExperienceTagJpaEntity e where e.experienceId in :experienceIds") + @Query("select e from ExperienceJpaEntity e where e.experienceId in :experienceIds") List findByIds(@Param("experienceIds") List experienceIds); List findByCreatedAtBetween(LocalDateTime startYear, LocalDateTime endYear); From f63d98ea7777dada56a6708dce36c11327b9555c Mon Sep 17 00:00:00 2001 From: whereami2048 Date: Wed, 22 May 2024 00:21:10 +0900 Subject: [PATCH 19/23] =?UTF-8?q?fix:=20@Modifying=20=EC=A0=9C=EA=B1=B0(#1?= =?UTF-8?q?15)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../experience/jpa/repository/ExperienceJpaRepository.java | 2 -- .../jpa/repository/JobDescriptionJpaRepository.java | 3 --- .../strongpoint/jpa/repository/StrongPointJpaRepository.java | 2 -- 3 files changed, 7 deletions(-) diff --git a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/jpa/repository/ExperienceJpaRepository.java b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/jpa/repository/ExperienceJpaRepository.java index 857349b2..eb937037 100644 --- a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/jpa/repository/ExperienceJpaRepository.java +++ b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/jpa/repository/ExperienceJpaRepository.java @@ -5,7 +5,6 @@ import java.util.List; import java.util.UUID; import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; @@ -16,7 +15,6 @@ public interface ExperienceJpaRepository extends JpaRepository findByChildTagIdAndCreatedAtBetweenOrderByCreatedAtDesc(UUID childTagId, LocalDateTime startYear, LocalDateTime endYear); List findByTitleContaining(String title); - @Modifying @Query("select e from ExperienceJpaEntity e where e.experienceId in :experienceIds") List findByIds(@Param("experienceIds") List experienceIds); diff --git a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/jobDescription/jpa/repository/JobDescriptionJpaRepository.java b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/jobDescription/jpa/repository/JobDescriptionJpaRepository.java index 55cc7fc7..4f4d74be 100644 --- a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/jobDescription/jpa/repository/JobDescriptionJpaRepository.java +++ b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/jobDescription/jpa/repository/JobDescriptionJpaRepository.java @@ -2,12 +2,10 @@ import com.bamyanggang.domainmodule.domain.jobDescription.enums.WriteStatus; import com.bamyanggang.persistence.jobDescription.jpa.entity.JobDescriptionJpaEntity; -import java.time.LocalDateTime; import java.util.UUID; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; @@ -16,7 +14,6 @@ public interface JobDescriptionJpaRepository extends JpaRepository findAllByUserIdAndWriteStatus(@Param("userId") UUID userId, @Param("writeStatus") WriteStatus writeStatus, @Param("date") Pageable pageable); - @Modifying @Query("UPDATE JobDescriptionJpaEntity j SET j.writeStatus = 'CLOSED' WHERE j.endedAt < CURRENT_TIMESTAMP") void changeWriteStatus(); diff --git a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/strongpoint/jpa/repository/StrongPointJpaRepository.java b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/strongpoint/jpa/repository/StrongPointJpaRepository.java index 21c7b8a3..6e94df97 100644 --- a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/strongpoint/jpa/repository/StrongPointJpaRepository.java +++ b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/strongpoint/jpa/repository/StrongPointJpaRepository.java @@ -4,14 +4,12 @@ import java.util.List; import java.util.UUID; import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; public interface StrongPointJpaRepository extends JpaRepository { List findAllByUserId(UUID userId); - @Modifying @Query("select spe from StrongPointJpaEntity spe where spe.strongPointId in :strongPoints") List findByIds(@Param("strongPoints") List strongPointIds); From 7581227d9b6b40c30d160734bb8a27962dbb7a99 Mon Sep 17 00:00:00 2001 From: whereami0404 Date: Wed, 22 May 2024 00:38:50 +0900 Subject: [PATCH 20/23] =?UTF-8?q?fix:=20=ED=95=98=EC=9C=84=20=ED=83=9C?= =?UTF-8?q?=EA=B7=B8=20=EA=B4=80=EB=A0=A8=20=EC=A1=B0=ED=9A=8C=20=EC=97=B0?= =?UTF-8?q?=EB=8F=84=20=EA=B8=B0=EC=A4=80=20=ED=99=9C=EB=8F=99=20=EC=8B=9C?= =?UTF-8?q?=EC=9E=91=EC=9D=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD(#115)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../persistence/experience/ExperienceRepositoryImpl.java | 2 +- .../experience/jpa/repository/ExperienceJpaRepository.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/ExperienceRepositoryImpl.java b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/ExperienceRepositoryImpl.java index 7fceeab4..8469d31e 100644 --- a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/ExperienceRepositoryImpl.java +++ b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/ExperienceRepositoryImpl.java @@ -71,7 +71,7 @@ public List findByYearAndChildTagId(int year, UUID childTagId) { LocalDateTime endYear = LocalDateTime.of(year, 12, 31, 23, 59); List experienceJpaEntities = experienceJpaRepository - .findByChildTagIdAndCreatedAtBetweenOrderByCreatedAtDesc(childTagId, startYear, endYear); + .findByChildTagIdAndStartedAtBetweenOrderByStartedAtDesc(childTagId, startYear, endYear); return experienceJpaEntities.stream().map(experienceMapper::toExperienceDomainEntity).toList(); } diff --git a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/jpa/repository/ExperienceJpaRepository.java b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/jpa/repository/ExperienceJpaRepository.java index eb937037..44801cd6 100644 --- a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/jpa/repository/ExperienceJpaRepository.java +++ b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/jpa/repository/ExperienceJpaRepository.java @@ -12,7 +12,7 @@ public interface ExperienceJpaRepository extends JpaRepository findAllByUserId(UUID userId); List findByUserIdAndCreatedAtBetweenOrderByCreatedAtDesc(UUID userId, LocalDateTime startYear, LocalDateTime endYear); List findByParentTagIdAndCreatedAtBetweenOrderByCreatedAtDesc(UUID parentTagId, LocalDateTime startYear, LocalDateTime endYear); - List findByChildTagIdAndCreatedAtBetweenOrderByCreatedAtDesc(UUID childTagId, LocalDateTime startYear, LocalDateTime endYear); + List findByChildTagIdAndStartedAtBetweenOrderByStartedAtDesc(UUID childTagId, LocalDateTime startYear, LocalDateTime endYear); List findByTitleContaining(String title); @Query("select e from ExperienceJpaEntity e where e.experienceId in :experienceIds") From 1ce8466f3f9c3290b72c1954608a4efc52caec9c Mon Sep 17 00:00:00 2001 From: whereami0404 Date: Wed, 22 May 2024 01:14:10 +0900 Subject: [PATCH 21/23] =?UTF-8?q?feat:=20=ED=83=9C=EA=B7=B8=EB=A1=9C=20?= =?UTF-8?q?=EA=B2=BD=ED=97=98=20=EC=A1=B0=ED=9A=8C=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84(#115)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/experience/repository/ExperienceRepository.kt | 1 + .../domain/experience/service/ExperienceReader.kt | 4 ++++ .../persistence/experience/ExperienceRepositoryImpl.java | 6 ++++++ .../experience/jpa/repository/ExperienceJpaRepository.java | 2 ++ 4 files changed, 13 insertions(+) diff --git a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/repository/ExperienceRepository.kt b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/repository/ExperienceRepository.kt index ff98106c..42a3569c 100644 --- a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/repository/ExperienceRepository.kt +++ b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/repository/ExperienceRepository.kt @@ -16,4 +16,5 @@ interface ExperienceRepository { fun findByUserIdAndParentTagId(userId: UUID, parentTagId: UUID): List fun findByUserIdAndParentTagIdAndYearDesc(year: Int, parentTagId: UUID, userId: UUID): List fun findByYear(year: Int): List + fun findByChildTagId(childTag: UUID) : List } diff --git a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/service/ExperienceReader.kt b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/service/ExperienceReader.kt index df0972ab..a06364aa 100644 --- a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/service/ExperienceReader.kt +++ b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/service/ExperienceReader.kt @@ -66,4 +66,8 @@ class ExperienceReader( fun readByYear(year: Int): List { return experienceRepository.findByYear(year) } + + fun readByChildTag(childTag: UUID): List { + return experienceRepository.findByChildTagId(childTag) + } } diff --git a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/ExperienceRepositoryImpl.java b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/ExperienceRepositoryImpl.java index 8469d31e..97a89c69 100644 --- a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/ExperienceRepositoryImpl.java +++ b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/ExperienceRepositoryImpl.java @@ -114,4 +114,10 @@ public List findByYear(int year) { return experienceJpaEntities.stream().map(experienceMapper::toExperienceDomainEntity).toList(); } + + @Override + public List findByChildTagId(UUID childTag) { + List experienceJpaEntities = experienceJpaRepository.findByChildTagId(childTag); + return experienceJpaEntities.stream().map(experienceMapper::toExperienceDomainEntity).toList(); + } } diff --git a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/jpa/repository/ExperienceJpaRepository.java b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/jpa/repository/ExperienceJpaRepository.java index 44801cd6..0619ba68 100644 --- a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/jpa/repository/ExperienceJpaRepository.java +++ b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/jpa/repository/ExperienceJpaRepository.java @@ -22,4 +22,6 @@ public interface ExperienceJpaRepository extends JpaRepository findByUserIdAndParentTagId(UUID userId, UUID parentTagId); List findByUserIdAndParentTagIdAndCreatedAtBetweenOrderByCreatedAtDesc( UUID userId, UUID parentTagId, LocalDateTime startYear, LocalDateTime endYear); + + List findByChildTagId(UUID childTag); } From 9f7c0221d5655a4d8e05df62490b73e2c8bc3621 Mon Sep 17 00:00:00 2001 From: whereami0404 Date: Wed, 22 May 2024 01:14:24 +0900 Subject: [PATCH 22/23] =?UTF-8?q?feat:=20=ED=83=9C=EA=B7=B8=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=20=EC=8B=9C=20=EA=B4=80=EB=A0=A8=20=EA=B2=BD=ED=97=98?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= =?UTF-8?q?(#115)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/service/TagDeleteService.kt | 20 ++++++++++++++++++- .../domain/tag/presentation/TagController.kt | 3 ++- .../domain/tag/service/TagRemover.kt | 2 +- .../persistence/tag/TagRepositoryImpl.java | 1 + 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/tag/application/service/TagDeleteService.kt b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/tag/application/service/TagDeleteService.kt index aa7839c8..f99f91de 100644 --- a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/tag/application/service/TagDeleteService.kt +++ b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/tag/application/service/TagDeleteService.kt @@ -1,5 +1,9 @@ package com.bamyanggang.apimodule.domain.tag.application.service +import com.bamyanggang.apimodule.common.getAuthenticationPrincipal +import com.bamyanggang.domainmodule.domain.experience.service.ExperienceReader +import com.bamyanggang.domainmodule.domain.experience.service.ExperienceRemover +import com.bamyanggang.domainmodule.domain.tag.service.TagReader import com.bamyanggang.domainmodule.domain.tag.service.TagRemover import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional @@ -7,10 +11,24 @@ import java.util.* @Service class TagDeleteService( - private val tagRemover: TagRemover + private val tagRemover: TagRemover, + private val tagReader: TagReader, + private val experienceReader: ExperienceReader, + private val experienceRemover: ExperienceRemover ) { @Transactional fun deleteTag(tagId: UUID) { + val deleteTag = tagReader.readById(tagId) + + if (deleteTag.parentTagId == null) { + experienceReader.readByUserIdAndParentTagId(getAuthenticationPrincipal(), deleteTag.id) + .forEach { experienceRemover.remove(it.id) } + }else { + experienceReader.readByChildTag(tagId).forEach { + experienceRemover.remove(it.id) + } + } + tagRemover.removeTag(tagId) } } diff --git a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/tag/presentation/TagController.kt b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/tag/presentation/TagController.kt index 127e42a5..33126e48 100644 --- a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/tag/presentation/TagController.kt +++ b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/tag/presentation/TagController.kt @@ -69,7 +69,8 @@ class TagController( } @DeleteMapping(TagApi.TAG_PATH_VARIABLE_URL) - fun deleteTag( @PathVariable("tagId", required = false) tagId: UUID) { + fun deleteTag( @PathVariable("tagId") tagId: UUID) { + tagDeleteService.deleteTag(tagId) } } diff --git a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/tag/service/TagRemover.kt b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/tag/service/TagRemover.kt index 367b436f..ea91863c 100644 --- a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/tag/service/TagRemover.kt +++ b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/tag/service/TagRemover.kt @@ -10,7 +10,7 @@ class TagRemover( private val tagRepository: TagRepository ) { fun removeTag(tagId: UUID) { - if (tagRepository.isExistById(tagId)) { + if (!tagRepository.isExistById(tagId)) { throw TagException.NotFoundTag() } tagRepository.deleteByTagId(tagId) 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 8a28401a..d6b1508d 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 @@ -42,6 +42,7 @@ public void deleteByTagId(UUID tagId) { @Override public boolean isExistById(UUID tagId) { + System.out.println(tagJpaRepository.existsById(tagId)); return tagJpaRepository.existsById(tagId); } From 8a4c29d0214c153cbf17ddc6c28eed764edec69d Mon Sep 17 00:00:00 2001 From: whereami0404 Date: Wed, 22 May 2024 03:07:03 +0900 Subject: [PATCH 23/23] =?UTF-8?q?fix:=20@Modifying=20=EB=88=84=EB=9D=BD=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80(#115)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jpa/repository/JobDescriptionJpaRepository.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/jobDescription/jpa/repository/JobDescriptionJpaRepository.java b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/jobDescription/jpa/repository/JobDescriptionJpaRepository.java index 4f4d74be..dafa712c 100644 --- a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/jobDescription/jpa/repository/JobDescriptionJpaRepository.java +++ b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/jobDescription/jpa/repository/JobDescriptionJpaRepository.java @@ -6,6 +6,7 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; @@ -14,6 +15,7 @@ public interface JobDescriptionJpaRepository extends JpaRepository findAllByUserIdAndWriteStatus(@Param("userId") UUID userId, @Param("writeStatus") WriteStatus writeStatus, @Param("date") Pageable pageable); + @Modifying @Query("UPDATE JobDescriptionJpaEntity j SET j.writeStatus = 'CLOSED' WHERE j.endedAt < CURRENT_TIMESTAMP") void changeWriteStatus();