Skip to content

Commit

Permalink
feat: 자기소개 작성하고 받는 첫 보틀 3개로 수정 (#530)
Browse files Browse the repository at this point in the history
  • Loading branch information
injoon2019 authored Oct 23, 2024
1 parent fdf7ddf commit 4b66d76
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class UserProfileFacade(
fun upsertIntroduction(userId: Long, registerIntroductionRequest: RegisterIntroductionRequest) {
validateIntroduction(registerIntroductionRequest)

profileService.saveIntroduction(userId, registerIntroductionRequest.introduction)
profileService.saveIntroduction(userId, registerIntroductionRequest.introduction, FIRST_MATCHING_COUNT)
}

fun getMyProfile(userId: Long): UserProfileResponse {
Expand Down Expand Up @@ -191,5 +191,6 @@ class UserProfileFacade(

companion object {
private const val FILE_NAME_DELIMITER = "_"
private const val FIRST_MATCHING_COUNT = 3
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,17 @@ class UserProfileService(
}

@Transactional
fun saveIntroduction(userId: Long, introduction: List<QuestionAndAnswer>) {
fun saveIntroduction(userId: Long, introduction: List<QuestionAndAnswer>, firstMatchingCount: Int) {
val user = userRepository.findByIdOrNull(userId) ?: throw IllegalStateException("회원가입 상태를 문의해주세요")
profileRepository.findByUserId(user.id)?.let {
val isFirstRegisterIntroduction = it.introduction.isEmpty()
it.introduction = introduction
if (isFirstRegisterIntroduction) {
applicationEventPublisher.publishEvent(
IntroductionSaveEventDto(userId = userId)
)
repeat(firstMatchingCount) {
applicationEventPublisher.publishEvent(
IntroductionSaveEventDto(userId = userId)
)
}
}
} ?: run {
profileRepository.save(
Expand Down

0 comments on commit 4b66d76

Please sign in to comment.