Compare commits
3 Commits
141f3e3b5d
...
h-hirane
| Author | SHA1 | Date | |
|---|---|---|---|
| 0f1d80267c | |||
| 2c56f6f272 | |||
| 4025abe126 |
@@ -1,11 +1,13 @@
|
|||||||
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;
|
||||||
|
|
||||||
|
|
||||||
@@ -18,19 +20,12 @@ 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,7 +4,6 @@ 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;
|
||||||
@@ -17,18 +16,6 @@ public class BookLendService {
|
|||||||
|
|
||||||
public List<BookLend> findAll() {
|
public List<BookLend> findAll() {
|
||||||
return bookLendRepository.findAll();
|
return bookLendRepository.findAll();
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public void regist(Integer lendId) {
|
|
||||||
|
|
||||||
BookLend booklend = bookLendRepository.findById(lendId).orElse(null);
|
|
||||||
|
|
||||||
booklend.setBookStatus(0);
|
|
||||||
|
|
||||||
bookLendRepository.save(booklend);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,7 +78,7 @@
|
|||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr th:each="book : ${book}" th:if="${book.bookManageId != null && book.isDeleted != 1}">
|
<tr th:each="book : ${book}" th:if="${book.bookManageId != null}">
|
||||||
|
|
||||||
<td th:hidden="*{book.bookId}"></td>
|
<td th:hidden="*{book.bookId}"></td>
|
||||||
<td th:text="*{book.bookManageId}"></td>
|
<td th:text="*{book.bookManageId}"></td>
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
<!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,6 +10,10 @@
|
|||||||
<body>
|
<body>
|
||||||
<h1>貸出中図書一覧</h1>
|
<h1>貸出中図書一覧</h1>
|
||||||
|
|
||||||
|
<!-- action先要修正 -->
|
||||||
|
<form action="/lendList" method="GET">
|
||||||
|
<input type="submit" value="返却" class="btn">
|
||||||
|
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
|
|
||||||
@@ -20,7 +24,7 @@
|
|||||||
<th>管理ID</th>
|
<th>管理ID</th>
|
||||||
<th>タイトル</th>
|
<th>タイトル</th>
|
||||||
<th>返却予定日</th>
|
<th>返却予定日</th>
|
||||||
|
<th>超過日数</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
@@ -33,30 +37,42 @@
|
|||||||
<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>
|
||||||
|
|
||||||
|
|
||||||
<script>
|
</form>
|
||||||
|
|
||||||
function MoveCheck() {
|
<!-- 以下ポップアップ -->
|
||||||
return window.confirm("返却処理を実行します。よろしいですか?");
|
<div id="registerModal" class="modal-overlay">
|
||||||
}
|
|
||||||
|
<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