3 Commits

9 changed files with 265 additions and 41 deletions

View File

@@ -36,7 +36,7 @@ public class AdminLoanController {
public String approvalConfirm(@PathVariable Integer id, Model model, RedirectAttributes ra) {
try {
model.addAttribute("r", loanService.getView(id, Const.STATUS_WAITING));
return "approvalConfirm";
return "approvalConfilm";
} catch (BusinessException e) {
ra.addFlashAttribute("errorMessage", e.getMessage());
return "redirect:/admin/applications";
@@ -49,7 +49,7 @@ public class AdminLoanController {
try {
loanService.approve(id, admin);
ra.addFlashAttribute("message", "書籍貸出申請を承認しました。");
return "redirect:/admin/approval/complete";
return "approvalComplete";
} catch (BusinessException e) {
ra.addFlashAttribute("errorMessage", e.getMessage());
return "redirect:/admin/applications";
@@ -62,7 +62,7 @@ public class AdminLoanController {
try {
loanService.reject(id, admin);
ra.addFlashAttribute("message", "書籍貸出申請を却下しました。");
return "redirect:/admin/approval/complete";
return "approvalRejected";
} catch (BusinessException e) {
ra.addFlashAttribute("errorMessage", e.getMessage());
return "redirect:/admin/applications";

View File

@@ -1,5 +1,33 @@
package com.example.demo.controller;
public class BookController {
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.service.BookService;
/** BOOK-01:書籍検索(bookList.html) */
@Controller
public class BookController {
private final BookService bookService;
public BookController(BookService bookService) {
this.bookService = bookService;
}
/** メニューの「書籍一覧」=条件なし(全件)、検索ボタン=条件付きで同じURLを使う */
@GetMapping("/books")
public String list(@RequestParam(defaultValue = "") String nmBook,
@RequestParam(defaultValue = "") String publisher,
@RequestParam(defaultValue = "") String note,
Model model) {
model.addAttribute("books", bookService.searchLendable(nmBook, publisher, note));
// 検索条件を保持
model.addAttribute("nmBook", nmBook);
model.addAttribute("publisher", publisher);
model.addAttribute("note", note);
return "bookList";
}
}

View File

@@ -1,37 +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>
<table>
<!-- エラーメッセージ -->
<div class="msgBox error" th:if="${messageError != null}">
<span class="error" th:text="${messageError.message}"></span>
<th class="header">蔵書ID</th>
<td>
<input placeholder="蔵書ID" th:field="*{id_book}" type="number" />
</td>
<th class="header">書籍名</th>
<td>
<input placeholder="蔵書ID" th:field="*{nm_book}" type="text" />
</td>
<th class="header">貸出日</th>
<td>
<input placeholder="貸出日" th:field="*{date_borrow}" type="text" />
</td>
<th class="header">返却予定日</th>
<td>
<input placeholder="返却予定日" th:field="*{date_schedule_return}" type="text" />
</td>
<a href="applicationComplete/html" class="btn"> 申請</a>
</table>
<a href="@{/application}">申請情報入力</a>
</body>
</html>

View File

@@ -0,0 +1,42 @@
<!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>
<div th:replace="~{fragments/header :: header}"></div>
<main>
<h1>書籍情報確認</h1>
<div class="card">
<h2 th:text="${title}">書籍登録</h2>
<table>
<tr><th>ISBN</th><td th:text="${form.isbn}"></td></tr>
<tr><th>書籍名</th><td th:text="${form.nmBook}"></td></tr>
<tr><th>書籍名よみ</th><td th:text="${form.knBook}"></td></tr>
<tr><th>出版社</th><td th:text="${form.publisher}"></td></tr>
<tr><th>特記事項</th><td th:text="${form.note}"></td></tr>
</table>
<form th:action="@{${base + '/execute'}}" method="post" style="display:inline">
<input type="hidden" name="idBook" th:value="${form.idBook}">
<input type="hidden" name="isbn" th:value="${form.isbn}">
<input type="hidden" name="nmBook" th:value="${form.nmBook}">
<input type="hidden" name="knBook" th:value="${form.knBook}">
<input type="hidden" name="publisher" th:value="${form.publisher}">
<input type="hidden" name="note" th:value="${form.note}">
<button type="submit" th:text="${title == '書籍登録'} ? '登録' : '編集'">登録</button>
</form>
<form th:action="@{${base + '/input'}}" method="post" style="display:inline">
<input type="hidden" name="idBook" th:value="${form.idBook}">
<input type="hidden" name="isbn" th:value="${form.isbn}">
<input type="hidden" name="nmBook" th:value="${form.nmBook}">
<input type="hidden" name="knBook" th:value="${form.knBook}">
<input type="hidden" name="publisher" th:value="${form.publisher}">
<input type="hidden" name="note" th:value="${form.note}">
<button type="submit" class="sub">書籍情報入力に戻る</button>
</form>
</div>
</main>
</body>
</html>

View File

@@ -0,0 +1,34 @@
<!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>
<div th:replace="~{fragments/header :: header}"></div>
<main>
<h1>書籍情報入力</h1>
<div class="error" th:if="${errorMessage}" th:text="${errorMessage}"></div>
<div class="error" th:each="e : ${errors}" th:text="${e}"></div>
<div class="card">
<h2 th:text="${title}">書籍登録</h2>
<form th:action="@{${base + '/confirm'}}" method="post">
<input type="hidden" name="idBook" th:value="${form.idBook}">
<label for="isbn">ISBN(必須・13文字以内)</label>
<input type="text" id="isbn" name="isbn" th:value="${form.isbn}" maxlength="13">
<label for="nmBook">書籍名(必須・50文字以内)</label>
<input type="text" id="nmBook" name="nmBook" th:value="${form.nmBook}" maxlength="50">
<label for="knBook">書籍名よみ(100文字以内)</label>
<input type="text" id="knBook" name="knBook" th:value="${form.knBook}" maxlength="100">
<label for="publisher">出版社(50文字以内)</label>
<input type="text" id="publisher" name="publisher" th:value="${form.publisher}" maxlength="50">
<label for="note">特記事項</label>
<input type="text" id="note" name="note" th:value="${form.note}">
<p><button type="submit" th:text="${title} + '確認'">確認</button>
<a class="btn sub" th:href="@{/books}">書籍一覧に戻る</a></p>
</form>
</div>
</main>
</body>
</html>

View File

@@ -0,0 +1,67 @@
<!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>
<div th:replace="~{fragments/header :: header}"></div>
<main>
<h1>書籍一覧</h1>
<div class="error" th:if="${errorMessage}" th:text="${errorMessage}"></div>
<div class="card">
<form th:action="@{/books}" method="get">
<label for="nmBook">書籍名</label>
<input type="text" id="nmBook" name="nmBook" th:value="${nmBook}">
<label for="publisher">出版社</label>
<input type="text" id="publisher" name="publisher" th:value="${publisher}">
<label for="note">特記事項</label>
<input type="text" id="note" name="note" th:value="${note}">
<p><button type="submit">検索</button>
<a class="btn sub" th:href="@{/menu}">メニューに戻る</a>
<a class="btn" th:if="${session.loginUser.admin}" th:href="@{/admin/books/new}">書籍新規登録</a>
</p>
</form>
</div>
<div class="card">
<h2>検索結果</h2>
<p th:if="${#lists.isEmpty(books)}">該当する書籍はありません。</p>
<table th:unless="${#lists.isEmpty(books)}">
<thead>
<tr>
<th>蔵書ID</th>
<th>ISBN</th>
<th>書籍名</th>
<th>書籍名よみ</th>
<th>出版社</th>
<th>特記事項</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr th:each="b : ${books}">
<td th:text="${b.idBook}"></td>
<td th:text="${b.isbn}"></td>
<td th:text="${b.nmBook}"></td>
<td th:text="${b.knBook}"></td>
<td th:text="${b.publisher}"></td>
<td th:text="${b.note}"></td>
<td>
<!-- 一般:貸出申請(LOAN-01) / 管理者:編集(BOOK-03) -->
<a class="btn" th:unless="${session.loginUser.admin}"
th:href="@{/loan/apply(idBook=${b.idBook})}">貸出申請</a>
<a class="btn" th:if="${session.loginUser.admin}"
th:href="@{/admin/books/edit(idBook=${b.idBook})}">編集</a>
</td>
</tr>
</tbody>
</table>
</div>
</main>
</body>
</html>

View File

@@ -0,0 +1,19 @@
<!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>
<div th:replace="~{fragments/header :: header}"></div>
<main>
<h1>完了</h1>
<div class="info" th:text="${message} ?: '処理が完了しました。'"></div>
<p>
<a class="btn" th:href="@{${backUrl}}" th:text="${backLabel}">戻る</a>
<a class="btn sub" th:href="@{/menu}">メニューに戻る</a>
</p>
</main>
</body>
</html>

View File

@@ -0,0 +1,38 @@
<!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>
<div th:replace="~{fragments/header :: header}"></div>
<main>
<h1>書籍貸出申請確認</h1>
<div class="card">
<table>
<tr><th>書籍名</th><td th:text="${book.nmBook}"></td></tr>
<tr><th>ISBN</th><td th:text="${book.isbn}"></td></tr>
<tr><th>出版社</th><td th:text="${book.publisher}"></td></tr>
<tr><th>特記事項</th><td th:text="${book.note}"></td></tr>
</table>
<table>
<tr><th>貸出日</th><td th:text="${dateBorrow}"></td></tr>
<tr><th>返却予定日</th><td th:text="${dateScheduledReturn}"></td></tr>
</table>
<form th:action="@{/loan/apply/execute}" method="post" style="display:inline">
<input type="hidden" name="idBook" th:value="${idBook}">
<input type="hidden" name="dateBorrow" th:value="${dateBorrow}">
<input type="hidden" name="dateScheduledReturn" th:value="${dateScheduledReturn}">
<button type="submit">申請</button>
</form>
<form th:action="@{/loan/apply/input}" method="post" style="display:inline">
<input type="hidden" name="idBook" th:value="${idBook}">
<input type="hidden" name="dateBorrow" th:value="${dateBorrow}">
<input type="hidden" name="dateScheduledReturn" th:value="${dateScheduledReturn}">
<button type="submit" class="sub">申請情報入力に戻る</button>
</form>
</div>
</main>
</body>
</html>

View File

@@ -0,0 +1,33 @@
<!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>
<div th:replace="~{fragments/header :: header}"></div>
<main>
<h1>書籍貸出申請</h1>
<div class="error" th:if="${errorMessage}" th:text="${errorMessage}"></div>
<div class="error" th:each="e : ${errors}" th:text="${e}"></div>
<div class="card">
<table>
<tr><th>書籍名</th><td th:text="${book.nmBook}"></td></tr>
<tr><th>ISBN</th><td th:text="${book.isbn}"></td></tr>
<tr><th>出版社</th><td th:text="${book.publisher}"></td></tr>
<tr><th>特記事項</th><td th:text="${book.note}"></td></tr>
</table>
<form th:action="@{/loan/apply/confirm}" method="post">
<input type="hidden" name="idBook" th:value="${idBook}">
<label for="dateBorrow">貸出日</label>
<input type="date" id="dateBorrow" name="dateBorrow" th:value="${dateBorrow}">
<label for="dateScheduledReturn">返却予定日</label>
<input type="date" id="dateScheduledReturn" name="dateScheduledReturn" th:value="${dateScheduledReturn}">
<p><button type="submit">申請確認</button>
<a class="btn sub" th:href="@{/books}">書籍一覧に戻る</a></p>
</form>
</div>
</main>
</body>
</html>