generated from pricelees/issue-pr-template
refactor: 테마 / 일정에서의 생성(수정)인 반환 타입을 OperatorInfo로 수정
This commit is contained in:
parent
3b6e7ba7a6
commit
26910f1d14
@ -7,6 +7,7 @@ import io.github.oshai.kotlinlogging.KotlinLogging
|
|||||||
import org.springframework.data.repository.findByIdOrNull
|
import org.springframework.data.repository.findByIdOrNull
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
import org.springframework.transaction.annotation.Transactional
|
import org.springframework.transaction.annotation.Transactional
|
||||||
|
import roomescape.admin.business.AdminService
|
||||||
import roomescape.common.config.next
|
import roomescape.common.config.next
|
||||||
import roomescape.member.business.MemberService
|
import roomescape.member.business.MemberService
|
||||||
import roomescape.schedule.exception.ScheduleErrorCode
|
import roomescape.schedule.exception.ScheduleErrorCode
|
||||||
@ -23,7 +24,7 @@ class ScheduleService(
|
|||||||
private val scheduleRepository: ScheduleRepository,
|
private val scheduleRepository: ScheduleRepository,
|
||||||
private val scheduleValidator: ScheduleValidator,
|
private val scheduleValidator: ScheduleValidator,
|
||||||
private val tsidFactory: TsidFactory,
|
private val tsidFactory: TsidFactory,
|
||||||
private val memberService: MemberService
|
private val adminService: AdminService
|
||||||
) {
|
) {
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
@ -53,8 +54,8 @@ class ScheduleService(
|
|||||||
|
|
||||||
val schedule: ScheduleEntity = findOrThrow(id)
|
val schedule: ScheduleEntity = findOrThrow(id)
|
||||||
|
|
||||||
val createdBy = memberService.findSummaryById(schedule.createdBy).name
|
val createdBy = adminService.findOperatorById(schedule.createdBy)
|
||||||
val updatedBy = memberService.findSummaryById(schedule.updatedBy).name
|
val updatedBy = adminService.findOperatorById(schedule.updatedBy)
|
||||||
|
|
||||||
return schedule.toDetailRetrieveResponse(createdBy, updatedBy)
|
return schedule.toDetailRetrieveResponse(createdBy, updatedBy)
|
||||||
.also {
|
.also {
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package roomescape.schedule.web
|
package roomescape.schedule.web
|
||||||
|
|
||||||
|
import roomescape.common.dto.OperatorInfo
|
||||||
import roomescape.schedule.infrastructure.persistence.ScheduleEntity
|
import roomescape.schedule.infrastructure.persistence.ScheduleEntity
|
||||||
import roomescape.schedule.infrastructure.persistence.ScheduleStatus
|
import roomescape.schedule.infrastructure.persistence.ScheduleStatus
|
||||||
import java.time.LocalDate
|
import java.time.LocalDate
|
||||||
@ -49,12 +50,12 @@ data class ScheduleDetailRetrieveResponse(
|
|||||||
val time: LocalTime,
|
val time: LocalTime,
|
||||||
val status: ScheduleStatus,
|
val status: ScheduleStatus,
|
||||||
val createdAt: LocalDateTime,
|
val createdAt: LocalDateTime,
|
||||||
val createdBy: String,
|
val createdBy: OperatorInfo,
|
||||||
val updatedAt: LocalDateTime,
|
val updatedAt: LocalDateTime,
|
||||||
val updatedBy: String,
|
val updatedBy: OperatorInfo,
|
||||||
)
|
)
|
||||||
|
|
||||||
fun ScheduleEntity.toDetailRetrieveResponse(createdBy: String, updatedBy: String) = ScheduleDetailRetrieveResponse(
|
fun ScheduleEntity.toDetailRetrieveResponse(createdBy: OperatorInfo, updatedBy: OperatorInfo) = ScheduleDetailRetrieveResponse(
|
||||||
id = this.id,
|
id = this.id,
|
||||||
date = this.date,
|
date = this.date,
|
||||||
time = this.time,
|
time = this.time,
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import io.github.oshai.kotlinlogging.KotlinLogging
|
|||||||
import org.springframework.data.repository.findByIdOrNull
|
import org.springframework.data.repository.findByIdOrNull
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
import org.springframework.transaction.annotation.Transactional
|
import org.springframework.transaction.annotation.Transactional
|
||||||
|
import roomescape.admin.business.AdminService
|
||||||
import roomescape.common.config.next
|
import roomescape.common.config.next
|
||||||
import roomescape.member.business.MemberService
|
import roomescape.member.business.MemberService
|
||||||
import roomescape.theme.exception.ThemeErrorCode
|
import roomescape.theme.exception.ThemeErrorCode
|
||||||
@ -19,9 +20,9 @@ private val log: KLogger = KotlinLogging.logger {}
|
|||||||
@Service
|
@Service
|
||||||
class ThemeService(
|
class ThemeService(
|
||||||
private val themeRepository: ThemeRepository,
|
private val themeRepository: ThemeRepository,
|
||||||
|
private val themeValidator: ThemeValidator,
|
||||||
private val tsidFactory: TsidFactory,
|
private val tsidFactory: TsidFactory,
|
||||||
private val memberService: MemberService,
|
private val adminService: AdminService
|
||||||
private val themeValidator: ThemeValidator
|
|
||||||
) {
|
) {
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
fun findThemesByIds(request: ThemeListRetrieveRequest): ThemeSummaryListResponse {
|
fun findThemesByIds(request: ThemeListRetrieveRequest): ThemeSummaryListResponse {
|
||||||
@ -66,8 +67,8 @@ class ThemeService(
|
|||||||
|
|
||||||
val theme: ThemeEntity = findOrThrow(id)
|
val theme: ThemeEntity = findOrThrow(id)
|
||||||
|
|
||||||
val createdBy = memberService.findSummaryById(theme.createdBy).name
|
val createdBy = adminService.findOperatorById(theme.createdBy)
|
||||||
val updatedBy = memberService.findSummaryById(theme.updatedBy).name
|
val updatedBy = adminService.findOperatorById(theme.updatedBy)
|
||||||
|
|
||||||
return theme.toAdminThemeDetailResponse(createdBy, updatedBy)
|
return theme.toAdminThemeDetailResponse(createdBy, updatedBy)
|
||||||
.also { log.info { "[ThemeService.findAdminThemeDetail] 테마 상세 조회 완료: id=$id, name=${theme.name}" } }
|
.also { log.info { "[ThemeService.findAdminThemeDetail] 테마 상세 조회 완료: id=$id, name=${theme.name}" } }
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package roomescape.theme.web
|
package roomescape.theme.web
|
||||||
|
|
||||||
|
import roomescape.common.dto.OperatorInfo
|
||||||
import roomescape.theme.infrastructure.persistence.Difficulty
|
import roomescape.theme.infrastructure.persistence.Difficulty
|
||||||
import roomescape.theme.infrastructure.persistence.ThemeEntity
|
import roomescape.theme.infrastructure.persistence.ThemeEntity
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
@ -103,12 +104,12 @@ data class AdminThemeDetailRetrieveResponse(
|
|||||||
val expectedMinutesTo: Short,
|
val expectedMinutesTo: Short,
|
||||||
val isOpen: Boolean,
|
val isOpen: Boolean,
|
||||||
val createdAt: LocalDateTime,
|
val createdAt: LocalDateTime,
|
||||||
val createdBy: String,
|
val createdBy: OperatorInfo,
|
||||||
val updatedAt: LocalDateTime,
|
val updatedAt: LocalDateTime,
|
||||||
val updatedBy: String,
|
val updatedBy: OperatorInfo,
|
||||||
)
|
)
|
||||||
|
|
||||||
fun ThemeEntity.toAdminThemeDetailResponse(createUserName: String, updateUserName: String) =
|
fun ThemeEntity.toAdminThemeDetailResponse(createdBy: OperatorInfo, updatedBy: OperatorInfo) =
|
||||||
AdminThemeDetailRetrieveResponse(
|
AdminThemeDetailRetrieveResponse(
|
||||||
id = this.id,
|
id = this.id,
|
||||||
name = this.name,
|
name = this.name,
|
||||||
@ -123,9 +124,9 @@ fun ThemeEntity.toAdminThemeDetailResponse(createUserName: String, updateUserNam
|
|||||||
expectedMinutesTo = this.expectedMinutesTo,
|
expectedMinutesTo = this.expectedMinutesTo,
|
||||||
isOpen = this.isOpen,
|
isOpen = this.isOpen,
|
||||||
createdAt = this.createdAt,
|
createdAt = this.createdAt,
|
||||||
createdBy = createUserName,
|
createdBy = createdBy,
|
||||||
updatedAt = this.updatedAt,
|
updatedAt = this.updatedAt,
|
||||||
updatedBy = updateUserName
|
updatedBy = updatedBy
|
||||||
)
|
)
|
||||||
|
|
||||||
data class ThemeListRetrieveRequest(
|
data class ThemeListRetrieveRequest(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user