From 44facda400b8bd71bbb5643f7c7b9966cf93d102 Mon Sep 17 00:00:00 2001 From: sispo3314 Date: Fri, 13 Feb 2026 01:50:53 +0900 Subject: [PATCH] =?UTF-8?q?fix:ID=20=EA=B2=80=EC=A6=9D=20=EA=B8=B0?= =?UTF-8?q?=EC=A4=80=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/mypage/application/MyProfileService.kt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/com/stepbookstep/server/domain/mypage/application/MyProfileService.kt b/src/main/kotlin/com/stepbookstep/server/domain/mypage/application/MyProfileService.kt index 9abe0fe..4bc2195 100644 --- a/src/main/kotlin/com/stepbookstep/server/domain/mypage/application/MyProfileService.kt +++ b/src/main/kotlin/com/stepbookstep/server/domain/mypage/application/MyProfileService.kt @@ -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 @@ -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) @@ -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) }