Skip to content

Commit

Permalink
default theme 개념 제거 (#232)
Browse files Browse the repository at this point in the history
  • Loading branch information
davin111 authored Mar 2, 2024
1 parent a97cdfb commit 8ca58a4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface TimetableThemeRepository : CoroutineCrudRepository<TimetableTheme, Str

suspend fun findByUserIdAndIsDefaultTrue(userId: String): TimetableTheme?

suspend fun findByUserIdAndIsCustomTrueOrderByCreatedAtDesc(userId: String): List<TimetableTheme>
suspend fun findByUserIdAndIsCustomTrueOrderByUpdatedAtDesc(userId: String): List<TimetableTheme>

suspend fun existsByUserIdAndName(userId: String, name: String): Boolean
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.wafflestudio.snu4t.timetables.service

import com.wafflestudio.snu4t.common.enum.BasicThemeType
import com.wafflestudio.snu4t.common.exception.DefaultThemeDeleteErrorException
import com.wafflestudio.snu4t.common.exception.DuplicateThemeNameException
import com.wafflestudio.snu4t.common.exception.InvalidThemeColorCountException
import com.wafflestudio.snu4t.common.exception.InvalidThemeTypeException
Expand Down Expand Up @@ -49,7 +48,7 @@ class TimetableThemeServiceImpl(
}

override suspend fun getThemes(userId: String): List<TimetableTheme> {
val customThemes = timetableThemeRepository.findByUserIdAndIsCustomTrueOrderByCreatedAtDesc(userId)
val customThemes = timetableThemeRepository.findByUserIdAndIsCustomTrueOrderByUpdatedAtDesc(userId)
val defaultTheme = getDefaultTheme(userId)

val basicThemes = BasicThemeType.values().map {
Expand Down Expand Up @@ -111,7 +110,6 @@ class TimetableThemeServiceImpl(

override suspend fun deleteTheme(userId: String, themeId: String) {
val theme = getCustomTheme(userId, themeId)
if (theme.isDefault) throw DefaultThemeDeleteErrorException

val timetables = timetableRepository.findByUserIdAndThemeId(userId, themeId)

Expand Down Expand Up @@ -192,7 +190,8 @@ class TimetableThemeServiceImpl(
}

override suspend fun getDefaultTheme(userId: String): TimetableTheme? {
return timetableThemeRepository.findByUserIdAndIsDefaultTrue(userId)
val customThemes = timetableThemeRepository.findByUserIdAndIsCustomTrueOrderByUpdatedAtDesc(userId)
return customThemes.firstOrNull() ?: buildTimetableTheme(userId, BasicThemeType.SNUTT, isDefault = true)
}

override suspend fun getTheme(userId: String, themeId: String?, basicThemeType: BasicThemeType?): TimetableTheme {
Expand Down

0 comments on commit 8ca58a4

Please sign in to comment.