Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

250 Update logback file #252

Merged
merged 4 commits into from
Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class QueryReservationByHomeBaseUseCase(
val homeBases = homeBaseService.queryHomeBaseByFloorAndPeriod(floor, period)

return homeBases.map {
reservationPort.queryReservationByHomeBase(it)?.let { reservation ->
reservationPort.queryReservationByHomeBaseId(it.id)?.let { reservation ->
val users = userService.queryAllUserById(reservation.userIds)

ReservationResponse.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import java.util.*
interface QueryReservationService {

fun queryReservationById(id: UUID): Reservation
fun queryReservationByHomeBase(homeBase: HomeBase): Reservation?
fun queryReservationByHomeBaseId(homeBaseId: Long): Reservation?
fun queryAllReservationByHomeBaseIn(homeBases: List<HomeBase>): List<Reservation>
fun queryAllReservation(): List<Reservation>
fun countReservationByHomeBase(homeBase: HomeBase): Int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class QueryReservationServiceImpl(
override fun queryReservationById(id: UUID): Reservation =
queryReservationPort.queryReservationById(id) ?: throw ReservationNotFoundException()

override fun queryReservationByHomeBase(homeBase: HomeBase): Reservation? =
queryReservationPort.queryReservationByHomeBase(homeBase)
override fun queryReservationByHomeBaseId(homeBaseId: Long): Reservation? =
queryReservationPort.queryReservationByHomeBaseId(homeBaseId)

override fun queryAllReservationByHomeBaseIn(homeBases: List<HomeBase>): List<Reservation> =
queryReservationPort.queryAllReservationByHomeBaseIn(homeBases)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import java.util.UUID
interface QueryReservationPort {

fun queryReservationById(id: UUID): Reservation?
fun queryReservationByHomeBase(homeBase: HomeBase): Reservation?
fun queryReservationByHomeBaseId(homeBaseId: Long): Reservation?
fun queryAllReservationByHomeBaseIn(homeBases: List<HomeBase>): List<Reservation>
fun queryAllReservations(): List<Reservation>
fun countReservationByHomeBase(homeBase: HomeBase): Int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,19 @@ import java.time.LocalDateTime
@Component
class ReservationValidatorImpl : ReservationValidator {

// 오전 8시 10분부터 오후 8시 30분까지만 예약 가능
override fun validateReservationTime(currentTime: LocalDateTime, period: Int) {
val hour = currentTime.hour
val minute = currentTime.minute

/*
오전 8시 10분부터 오후 8시 30분까지만 예약 가능
*/
if (hour < 8 || (hour == 8 && minute < 10) || hour > 20 || (hour == 20 && minute > 30))
throw NotReserveHomeBaseHourException()
}

// 금요일, 토요일, 일요일은 예약 불가능
override fun validateReservationDay(currentTime: LocalDateTime): DayOfWeek {
val dayOfWeek = currentTime.dayOfWeek

// 금요일, 토요일, 일요일은 예약 불가능
if (dayOfWeek == DayOfWeek.FRIDAY || dayOfWeek == DayOfWeek.SATURDAY || dayOfWeek == DayOfWeek.SUNDAY)
throw NotReserveHomeBaseHourException()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ class ReservationPersistenceAdapter(
override fun queryReservationById(id: UUID) =
reservationMapper.toDomain(reservationRepository.findByIdOrNull(id))

override fun queryReservationByHomeBase(homeBase: HomeBase): Reservation? =
reservationMapper.toDomain(reservationRepository.findByHomeBase(homeBaseMapper.toEntity(homeBase)))
override fun queryReservationByHomeBaseId(homeBaseId: Long): Reservation? =
reservationMapper.toDomain(reservationRepository.findByHomeBaseId(homeBaseId))

override fun queryAllReservationByHomeBaseIn(homeBases: List<HomeBase>): List<Reservation> =
reservationRepository.findAllByHomeBaseIn(homeBases.map { homeBaseMapper.toEntity(it) })
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
package team.msg.hiv2.domain.reservation.persistence.entity

import javax.persistence.CollectionTable
import javax.persistence.Column
import javax.persistence.ElementCollection
import javax.persistence.Entity
import javax.persistence.FetchType
import javax.persistence.Index
import javax.persistence.JoinColumn
import javax.persistence.OneToOne
import javax.persistence.Table
import org.hibernate.annotations.OnDelete
import org.hibernate.annotations.OnDeleteAction
import team.msg.hiv2.domain.homebase.persistence.entity.HomeBaseJpaEntity
import team.msg.hiv2.global.entity.BaseUuidEntity
import java.util.*
import javax.persistence.*
import org.hibernate.annotations.OnDelete
import org.hibernate.annotations.OnDeleteAction

@Entity
@Table(name = "reservation")
Expand All @@ -26,8 +34,11 @@ class ReservationJpaEntity(
@JoinColumn(name = "reservation_id")
@OnDelete(action = OnDeleteAction.CASCADE)
@Column(columnDefinition = "BINARY(16)", name = "user_id")
@ElementCollection
@CollectionTable(name = "users", joinColumns = [JoinColumn(name = "reservation_id")])
@ElementCollection(fetch = FetchType.LAZY)
@CollectionTable(
name = "users",
joinColumns = [JoinColumn(name = "reservation_id")]
)
val userIds: MutableList<UUID>

) : BaseUuidEntity(id)
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import javax.persistence.LockModeType.*
interface ReservationRepository : JpaRepository<ReservationJpaEntity, UUID> {

@EntityGraph(attributePaths = ["homeBase"])
fun findByHomeBase(homeBase: HomeBaseJpaEntity): ReservationJpaEntity?
fun findByHomeBaseId(homeBaseId: Long): ReservationJpaEntity?
@EntityGraph(attributePaths = ["homeBase"])
fun findAllByHomeBaseIn(homeBases: List<HomeBaseJpaEntity>): List<ReservationJpaEntity>
@Modifying
Expand Down
5 changes: 1 addition & 4 deletions src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
<configuration scan="true" scanPeriod="30 seconds">
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>

<property name="LOG_PATH" value="./logs"/>
<property name="LOG_NAME" value="hiv2-log"/>

<springProfile name="local | prod">
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
Expand All @@ -14,7 +11,7 @@
</encoder>
</appender>

<logger name="org.springframework" level="INFO">
<logger name="org.springframework" level="TRACE">
<appender-ref ref="CONSOLE"/>
</logger>
<logger name="org.hibernate.orm.jdbc.bind" level="TRACE">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class QueryReservationByHomeBaseUseCaseTest {
given(queryHomeBaseService.queryHomeBaseByFloorAndPeriod(floor, period))
.willReturn(listOf(homeBaseStub))

given(queryReservationPort.queryReservationByHomeBase(homeBaseStub))
given(queryReservationPort.queryReservationByHomeBaseId(homeBaseId))
.willReturn(reservationStub)

given(userService.queryAllUserById(listOf(userId1, userId2)))
Expand Down
Loading