Skip to content

Commit

Permalink
feat :: 주간 행사 일정 생성
Browse files Browse the repository at this point in the history
  • Loading branch information
geunoo committed Dec 21, 2023
1 parent 71e8c19 commit 4567412
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.kodomo.juganbbojjak.domain.event_schedule.dto

import java.time.LocalDate

data class CreateWeeklyEventScheduleRequest(
val startDate: LocalDate,
val endDate: LocalDate,
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import java.util.UUID

@Aggregate
data class WeeklyEventSchedule(
val id: UUID,
val id: UUID = UUID.randomUUID(),
val startDate: LocalDate,
val endDate: LocalDate,
)
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ interface QueryEventSchedulePort {
interface CommandEventSchedulePort {
fun saveAllEventSchedule(eventSchedule: List<EventSchedule>)
fun saveEventSchedule(eventSchedule: EventSchedule)
fun saveWeeklyEventSchedule(weeklyEventSchedule: WeeklyEventSchedule): WeeklyEventSchedule
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.kodomo.juganbbojjak.domain.event_schedule.usecase

import com.kodomo.juganbbojjak.common.annotation.UseCase
import com.kodomo.juganbbojjak.domain.event_schedule.dto.CreateWeeklyEventScheduleRequest
import com.kodomo.juganbbojjak.domain.event_schedule.model.WeeklyEventSchedule
import com.kodomo.juganbbojjak.domain.event_schedule.spi.CommandEventSchedulePort

@UseCase
class CreateWeeklyEventScheduleUseCase(
private val commandEventSchedulePort: CommandEventSchedulePort,
) {

fun execute(request: CreateWeeklyEventScheduleRequest) {
commandEventSchedulePort.saveWeeklyEventSchedule(
WeeklyEventSchedule(
startDate = request.startDate,
endDate = request.endDate,
)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,17 @@ class EvenSchedulePersistenceAdapter(
eventScheduleJpaRepository.save(eventScheduleMapper.toEntity(eventSchedule))
}

override fun saveWeeklyEventSchedule(weeklyEventSchedule: WeeklyEventSchedule): WeeklyEventSchedule = weeklyEventScheduleMapper.toDomain(
weeklyEventScheduleJpaRepository.save(weeklyEventScheduleMapper.toEntity(weeklyEventSchedule))
)!!

//==condition==//

private fun eqUserId(userId: UUID?): BooleanExpression? =
if (userId != null)
eventScheduleEntity.userEntity.id.eq(userId)
else null

override fun queryAllEventScheduleList(): List<WeeklyEventSchedule> {
val weeklyEventScheduleEntity = weeklyEventScheduleJpaRepository.findAllByOrderByEndDateDesc()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package com.kodomo.juganbbojjak.domain.event_schedule.presentation

import com.kodomo.juganbbojjak.domain.event_schedule.dto.response.QueryEventScheduleDetailResponse
import com.kodomo.juganbbojjak.domain.event_schedule.presentation.dto.CreateEvenScheduleWebRequest
import com.kodomo.juganbbojjak.domain.event_schedule.presentation.dto.CreateWeeklyEventScheduleWebRequest
import com.kodomo.juganbbojjak.domain.event_schedule.presentation.dto.UpdateEventScheduleWebRequest
import com.kodomo.juganbbojjak.domain.event_schedule.usecase.CreateEvenScheduleUseCase
import com.kodomo.juganbbojjak.domain.event_schedule.usecase.CreateWeeklyEventScheduleUseCase
import com.kodomo.juganbbojjak.domain.event_schedule.usecase.QueryEventScheduleDetailUseCase
import com.kodomo.juganbbojjak.domain.event_schedule.usecase.UpdateEventScheduleUseCase
import jakarta.validation.Valid
Expand All @@ -24,6 +26,7 @@ class EventScheduleWebAdapter(
private val createEvenScheduleUseCase: CreateEvenScheduleUseCase,
private val queryEventScheduleDetailUseCase: QueryEventScheduleDetailUseCase,
private val updateEventScheduleUseCase: UpdateEventScheduleUseCase,
private val createWeeklyEventScheduleUseCase: CreateWeeklyEventScheduleUseCase,
) {

@ResponseStatus(HttpStatus.CREATED)
Expand All @@ -48,4 +51,12 @@ class EventScheduleWebAdapter(
) {
updateEventScheduleUseCase.execute(eventScheduleId, request.toDomainRequest())
}

@ResponseStatus(HttpStatus.CREATED)
@PostMapping
fun createWeeklyEventSchedule(
@RequestBody @Valid request: CreateWeeklyEventScheduleWebRequest,
) {
createWeeklyEventScheduleUseCase.execute(request.toDomainRequest())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.kodomo.juganbbojjak.domain.event_schedule.presentation.dto

import com.kodomo.juganbbojjak.domain.event_schedule.dto.CreateWeeklyEventScheduleRequest
import org.jetbrains.annotations.NotNull
import java.time.LocalDate

data class CreateWeeklyEventScheduleWebRequest(

@field:NotNull
val startDate: LocalDate,

@field:NotNull
val endDate: LocalDate,
) {

fun toDomainRequest() = CreateWeeklyEventScheduleRequest(
startDate = startDate,
endDate = endDate,
)
}

0 comments on commit 4567412

Please sign in to comment.