Compare commits
1 Commits
y-watanabe
...
y-kumaki
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
441d91d1e2 |
@@ -1,13 +1,11 @@
|
|||||||
package com.example.demo.controller;
|
package com.example.demo.controller;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
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;
|
import com.example.demo.service.BookLendService;
|
||||||
|
|
||||||
|
|
||||||
@@ -20,12 +18,19 @@ public class LendListController {
|
|||||||
@GetMapping("/lendList")
|
@GetMapping("/lendList")
|
||||||
public String list(Model model) {
|
public String list(Model model) {
|
||||||
|
|
||||||
List<BookLend> aaa = lendlistService.findAll();
|
|
||||||
|
|
||||||
// findAllを使って、DBから一覧を取得 でバックで取得したのを確認
|
// findAllを使って、DBから一覧を取得 でバックで取得したのを確認
|
||||||
model.addAttribute("list",lendlistService.findAll());
|
model.addAttribute("list",lendlistService.findAll());
|
||||||
|
|
||||||
return "lendList";
|
return "lendList";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/return-book")
|
||||||
|
public String retun(@RequestParam(name="lendId") int returnBook){
|
||||||
|
|
||||||
|
lendlistService.regist(returnBook);
|
||||||
|
|
||||||
|
|
||||||
|
return "bookLendResult";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import com.example.demo.entity.BookLend;
|
import com.example.demo.entity.BookLend;
|
||||||
import com.example.demo.repository.BookLendRepository;
|
import com.example.demo.repository.BookLendRepository;
|
||||||
@@ -16,6 +17,18 @@ public class BookLendService {
|
|||||||
|
|
||||||
public List<BookLend> findAll() {
|
public List<BookLend> findAll() {
|
||||||
return bookLendRepository.findBybookStatus(1);
|
return bookLendRepository.findBybookStatus(1);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void regist(Integer lendId) {
|
||||||
|
|
||||||
|
BookLend booklend = bookLendRepository.findById(lendId).orElse(null);
|
||||||
|
|
||||||
|
booklend.setBookStatus(0);
|
||||||
|
|
||||||
|
bookLendRepository.save(booklend);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
20
src/main/resources/templates/bookLendResult.html
Normal file
20
src/main/resources/templates/bookLendResult.html
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>貸出中図書、返却処理結果画面</title>
|
||||||
|
<link rel="stylesheet" th:href="@{/css/style.css}">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h1>返却処理が完了しました。</h1>
|
||||||
|
|
||||||
|
<td>
|
||||||
|
<form th:action="@{/lendList}" method="get">
|
||||||
|
<button type="submit" th:value="貸出">貸出中図書一覧に戻る</button>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@@ -10,10 +10,6 @@
|
|||||||
<body>
|
<body>
|
||||||
<h1>貸出中図書一覧</h1>
|
<h1>貸出中図書一覧</h1>
|
||||||
|
|
||||||
<!-- action先要修正 -->
|
|
||||||
<form action="/lendList" method="GET">
|
|
||||||
<input type="submit" value="返却" class="btn">
|
|
||||||
|
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
|
|
||||||
@@ -24,7 +20,7 @@
|
|||||||
<th>管理ID</th>
|
<th>管理ID</th>
|
||||||
<th>タイトル</th>
|
<th>タイトル</th>
|
||||||
<th>返却予定日</th>
|
<th>返却予定日</th>
|
||||||
<th>超過日数</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
@@ -37,42 +33,30 @@
|
|||||||
<td th:text="*{booklist.book.bookManageId}"></td>
|
<td th:text="*{booklist.book.bookManageId}"></td>
|
||||||
<td th:text="*{booklist.book.title}"></td>
|
<td th:text="*{booklist.book.title}"></td>
|
||||||
<td th:text="*{booklist.bookReturnDate}"></td>
|
<td th:text="*{booklist.bookReturnDate}"></td>
|
||||||
<!-- <td th:text="*{booklist.}"></td>-->
|
|
||||||
|
|
||||||
|
<td>
|
||||||
|
<form th:action="@{/return-book}" method="get">
|
||||||
|
<button type="submit" name="lendId" th:value="${booklist.lendId}"
|
||||||
|
onclick="return MoveCheck();">返却
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
||||||
</form>
|
<script>
|
||||||
|
|
||||||
<!-- 以下ポップアップ -->
|
function MoveCheck() {
|
||||||
<div id="registerModal" class="modal-overlay">
|
return window.confirm("返却処理を実行します。よろしいですか?");
|
||||||
|
}
|
||||||
<div class="modal">
|
|
||||||
|
|
||||||
<div class="modal-message">
|
|
||||||
返却処理が完了しました!
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="modal-buttons">
|
|
||||||
|
|
||||||
<!-- OK -->
|
|
||||||
<form method="get" action="/lendList">
|
|
||||||
|
|
||||||
<button type="submit" class="modal-btn">
|
|
||||||
OK
|
|
||||||
</button>
|
|
||||||
|
|
||||||
</form>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user