Skip to content

Commit

Permalink
works
Browse files Browse the repository at this point in the history
  • Loading branch information
Hummel009 committed Dec 11, 2024
1 parent 4371f92 commit 69e2af2
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ fun Application.configureRouting() {
val password = decomposedToken?.password

if (AuthService.areCredentialsValid(username, password)) {
val ids = request.cart.map { it.bookId }
val books = MainService.getAllBooks().filter { ids.contains(it.id) }
val bookIds = request.cart.map { it.bookId }
val books = MainService.getAllBooks().filter { bookIds.contains(it.id) }
val quantities = request.cart.map { it.quantity }

if (CartService.addUserOrder(userId, books, quantities)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ package com.github.hummel.mpp.course.dto.response
import com.github.hummel.mpp.course.entity.Book

data class OrderResponse(
val books: List<Book>,
val quantities: List<Int>
val books: List<Book>, val quantities: List<Int>
)
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ data class Order(val id: Int, val userId: Int, val orderItems: MutableList<Order
data class OrderItem(val id: Int, val orderId: Int, val bookId: Int, val quantity: Int)

fun toResponse(): OrderResponse {
val ids = orderItems.map { it.bookId }
val books = MainService.getAllBooks().filter { ids.contains(it.id) }
val bookIds = orderItems.map { it.bookId }
val books = MainService.getAllBooks().filter { bookIds.contains(it.id) }
val quantities = orderItems.map { it.quantity }

return OrderResponse(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.github.hummel.mpp.course.entity

data class Type(
val id: Int,
var name: String
val id: Int, var name: String
)

0 comments on commit 69e2af2

Please sign in to comment.