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

merge :: (#28) 주간 업무 보고, 주간 행사 일정 생성 api #29

Merged
merged 3 commits into from
Dec 26, 2023
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
@@ -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
@@ -0,0 +1,8 @@
package com.kodomo.juganbbojjak.domain.work_report.dto

import java.time.LocalDate

data class CreateWeeklyWorkReportRequest(
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
interface WeeklyWorkReportPort : CommandWeeklyWorkReportPort, QueryWeeklyWorkReportPort

interface CommandWeeklyWorkReportPort {

fun saveWeeklyWorkReport(weeklyWorkReport: WeeklyWorkReport)
}

interface QueryWeeklyWorkReportPort {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.kodomo.juganbbojjak.domain.work_report.spi

import com.kodomo.juganbbojjak.domain.work_report.model.WeeklyWorkReport
import com.kodomo.juganbbojjak.domain.work_report.model.WorkReport
import java.util.UUID

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.kodomo.juganbbojjak.domain.work_report.usecase

import com.kodomo.juganbbojjak.common.annotation.UseCase
import com.kodomo.juganbbojjak.domain.work_report.dto.CreateWeeklyWorkReportRequest
import com.kodomo.juganbbojjak.domain.work_report.model.WeeklyWorkReport
import com.kodomo.juganbbojjak.domain.work_report.spi.CommandWeeklyWorkReportPort

@UseCase
class CreateWeeklyWorkReportUseCase(
private val commandWorkReportPort: CommandWeeklyWorkReportPort,
) {

fun execute(request: CreateWeeklyWorkReportRequest) {
commandWorkReportPort.saveWeeklyWorkReport(
WeeklyWorkReport(
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,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ class WeeklyWorkReportPersistenceAdapter(
private val weeklyWorkReportMapper: WeeklyWorkReportMapper
) : WeeklyWorkReportPort {

override fun saveWeeklyWorkReport(weeklyWorkReport: WeeklyWorkReport) {
weeklyWorkReportRepository.save(weeklyWorkReportMapper.toEntity(weeklyWorkReport))
}

override fun queryWeeklyWorkReportById(weeklyWorkReportId: UUID): WeeklyWorkReport =
weeklyWorkReportMapper.toDomain(
weeklyWorkReportRepository.findByIdOrNull(weeklyWorkReportId)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.kodomo.juganbbojjak.domain.work_report.presentation

import com.kodomo.juganbbojjak.domain.work_report.dto.response.QueryWorkReportDetailsResponse
import com.kodomo.juganbbojjak.domain.work_report.presentation.dto.CreateWeeklyWorkReportWebRequest
import com.kodomo.juganbbojjak.domain.work_report.presentation.dto.CreateWorkReportWebRequest
import com.kodomo.juganbbojjak.domain.work_report.presentation.dto.UpdateWorkReportWebRequest
import com.kodomo.juganbbojjak.domain.work_report.usecase.CreateWeeklyWorkReportUseCase
import com.kodomo.juganbbojjak.domain.work_report.usecase.CreateWorkReportUseCase
import com.kodomo.juganbbojjak.domain.work_report.usecase.QueryWorkReportDetailsUseCase
import com.kodomo.juganbbojjak.domain.work_report.usecase.UpdateWorkReportUseCase
Expand All @@ -23,7 +25,8 @@ import java.util.UUID
class WorkReportWebAdapter(
private val createWorkReportUseCase: CreateWorkReportUseCase,
private val queryWorkReportDetailsUseCase: QueryWorkReportDetailsUseCase,
private val updateWorkReportUseCase: UpdateWorkReportUseCase
private val updateWorkReportUseCase: UpdateWorkReportUseCase,
private val createWeeklyWorkReportUseCase: CreateWeeklyWorkReportUseCase,
) {

@ResponseStatus(HttpStatus.CREATED)
Expand All @@ -45,4 +48,11 @@ class WorkReportWebAdapter(
updateWorkReportUseCase.execute(request.toDomainRequest())
}

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

import com.kodomo.juganbbojjak.domain.work_report.dto.CreateWeeklyWorkReportRequest
import org.jetbrains.annotations.NotNull
import java.time.LocalDate

data class CreateWeeklyWorkReportWebRequest(

@field:NotNull
val startDate: LocalDate,

@field:NotNull
val endDate: LocalDate,
) {

fun toDomainRequest() = CreateWeeklyWorkReportRequest(
startDate = startDate,
endDate = endDate,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ class SecurityConfig(
.requestMatchers(HttpMethod.POST, "/event_schedules/{weekly-event-schedule-id}").hasAuthority(USER.name)
.requestMatchers(HttpMethod.GET, "/event_schedules/{weekly-event-schedule-id}").hasAnyAuthority(ADMIN.name, USER.name)
.requestMatchers(HttpMethod.PUT, "/event_schedules/{event-schedule-id}").hasAnyAuthority(ADMIN.name, USER.name)
.requestMatchers(HttpMethod.POST, "/event_schedules").hasAuthority(ADMIN.name)

.requestMatchers(HttpMethod.POST, "/work_report/{weekly-work-report-id}").hasAuthority(USER.name)
.requestMatchers(HttpMethod.GET, "/work_report/{weekly-work-report-id}").hasAnyAuthority(USER.name, ADMIN.name)
.requestMatchers(HttpMethod.POST, "/work_report").hasAuthority(ADMIN.name)

.requestMatchers(HttpMethod.GET, "/main").hasAnyAuthority(USER.name, ADMIN.name)
.requestMatchers(HttpMethod.GET, "/main/latest_work").hasAuthority(USER.name)
Expand Down
Loading