From 164959272799054e0e75b34e98ca2368dcb27645 Mon Sep 17 00:00:00 2001 From: Davin Byeon Date: Sat, 3 Feb 2024 17:39:03 +0900 Subject: [PATCH] =?UTF-8?q?=EC=BB=A4=EC=8A=A4=ED=85=80=20=ED=85=8C?= =?UTF-8?q?=EB=A7=88=EA=B0=80=20=ED=95=98=EB=82=98=EB=8F=84=20=EC=97=86?= =?UTF-8?q?=EC=9D=84=20=EB=95=8C,=20SNUTT=20=EB=A5=BC=20default=20?= =?UTF-8?q?=EB=A1=9C=20=ED=91=9C=EC=8B=9C=ED=95=B4=EC=A3=BC=EA=B8=B0=20(#2?= =?UTF-8?q?23)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../timetables/dto/TimetableThemeDto.kt | 2 +- .../service/TimetableThemeService.kt | 23 +++++++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/core/src/main/kotlin/timetables/dto/TimetableThemeDto.kt b/core/src/main/kotlin/timetables/dto/TimetableThemeDto.kt index f03a2043..88105407 100644 --- a/core/src/main/kotlin/timetables/dto/TimetableThemeDto.kt +++ b/core/src/main/kotlin/timetables/dto/TimetableThemeDto.kt @@ -17,7 +17,7 @@ data class TimetableThemeDto( fun TimetableThemeDto(timetableTheme: TimetableTheme) = with(timetableTheme) { TimetableThemeDto( - id = id, + id = if (isCustom) id else null, theme = toBasicThemeType(), name = name, colors = colors, diff --git a/core/src/main/kotlin/timetables/service/TimetableThemeService.kt b/core/src/main/kotlin/timetables/service/TimetableThemeService.kt index c56e2dbf..b224ccfa 100644 --- a/core/src/main/kotlin/timetables/service/TimetableThemeService.kt +++ b/core/src/main/kotlin/timetables/service/TimetableThemeService.kt @@ -52,10 +52,18 @@ class TimetableThemeServiceImpl( val customThemes = timetableThemeRepository.findByUserIdAndIsCustomTrueOrderByCreatedAtDesc(userId) val defaultTheme = getDefaultTheme(userId) - return ( - BasicThemeType.values().map { buildTimetableTheme(userId, it, isDefault = it.displayName == defaultTheme?.name) } + - customThemes + val basicThemes = BasicThemeType.values().map { + buildTimetableTheme( + userId, + it, + isDefault = ( + it.displayName == defaultTheme?.name || + (defaultTheme == null && it == BasicThemeType.SNUTT) + ) ) + } + + return basicThemes + customThemes } override suspend fun addTheme(userId: String, name: String, colors: List): TimetableTheme { @@ -194,7 +202,14 @@ class TimetableThemeServiceImpl( return themeId?.let { timetableThemeRepository.findByIdAndUserId(it, userId) ?: throw ThemeNotFoundException - } ?: buildTimetableTheme(userId, basicThemeType!!, isDefault = basicThemeType.displayName == defaultTheme?.name) + } ?: buildTimetableTheme( + userId, + basicThemeType!!, + isDefault = ( + basicThemeType.displayName == defaultTheme?.name || + (defaultTheme == null && basicThemeType == BasicThemeType.SNUTT) + ), + ) } private suspend fun getCustomTheme(userId: String, themeId: String): TimetableTheme {