Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.stepbookstep.server.domain.mypage.application

import com.stepbookstep.server.domain.book.domain.Book
import com.stepbookstep.server.domain.book.domain.BookRepository
import com.stepbookstep.server.domain.mypage.application.dto.UpdateNicknameRequest
import com.stepbookstep.server.domain.mypage.application.dto.UpdatePreferencesRequest
import com.stepbookstep.server.domain.user.domain.UserCategoryPreference
Expand All @@ -23,9 +25,10 @@ class MyProfileService(
private val refreshTokenRepository: RefreshTokenRepository,
private val userCategoryPreferenceRepository: UserCategoryPreferenceRepository,
private val userGenrePreferenceRepository: UserGenrePreferenceRepository,
private val kakaoUnlinkClient: KakaoUnlinkClient
private val kakaoUnlinkClient: KakaoUnlinkClient,
private val bookRepository: BookRepository,

) {
) {
companion object {
private val VALID_LEVELS = setOf(1, 2, 3)
private val log = LoggerFactory.getLogger(MyProfileService::class.java)
Expand All @@ -46,11 +49,14 @@ class MyProfileService(
val requestGenreIds = request.genreIds.distinct().toSet()

// 존재 여부 검증
if (!userCategoryPreferenceRepository.existsAllByIds(requestCategoryIds)) {
val validCategoryIds = bookRepository.findDistinctCategoryIds().toSet()
val validGenreIds = bookRepository.findDistinctGenreIds().toSet()

if (!validCategoryIds.containsAll(requestCategoryIds)) {
throw CustomException(ErrorCode.INVALID_INPUT)
}

if (!userGenrePreferenceRepository.existsAllByIds(requestGenreIds)) {
if (!validGenreIds.containsAll(requestGenreIds)) {
throw CustomException(ErrorCode.INVALID_INPUT)
}

Expand Down