From a171b3f55dc975d114ab5e12c5346443bb1c5116 Mon Sep 17 00:00:00 2001 From: Victoria Date: Thu, 7 Mar 2024 15:19:27 +0100 Subject: [PATCH] #14 setup approveReceipt in AdminController but not tested --- .../com/example/autobank/controller/AdminController.kt | 2 +- .../com/example/autobank/service/ReceiptReviewService.kt | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/example/autobank/controller/AdminController.kt b/src/main/kotlin/com/example/autobank/controller/AdminController.kt index d455ccb..e640de4 100644 --- a/src/main/kotlin/com/example/autobank/controller/AdminController.kt +++ b/src/main/kotlin/com/example/autobank/controller/AdminController.kt @@ -50,7 +50,7 @@ class AdminController(@Autowired val adminService: AdminService, @Autowired val val receiptReview = receiptReviewService.getReceiptReview(approveReceiptBody.receipt) receiptReviewService.updateReceiptReviewByStatus(receiptReview, approveReceiptBody.status) }else { - receiptReviewService.addReceiptReview() + receiptReviewService.createReceiptReview(status = approveReceiptBody.status, receipt = approveReceiptBody.receipt, user = approveReceiptBody.user, description = approveReceiptBody.description) } } } diff --git a/src/main/kotlin/com/example/autobank/service/ReceiptReviewService.kt b/src/main/kotlin/com/example/autobank/service/ReceiptReviewService.kt index ee2d3ad..1055830 100644 --- a/src/main/kotlin/com/example/autobank/service/ReceiptReviewService.kt +++ b/src/main/kotlin/com/example/autobank/service/ReceiptReviewService.kt @@ -7,6 +7,7 @@ import com.example.autobank.repository.ReceiptRepository import com.example.autobank.repository.ReceiptReviewRepository import jakarta.transaction.Status import org.springframework.stereotype.Service +import java.time.LocalDateTime @Service class ReceiptReviewService(private val repository: ReceiptReviewRepository) { @@ -20,8 +21,9 @@ class ReceiptReviewService(private val repository: ReceiptReviewRepository) { } fun createReceiptReview(status: Boolean, user: OnlineUser, description: String, receipt: Receipt){ - // val receiptReview = ReceiptReview( recieptId = receipt.id, date = "2017-01-13T17:09:42.4100000", d ) - //repository.save(receiptReview) + val dato = LocalDateTime.now() + val receiptReview = ReceiptReview( receiptReviewId = -1, recieptId = receipt.id, date = dato, adminID = user.onlineId, description = description, status = status ) + repository.save(receiptReview) } fun updateReceiptReviewByStatus(receiptReview: ReceiptReview, status: Boolean){