Skip to content

Commit

Permalink
Edit order service to use checkAccessible
Browse files Browse the repository at this point in the history
  • Loading branch information
Ji-InPark committed May 12, 2024
1 parent a3656b8 commit 61a48a3
Showing 1 changed file with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ class OrderService(
endDate: String?,
status: String?
): List<Order> {
val workspace = workspaceService.getWorkspace(workspaceId)
if (workspace.owner.loginId != username) throw WorkspaceInaccessibleException()
checkAccessible(username, workspaceId)

val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd")
val parsedStartDate = startDate?.let { LocalDate.parse(it, formatter).atStartOfDay() }
Expand All @@ -116,8 +115,7 @@ class OrderService(
}

fun payOrder(username: String, workspaceId: Long, orderId: Long): Order {
val workspace = workspaceService.getWorkspace(workspaceId)
if (workspace.owner.loginId != username) throw WorkspaceInaccessibleException()
checkAccessible(username, workspaceId)

val order = orderRepository.findById(orderId).get()
order.status = OrderStatus.PAID
Expand All @@ -129,8 +127,7 @@ class OrderService(
}

fun getRealtimeOrders(username: String, workspaceId: Long): List<Order> {
val workspace = workspaceService.getWorkspace(workspaceId)
if (workspace.owner.loginId != username) throw WorkspaceInaccessibleException()
checkAccessible(username, workspaceId)

val startDate = LocalDateTime.now().minusHours(2)
val endDate = LocalDateTime.now()
Expand Down

0 comments on commit 61a48a3

Please sign in to comment.