Skip to content

Commit

Permalink
Merge pull request #103 from KUSITMS-29th-TEAM-B/fix/flight-102
Browse files Browse the repository at this point in the history
경험 상세 조회 API 응답 값 변경
  • Loading branch information
whereami2048 authored May 20, 2024
2 parents 8073abf + 2b736a3 commit ef0868b
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package com.bamyanggang.apimodule.domain.experience.application.dto

import com.bamyanggang.apimodule.domain.strongpoint.application.dto.GetStrongPoint.DetailStrongPoint
import java.time.LocalDateTime
import java.util.*

class DetailExperience {
data class Response(
val id: UUID,
val title: String,
val parentTagId: UUID,
val childTagId: UUID,
val parentTag: DetailTag,
val childTag: DetailTag,
val strongPoints: List<DetailStrongPoint>,
val contents: List<DetailExperienceContent>,
val startedAt: LocalDateTime,
Expand All @@ -20,4 +19,14 @@ class DetailExperience {
val question: String,
val answer: String,
)

data class DetailTag(
val id: UUID,
val name: String,
)

data class DetailStrongPoint(
val id: UUID,
val name: String,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ package com.bamyanggang.apimodule.domain.experience.application.service
import com.bamyanggang.apimodule.common.getAuthenticationPrincipal
import com.bamyanggang.apimodule.domain.experience.application.dto.DetailExperience
import com.bamyanggang.apimodule.domain.experience.application.dto.ExperienceYear
import com.bamyanggang.apimodule.domain.strongpoint.application.dto.GetStrongPoint
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 java.util.*

@Service
class ExperienceGetService(
private val experienceReader: ExperienceReader,
private val strongPointReader: StrongPointReader,
private val tagReader: TagReader,
) {
fun getExperienceDetailById(experienceId: UUID) : DetailExperience.Response {
val oneExperience = experienceReader.readExperience(experienceId)
Expand All @@ -24,9 +25,23 @@ class ExperienceGetService(
)
}

val strongPointIds = oneExperience.strongPoints.map { it.id }
val strongPointIds = oneExperience.strongPoints.map { it.strongPointId }
val strongPointDetails = strongPointReader.readByIds(strongPointIds).map {
GetStrongPoint.DetailStrongPoint(
DetailExperience.DetailStrongPoint(
it.id,
it.name
)
}

val detailParentTag = tagReader.readById(oneExperience.parentTagId).let {
DetailExperience.DetailTag(
it.id,
it.name
)
}

val detailChildTag = tagReader.readById(oneExperience.childTagId).let {
DetailExperience.DetailTag(
it.id,
it.name
)
Expand All @@ -36,8 +51,8 @@ class ExperienceGetService(
DetailExperience.Response(
id = it.id,
title = it.title,
parentTagId = it.parentTagId,
childTagId = it.childTagId,
parentTag = detailParentTag,
childTag = detailChildTag,
strongPoints = strongPointDetails,
contents = detailExperienceContents,
startedAt = it.startedAt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import java.util.*

class CreateStrongPoint {
data class Request(
val names: List<StrongPointName>,
val names: List<StrongPointName>
)

data class Response(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import com.bamyanggang.apimodule.domain.experience.application.service.Experienc
import com.bamyanggang.apimodule.domain.experience.application.service.ExperienceDeleteService
import com.bamyanggang.apimodule.domain.experience.application.service.ExperienceEditService
import com.bamyanggang.apimodule.domain.experience.application.service.ExperienceGetService
import com.bamyanggang.apimodule.domain.strongpoint.application.dto.GetStrongPoint.DetailStrongPoint
import com.bamyanggang.commonmodule.exception.ExceptionHandler
import com.bamyanggang.commonmodule.fixture.generateFixture
import org.junit.jupiter.api.DisplayName
Expand Down Expand Up @@ -301,13 +300,14 @@ class ExperienceControllerTest : BaseRestDocsTest() {
val contentResponse = arrayListOf(content1, content2)

val experienceId: UUID = UUID.randomUUID()

val experienceDetailResponse : DetailExperience.Response = generateFixture {
it.set("id", experienceId)
it.set("title", "제목")
it.set("contents", contentResponse)
it.set("strongPoints", generateFixture<List<DetailStrongPoint>>())
it.set("parentTagId", generateFixture<UUID>())
it.set("childTagId", generateFixture<UUID>())
it.set("strongPoints", generateFixture<List<DetailExperience.DetailStrongPoint>>())
it.set("parentTag", generateFixture<DetailExperience.DetailTag>())
it.set("childTag", generateFixture<DetailExperience.DetailTag>())
it.set("startedAt", generateFixture<LocalDateTime>())
it.set("endedAt", generateFixture<LocalDateTime>())
}
Expand Down Expand Up @@ -340,8 +340,12 @@ class ExperienceControllerTest : BaseRestDocsTest() {
fieldWithPath("strongPoints").description("관련된 역량 키워드"),
fieldWithPath("strongPoints[].id").description("역량 키워드 id"),
fieldWithPath("strongPoints[].name").description("역량 키워드 이름"),
fieldWithPath("parentTagId").description("속한 상위 태그"),
fieldWithPath("childTagId").description("속한 하위 태그"),
fieldWithPath("parentTag").description("속한 상위 태그"),
fieldWithPath("parentTag.id").description("상위 태그 id"),
fieldWithPath("parentTag.name").description("상위 태그 이름"),
fieldWithPath("childTag").description("속한 하위 태그"),
fieldWithPath("childTag.id").description("하위 태그 id"),
fieldWithPath("childTag.name").description("하위 태그 이름"),
fieldWithPath("startedAt").description("경험 시작 날짜"),
fieldWithPath("endedAt").description("경험 종료 날짜"),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,13 @@ class StrongPointControllerTest : BaseRestDocsTest() {
@Test
@DisplayName("역량 키워드 개수 제한보다 더 많은 키워드 등록 시도 시 예외를 반환한다.")
fun overCountLimitTest(){
val overCountLimitRequest: CreateStrongPoint.Request = generateFixture()
val overCountLimitRequest = CreateStrongPoint.Request(
arrayListOf(
CreateStrongPoint.StrongPointName("역량 키워드 이름 1"),
CreateStrongPoint.StrongPointName("역량 키워드 이름 2")
)
)


given(strongPointController.createStrongPoint(overCountLimitRequest)).willThrow(StrongPointException.OverCountLimit())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,5 @@ class StrongPointAppender(

strongPointRepository.saveAll(newStrongPoints)
return newStrongPoints

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class TagReader(
fun readById(tagId: UUID): Tag {
return tagRepository.findById(tagId)
}

fun readByIds(parentTagIds: List<UUID>): List<Tag> {
return tagRepository.findByParentTagIds(parentTagIds)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.bamyanggang.persistence.tag;

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;
Expand Down Expand Up @@ -53,7 +54,7 @@ public List<Tag> findByParentTagIds(List<UUID> parentTagIds) {

@Override
public Tag findById(UUID tagId) {
TagJpaEntity tagJpaEntity = tagJpaRepository.findById(tagId).orElseThrow(NotFound::new);
TagJpaEntity tagJpaEntity = tagJpaRepository.findById(tagId).orElseThrow(NotFoundTag::new);
return tagMapper.toDomainEntity(tagJpaEntity);
}
}

0 comments on commit ef0868b

Please sign in to comment.