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 a416702..b6e7b80 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.findAll(); + + + } + + @Transactional + public void regist(Integer lendId) { + + BookLend booklend = bookLendRepository.findById(lendId).orElse(null); + + booklend.setBookStatus(0); + + bookLendRepository.save(booklend); } } 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タイトル返却予定日超過日数
- - - - - -