-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from KUSITMS-29th-TEAM-B/feat/flight-39
feat: 경험 등록 API 구현(#39)
- Loading branch information
Showing
47 changed files
with
585 additions
and
96 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[[Experience-API]] | ||
== Experience-API | ||
|
||
[[CreateExperienceTest]] | ||
=== 경험 등록 API | ||
|
||
operation::ExperienceControllerTest/createExperienceTest/[snippets='http-request,request-headers,request-body,request-fields,http-response,response-body,response-fields'] | ||
|
||
[[CreateOverTitleLengthTest]] | ||
=== 제목 글자 수 제한(50자) 예외 | ||
|
||
operation::ExperienceControllerTest/createOverTitleLengthTest/[snippets='http-request,request-headers,request-body,request-fields,http-response,response-body,response-fields'] | ||
|
||
[[CreateOverStrongPointCountTest]] | ||
=== 역량 키워드 제한(5개) 초과 예외 | ||
|
||
operation::ExperienceControllerTest/createOverStrongPointCountTest/[snippets='http-request,request-headers,request-body,http-response,response-body,response-fields'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
23 changes: 23 additions & 0 deletions
23
...in/kotlin/com/bamyanggang/apimodule/domain/experience/application/dto/CreateExperience.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.bamyanggang.apimodule.domain.experience.application.dto | ||
|
||
import java.time.LocalDateTime | ||
import java.util.* | ||
|
||
class CreateExperience { | ||
data class Request( | ||
val title: String, | ||
val parentTagId: UUID, | ||
val childTagId: UUID, | ||
val strongPointIds: List<UUID>, | ||
val contents: List<ExperienceContentRequest>, | ||
val startedAt: LocalDateTime, | ||
val endedAt: LocalDateTime, | ||
) | ||
|
||
data class Response(val id: UUID) | ||
|
||
data class ExperienceContentRequest( | ||
val question: String, | ||
val answer: String, | ||
) | ||
} |
36 changes: 36 additions & 0 deletions
36
...om/bamyanggang/apimodule/domain/experience/application/service/ExperienceCreateService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.bamyanggang.apimodule.domain.experience.application.service | ||
|
||
import com.bamyanggang.apimodule.common.getAuthenticationPrincipal | ||
import com.bamyanggang.apimodule.domain.experience.application.dto.CreateExperience | ||
import com.bamyanggang.domainmodule.domain.experience.service.ExperienceAppender | ||
import com.bamyanggang.domainmodule.domain.experience.service.ExperienceContentAppender | ||
import org.springframework.stereotype.Service | ||
import org.springframework.transaction.annotation.Transactional | ||
|
||
@Service | ||
class ExperienceCreateService( | ||
val experienceAppender: ExperienceAppender, | ||
val experienceContentAppender: ExperienceContentAppender | ||
) { | ||
@Transactional | ||
fun createExperience(request: CreateExperience.Request):CreateExperience.Response { | ||
val currentUserId = getAuthenticationPrincipal() | ||
|
||
return request.contents.map { | ||
experienceContentAppender.appendExperienceContent(it.question, it.answer).id | ||
}.let { | ||
experienceAppender.appendExperience( | ||
title = request.title, | ||
userId = currentUserId, | ||
parentTagId = request.parentTagId, | ||
childTagId = request.childTagId, | ||
strongPointIds = request.strongPointIds, | ||
contentIds = it, | ||
startedAt = request.startedAt, | ||
endedAt = request.endedAt | ||
) | ||
}.let { | ||
CreateExperience.Response(it.id) | ||
} | ||
} | ||
} |
Empty file.
5 changes: 5 additions & 0 deletions
5
...src/main/kotlin/com/bamyanggang/apimodule/domain/experience/presentation/ExperienceApi.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.bamyanggang.apimodule.domain.experience.presentation | ||
|
||
object ExperienceApi { | ||
const val BASE_URL = "/api/experiences" | ||
} |
17 changes: 17 additions & 0 deletions
17
...n/kotlin/com/bamyanggang/apimodule/domain/experience/presentation/ExperienceController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.bamyanggang.apimodule.domain.experience.presentation | ||
|
||
import com.bamyanggang.apimodule.domain.experience.application.dto.CreateExperience | ||
import com.bamyanggang.apimodule.domain.experience.application.service.ExperienceCreateService | ||
import org.springframework.web.bind.annotation.PostMapping | ||
import org.springframework.web.bind.annotation.RequestBody | ||
import org.springframework.web.bind.annotation.RestController | ||
|
||
@RestController | ||
class ExperienceController( | ||
private val experienceCreateService: ExperienceCreateService | ||
) { | ||
@PostMapping(ExperienceApi.BASE_URL) | ||
fun createExperience(@RequestBody request: CreateExperience.Request): CreateExperience.Response { | ||
return experienceCreateService.createExperience(request) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.