-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
408 additions
and
20 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
...ation/src/main/kotlin/team/comit/simtong/domain/schedule/dto/ChangeSpotScheduleRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package team.comit.simtong.domain.schedule.dto | ||
|
||
import java.time.LocalDate | ||
import java.util.UUID | ||
|
||
/** | ||
* | ||
* 지점 일정 변경 요청 정보를 전달하는 ChangeSpotScheduleRequest | ||
* | ||
* @author Chokyunghyeon | ||
* @date 2022/11/22 | ||
* @version 1.0.0 | ||
**/ | ||
data class ChangeSpotScheduleRequest( | ||
val scheduleId: UUID, | ||
|
||
val title: String, | ||
|
||
val startAt: LocalDate, | ||
|
||
val endAt: LocalDate | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...n/src/main/kotlin/team/comit/simtong/domain/schedule/usecase/ChangeSpotScheduleUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package team.comit.simtong.domain.schedule.usecase | ||
|
||
import team.comit.simtong.domain.schedule.dto.ChangeSpotScheduleRequest | ||
import team.comit.simtong.domain.schedule.exception.ScheduleNotFoundException | ||
import team.comit.simtong.domain.schedule.spi.CommandSchedulePort | ||
import team.comit.simtong.domain.schedule.spi.QuerySchedulePort | ||
import team.comit.simtong.domain.schedule.spi.ScheduleQueryUserPort | ||
import team.comit.simtong.domain.schedule.spi.ScheduleSecurityPort | ||
import team.comit.simtong.domain.user.exception.NotEnoughPermissionException | ||
import team.comit.simtong.domain.user.exception.UserNotFoundException | ||
import team.comit.simtong.domain.user.model.Authority | ||
import team.comit.simtong.global.annotation.UseCase | ||
|
||
/** | ||
* | ||
* 지점 일정 변경 기능을 담당하는 ChangeSpotScheduleUseCase | ||
* | ||
* @author Chokyunghyeon | ||
* @date 2022/11/22 | ||
* @version 1.0.0 | ||
**/ | ||
@UseCase | ||
class ChangeSpotScheduleUseCase( | ||
private val queryUserPort: ScheduleQueryUserPort, | ||
private val querySchedulePort: QuerySchedulePort, | ||
private val commandSchedulePort: CommandSchedulePort, | ||
private val securityPort: ScheduleSecurityPort | ||
) { | ||
|
||
fun execute(request: ChangeSpotScheduleRequest) { | ||
val currentUserId = securityPort.getCurrentUserId() | ||
|
||
val user = queryUserPort.queryUserById(currentUserId) | ||
?: throw UserNotFoundException.EXCEPTION | ||
|
||
val schedule = querySchedulePort.queryScheduleById(request.scheduleId) | ||
?: throw ScheduleNotFoundException.EXCEPTION | ||
|
||
if (user.spotId != schedule.spotId && user.authority != Authority.ROLE_SUPER) { | ||
throw NotEnoughPermissionException.EXCEPTION | ||
} | ||
|
||
commandSchedulePort.save( | ||
schedule.copy( | ||
title = request.title, | ||
startAt = request.startAt, | ||
endAt = request.endAt | ||
) | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.