[#44] 매장 기능 도입 #45

Merged
pricelees merged 116 commits from feat/#44 into main 2025-09-20 03:15:06 +00:00
2 changed files with 10 additions and 17 deletions
Showing only changes of commit cf65ccf915 - Show all commits

View File

@ -8,6 +8,7 @@ import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional
import roomescape.admin.business.AdminService
import roomescape.common.config.next
import roomescape.common.dto.AuditInfo
import roomescape.theme.exception.ThemeErrorCode
import roomescape.theme.exception.ThemeException
import roomescape.theme.infrastructure.persistence.ThemeEntity
@ -42,18 +43,9 @@ class ThemeService(
}
@Transactional(readOnly = true)
fun findThemesByIds(request: ThemeIdListRequest): ThemeInfoListResponse {
fun findAllInfosByIds(request: ThemeIdListRequest): ThemeInfoListResponse {
log.info { "[ThemeService.findThemesByIds] 예약 페이지에서의 테마 목록 조회 시작: themeIds=${request.themeIds}" }
val result: MutableList<ThemeEntity> = mutableListOf()
for (id in request.themeIds) {
val theme: ThemeEntity? = themeRepository.findByIdOrNull(id)
if (theme == null) {
log.warn { "[ThemeService.findThemesByIds] id=${id} 인 테마 조회 실패" }
continue
}
result.add(theme)
}
val result: List<ThemeEntity> = themeRepository.findAllByIdIn(request.themeIds)
return result.toInfoListResponse().also {
log.info { "[ThemeService.findThemesByIds] ${it.themes.size} / ${request.themeIds.size} 개 테마 조회 완료" }
@ -80,8 +72,9 @@ class ThemeService(
val createdBy = adminService.findOperatorOrUnknown(theme.createdBy)
val updatedBy = adminService.findOperatorOrUnknown(theme.updatedBy)
val audit = AuditInfo(theme.createdAt, createdBy, theme.updatedAt, updatedBy)
return theme.toAdminThemeDetailResponse(createdBy, updatedBy)
return theme.toAdminThemeDetailResponse(audit)
.also { log.info { "[ThemeService.findAdminThemeDetail] 테마 상세 조회 완료: id=$id, name=${theme.name}" } }
}
@ -91,9 +84,8 @@ class ThemeService(
themeValidator.validateCanCreate(request)
val theme: ThemeEntity = themeRepository.save(
request.toEntity(tsidFactory.next())
)
val theme: ThemeEntity = request.toEntity(id = tsidFactory.next())
.also { themeRepository.save(it) }
return ThemeCreateResponse(theme.id).also {
log.info { "[ThemeService.createTheme] 테마 생성 완료: id=${theme.id}, name=${theme.name}" }
@ -155,7 +147,6 @@ class ThemeService(
}
}
// ========================================
// Common (공통 메서드)
// ========================================

View File

@ -9,4 +9,6 @@ interface ThemeRepository : JpaRepository<ThemeEntity, Long> {
fun findActiveThemes(): List<ThemeEntity>
fun existsByName(name: String): Boolean
}
fun findAllByIdIn(themeIds: List<Long>): List<ThemeEntity>
}