Compare commits
3 Commits
141f3e3b5d
...
h-hirane
| Author | SHA1 | Date | |
|---|---|---|---|
| 0f1d80267c | |||
| 2c56f6f272 | |||
| 4025abe126 |
@@ -1,11 +1,13 @@
|
||||
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;
|
||||
|
||||
|
||||
@@ -18,19 +20,12 @@ public class LendListController {
|
||||
@GetMapping("/lendList")
|
||||
public String list(Model model) {
|
||||
|
||||
List<BookLend> 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";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ 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;
|
||||
@@ -17,18 +16,6 @@ public class BookLendService {
|
||||
|
||||
public List<BookLend> 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>
|
||||
|
||||
<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: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,53 +10,69 @@
|
||||
<body>
|
||||
<h1>貸出中図書一覧</h1>
|
||||
|
||||
|
||||
<!-- action先要修正 -->
|
||||
<form action="/lendList" method="GET">
|
||||
<input type="submit" value="返却" class="btn">
|
||||
|
||||
|
||||
<table>
|
||||
|
||||
<thead>
|
||||
<tr>
|
||||
<th>社員ID</th>
|
||||
<th>社員名</th>
|
||||
<th>管理ID</th>
|
||||
<th>タイトル</th>
|
||||
<th>返却予定日</th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
|
||||
<tbody>
|
||||
<tr th:each="booklist : ${list}">
|
||||
|
||||
<td th:text="*{booklist.employeeBooklend.employeeId}"></td>
|
||||
<td th:text="*{booklist.employeeBooklend.employeeName}"></td>
|
||||
<td th:text="*{booklist.book.bookManageId}"></td>
|
||||
<td th:text="*{booklist.book.title}"></td>
|
||||
<td th:text="*{booklist.bookReturnDate}"></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>
|
||||
|
||||
</tbody>
|
||||
|
||||
<thead>
|
||||
<tr>
|
||||
<th>社員ID</th>
|
||||
<th>社員名</th>
|
||||
<th>管理ID</th>
|
||||
<th>タイトル</th>
|
||||
<th>返却予定日</th>
|
||||
<th>超過日数</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
|
||||
<tbody>
|
||||
<tr th:each="booklist : ${list}">
|
||||
|
||||
<td th:text="*{booklist.employeeBooklend.employeeId}"></td>
|
||||
<td th:text="*{booklist.employeeBooklend.employeeName}"></td>
|
||||
<td th:text="*{booklist.book.bookManageId}"></td>
|
||||
<td th:text="*{booklist.book.title}"></td>
|
||||
<td th:text="*{booklist.bookReturnDate}"></td>
|
||||
<!-- <td th:text="*{booklist.}"></td>-->
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
<!-- 以下ポップアップ -->
|
||||
<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>
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
function MoveCheck() {
|
||||
return window.confirm("返却処理を実行します。よろしいですか?");
|
||||
}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user