From 441d91d1e2c92ff6e31b73be0ee58393048e3145 Mon Sep 17 00:00:00 2001 From: y-kumaki <2026_04_00501@it-college.co.jp> Date: Tue, 29 Sep 2026 13:44:21 +0900 Subject: [PATCH] =?UTF-8?q?[ADD]=20=E8=B2=B8=E5=87=BA=E4=B8=AD=E5=9B=B3?= =?UTF-8?q?=E6=9B=B8=E4=B8=80=E8=A6=A7=E3=81=AE=E8=BF=94=E5=8D=B4=E5=87=A6?= =?UTF-8?q?=E7=90=86=E3=82=92=E8=BF=BD=E5=8A=A0=E3=81=97=E3=81=BE=E3=81=97?= =?UTF-8?q?=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../demo/controller/LendListController.java | 15 ++- .../example/demo/service/BookLendService.java | 13 +++ .../resources/templates/bookLendResult.html | 20 ++++ src/main/resources/templates/lendList.html | 96 ++++++++----------- 4 files changed, 83 insertions(+), 61 deletions(-) create mode 100644 src/main/resources/templates/bookLendResult.html diff --git a/src/main/java/com/example/demo/controller/LendListController.java b/src/main/java/com/example/demo/controller/LendListController.java index 981e7ac..223beb5 100644 --- a/src/main/java/com/example/demo/controller/LendListController.java +++ b/src/main/java/com/example/demo/controller/LendListController.java @@ -1,13 +1,11 @@ package com.example.demo.controller; -import java.util.List; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; -import com.example.demo.entity.BookLend; import com.example.demo.service.BookLendService; @@ -20,12 +18,19 @@ public class LendListController { @GetMapping("/lendList") public String list(Model model) { - List aaa = lendlistService.findAll(); - // findAllを使って、DBから一覧を取得 でバックで取得したのを確認 model.addAttribute("list",lendlistService.findAll()); return "lendList"; } + + @GetMapping("/return-book") + public String retun(@RequestParam(name="lendId") int returnBook){ + + lendlistService.regist(returnBook); + + + return "bookLendResult"; +} } diff --git a/src/main/java/com/example/demo/service/BookLendService.java b/src/main/java/com/example/demo/service/BookLendService.java index 1188085..cef2ebb 100644 --- a/src/main/java/com/example/demo/service/BookLendService.java +++ b/src/main/java/com/example/demo/service/BookLendService.java @@ -4,6 +4,7 @@ import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import com.example.demo.entity.BookLend; import com.example.demo.repository.BookLendRepository; @@ -16,6 +17,18 @@ public class BookLendService { public List findAll() { return bookLendRepository.findBybookStatus(1); + + + } + + @Transactional + public void regist(Integer lendId) { + + BookLend booklend = bookLendRepository.findById(lendId).orElse(null); + + booklend.setBookStatus(0); + + bookLendRepository.save(booklend); } } \ No newline at end of file diff --git a/src/main/resources/templates/bookLendResult.html b/src/main/resources/templates/bookLendResult.html new file mode 100644 index 0000000..5d21530 --- /dev/null +++ b/src/main/resources/templates/bookLendResult.html @@ -0,0 +1,20 @@ + + + + + + 貸出中図書、返却処理結果画面 + + + + +

返却処理が完了しました。

+ + +
+ + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/lendList.html b/src/main/resources/templates/lendList.html index 36b7f9d..d000161 100644 --- a/src/main/resources/templates/lendList.html +++ b/src/main/resources/templates/lendList.html @@ -10,69 +10,53 @@

貸出中図書一覧

- - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - -
社員ID社員名管理IDタイトル返却予定日
+ + + +
社員ID社員名管理IDタイトル返却予定日超過日数
- - - - - -