-
Notifications
You must be signed in to change notification settings - Fork 0
feat: 회원 설문 도메인 및 API 구현 #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
c33a9c8
feat: 회원 설문 도메인, API 구현
gustj3104 dfebb43
패키지, 상품 API 구현 (#27)
sosow0212 7a189be
feat: 장소 도메인 및 기능 설계 (#24)
gustj3104 e0e645c
fix: 여러 장소를 저장하도록 수정
gustj3104 f5c6781
feat: 테스트 코드 추가
gustj3104 ae57e12
Merge branch 'develop' into feat/28
gustj3104 c64d3cd
feat: QueryService로 조회 로직 이전
gustj3104 9944d61
Merge branch 'develop' of https://github.com/DOKI-SERVICE/DOKI_BE int…
gustj3104 b1dc23e
fix: 디렉터리 구조 수정
gustj3104 7b73de2
fix: 옵션, 메서드명 수정
gustj3104 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
21 changes: 0 additions & 21 deletions
21
src/main/kotlin/com/doki/user/dto/GetUserLoginInfoResponse.kt
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
src/main/kotlin/com/doki/user/infrastructure/UserRepository.kt
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
39 changes: 39 additions & 0 deletions
39
src/main/kotlin/com/doki/user/user/application/UserSurveyCommandService.kt
This file contains hidden or 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,39 @@ | ||
| package com.doki.user.user.application | ||
|
|
||
| import com.doki.user.user.application.dto.CreateUserSurveyCommand | ||
| import com.doki.user.user.domain.UserRepository | ||
| import com.doki.user.user.domain.UserSurvey | ||
| import com.doki.user.user.domain.dto.UserSurveyCreatedResponse | ||
| import com.doki.user.user.domain.dto.UserSurveyResponse | ||
| import com.doki.user.user.domain.UserSurveyRepository | ||
| import org.springframework.stereotype.Service | ||
| import org.springframework.transaction.annotation.Transactional | ||
|
|
||
| @Transactional | ||
| @Service | ||
| class UserSurveyCommandService( | ||
| private val userRepository: UserRepository, | ||
| private val userSurveyRepository: UserSurveyRepository, | ||
| ) { | ||
|
|
||
| fun saveUserSurvey(userId: Long, command: CreateUserSurveyCommand): UserSurveyCreatedResponse { | ||
| val user = userRepository.findById(userId) | ||
| ?: throw IllegalArgumentException("User with id $userId does not exist.") | ||
|
|
||
| if (userSurveyRepository.existsByUserId(userId)) { | ||
| throw IllegalArgumentException("UserSurvey already exists.") | ||
| } | ||
|
|
||
| val survey = UserSurvey.of( | ||
| user = user, | ||
| concept = command.concept, | ||
| idolName = command.idolName, | ||
| visitStartDate = command.visitStartDate, | ||
| visitEndDate = command.visitEndDate, | ||
| places = command.places | ||
| ) | ||
|
|
||
| val saved = userSurveyRepository.save(survey) | ||
| return UserSurveyCreatedResponse(saved.id) | ||
| } | ||
| } |
20 changes: 20 additions & 0 deletions
20
src/main/kotlin/com/doki/user/user/application/UserSurveyQueryService.kt
This file contains hidden or 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,20 @@ | ||
| package com.doki.user.user.application | ||
|
|
||
| import com.doki.user.user.domain.UserSurveyRepository | ||
| import com.doki.user.user.domain.dto.UserSurveyResponse | ||
| import org.springframework.stereotype.Service | ||
| import org.springframework.transaction.annotation.Transactional | ||
|
|
||
| @Transactional(readOnly = true) | ||
| @Service | ||
| class UserSurveyQueryService( | ||
| private val userSurveyRepository: UserSurveyRepository | ||
| ) { | ||
|
|
||
| fun findUserSurvey(userId: Long): UserSurveyResponse { | ||
| val survey = userSurveyRepository.findByUserId(userId) | ||
| ?: throw IllegalArgumentException("UserSurvey does not exist.") | ||
|
|
||
| return UserSurveyResponse.from(survey) | ||
| } | ||
| } |
12 changes: 12 additions & 0 deletions
12
src/main/kotlin/com/doki/user/user/application/dto/CreateUserSurveyCommand.kt
This file contains hidden or 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,12 @@ | ||
| package com.doki.user.user.application.dto | ||
|
|
||
| import com.doki.user.user.domain.vo.ConceptType | ||
| import java.time.LocalDate | ||
|
|
||
| data class CreateUserSurveyCommand ( | ||
| val concept: ConceptType, | ||
| val idolName: String, | ||
| val visitStartDate: LocalDate, | ||
| val visitEndDate: LocalDate, | ||
| val places: List<String> | ||
| ) |
4 changes: 2 additions & 2 deletions
4
...plication/dto/GetUserLoginInfoResponse.kt → ...plication/dto/GetUserLoginInfoResponse.kt
This file contains hidden or 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 hidden or 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
10 changes: 10 additions & 0 deletions
10
src/main/kotlin/com/doki/user/user/domain/UserRepository.kt
This file contains hidden or 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,10 @@ | ||
| package com.doki.user.user.domain | ||
|
|
||
| interface UserRepository { | ||
|
|
||
| fun findById(userId: Long): User? | ||
|
|
||
| fun findByEmail(email: String): User? | ||
|
|
||
| fun save(user: User): User | ||
| } |
This file contains hidden or 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,70 @@ | ||
| package com.doki.user.user.domain | ||
|
|
||
| import com.doki.global.BaseEntity | ||
| import com.doki.user.user.domain.vo.ConceptType | ||
| import jakarta.persistence.* | ||
| import java.time.LocalDate | ||
|
|
||
| @Entity | ||
| @Table(name = "user_survey") | ||
| class UserSurvey( | ||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| val id: Long = 0L, | ||
|
|
||
| @OneToOne(fetch = FetchType.LAZY, optional = false) | ||
| @JoinColumn(name = "user_id", nullable = false, unique = true) | ||
| val user: User, | ||
|
|
||
| @Enumerated(EnumType.STRING) | ||
| @Column(nullable = false, length = 30) | ||
| val concept: ConceptType, | ||
|
|
||
| @Column(name = "idol_name", nullable = false) | ||
| val idolName: String, | ||
|
|
||
| @Column(name = "visit_start_date", nullable = false) | ||
| val visitStartDate: LocalDate, | ||
|
|
||
| @Column(name = "visit_end_date", nullable = false) | ||
| val visitEndDate: LocalDate, | ||
|
|
||
| @ElementCollection | ||
| @CollectionTable( | ||
| name = "user_survey_places", | ||
| joinColumns = [JoinColumn(name = "user_survey_id")] | ||
| ) | ||
| @Column(name = "place", nullable = false, length = 100) | ||
| val places: List<String> | ||
| ) : BaseEntity() { | ||
|
|
||
| init { | ||
| require(places.isNotEmpty()) { "place must not be empty" } | ||
| require(!visitEndDate.isBefore(visitStartDate)) { "visitEndDate must be on or after visitStartDate" } | ||
| } | ||
|
|
||
| companion object { | ||
| private fun normalizePlaces(places: List<String>): List<String> = | ||
| places.map { it.trim() } | ||
| .filter { it.isNotBlank() } | ||
| .distinct() | ||
|
|
||
| fun of( | ||
| user: User, | ||
| concept: ConceptType, | ||
| idolName: String, | ||
| visitStartDate: LocalDate, | ||
| visitEndDate: LocalDate, | ||
| places: List<String> | ||
| ): UserSurvey { | ||
| return UserSurvey( | ||
| user = user, | ||
| concept = concept, | ||
| idolName = idolName.trim(), | ||
| visitStartDate = visitStartDate, | ||
| visitEndDate = visitEndDate, | ||
| places = normalizePlaces(places) | ||
| ) | ||
| } | ||
| } | ||
| } | ||
10 changes: 10 additions & 0 deletions
10
src/main/kotlin/com/doki/user/user/domain/UserSurveyRepository.kt
This file contains hidden or 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,10 @@ | ||
| package com.doki.user.user.domain | ||
|
|
||
| interface UserSurveyRepository { | ||
|
|
||
| fun findByUserId(userId: Long): UserSurvey? | ||
|
|
||
| fun existsByUserId(userId: Long): Boolean | ||
|
|
||
| fun save(userSurvey: UserSurvey): UserSurvey | ||
| } |
8 changes: 8 additions & 0 deletions
8
src/main/kotlin/com/doki/user/user/domain/dto/UserSurveyCreatedResponse.kt
This file contains hidden or 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,8 @@ | ||
| package com.doki.user.user.domain.dto | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema | ||
|
|
||
| data class UserSurveyCreatedResponse( | ||
| @field:Schema(description = "생성된 설문조사 ID", example = "1") | ||
| val id: Long | ||
| ) |
39 changes: 39 additions & 0 deletions
39
src/main/kotlin/com/doki/user/user/domain/dto/UserSurveyResponse.kt
This file contains hidden or 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,39 @@ | ||
| package com.doki.user.user.domain.dto | ||
|
|
||
| import com.doki.user.user.domain.UserSurvey | ||
| import com.doki.user.user.domain.vo.ConceptType | ||
| import io.swagger.v3.oas.annotations.media.Schema | ||
| import java.time.LocalDate | ||
|
|
||
| data class UserSurveyResponse( | ||
| @field:Schema(description = "설문조사 ID", example = "1") | ||
| val id: Long, | ||
|
|
||
| @field:Schema(description = "선호 컨셉", example = "GIRL_CRUSH") | ||
| val concept: ConceptType, | ||
|
|
||
| @field:Schema(description = "선호 아이돌 또는 그룹", example = "에스파") | ||
| val idolName: String, | ||
|
|
||
| @field:Schema(description = "여행 시작일", example = "2025-07-20") | ||
| val visitStartDate: LocalDate, | ||
|
|
||
| @field:Schema(description = "여행 종료일", example = "2025-07-22") | ||
| val visitEndDate: LocalDate, | ||
|
|
||
| @field:Schema(description = "여행 장소", example = "['용산구', '마포구']") | ||
| val places: List<String> | ||
| ) { | ||
| companion object { | ||
| fun from(userSurvey: UserSurvey): UserSurveyResponse { | ||
| return UserSurveyResponse( | ||
| id = userSurvey.id, | ||
| concept = userSurvey.concept, | ||
| idolName = userSurvey.idolName, | ||
| visitStartDate = userSurvey.visitStartDate, | ||
| visitEndDate = userSurvey.visitEndDate, | ||
| places = userSurvey.places | ||
| ) | ||
| } | ||
| } | ||
| } |
2 changes: 1 addition & 1 deletion
2
...ser/domain/exception/UserExceptionType.kt → ...ser/domain/exception/UserExceptionType.kt
This file contains hidden or 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
10 changes: 10 additions & 0 deletions
10
src/main/kotlin/com/doki/user/user/domain/vo/ConceptType.kt
This file contains hidden or 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,10 @@ | ||
| package com.doki.user.user.domain.vo | ||
|
|
||
| enum class ConceptType { | ||
| GIRL_CRUSH, | ||
| LOVELY_FRESH, | ||
| ELEGANT_GLAM, | ||
| DREAMY, | ||
| HIGHTEEN, | ||
| ETC | ||
| } |
4 changes: 2 additions & 2 deletions
4
...otlin/com/doki/user/domain/vo/Nickname.kt → .../com/doki/user/user/domain/vo/Nickname.kt
This file contains hidden or 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
2 changes: 1 addition & 1 deletion
2
...otlin/com/doki/user/domain/vo/UserRole.kt → .../com/doki/user/user/domain/vo/UserRole.kt
This file contains hidden or 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 |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package com.doki.user.domain.vo | ||
| package com.doki.user.user.domain.vo | ||
|
|
||
| enum class UserRole { | ||
| USER // 회원 | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
사전 위치 기반으로 데이터를 제공해준다면, 해당 정보가 필요할 거 같은데 조회할 때 복잡한 요구사항은 없을 것 같아서 지금 구조도 괜찮아 보입니다! 나중에 위치 데이터를 복잡하게 다룬다면 그때 개선하는 걸로 하시죠!!