6 Commits

6 changed files with 77 additions and 88 deletions

View File

@@ -47,13 +47,15 @@ private BookInsertRepository bookInsertRepository;
// 初期表示: 空のformを渡す(th:fieldの初期値が空になる)
// 確認画面から戻る: POSTされた入力中の値がformに入ったまま入力画面へ
//入力内容確認してOKであれば確認画面へ
@PostMapping("/bookInsertConfirm")
public String bookInsertConfirm(@Validated BookInsert bookInsert, BindingResult result, Model model) {
if (result.hasErrors()) {
model.addAttribute("nextBookManageId", bookInsertService.createBookManageId());
model.addAttribute("categoryList", categoryRepository.findAll());
if (bookInsert.getBookCategoryId() != null) { //nullじゃなかったら
model.addAttribute("subCategoryList",subCategoryRepository.findByBookCategory_BookCategoryId(bookInsert.getBookCategoryId()));
model.addAttribute("subCategoryList",
subCategoryRepository.findByBookCategory_BookCategoryId(bookInsert.getBookCategoryId()));
//そのカテゴリに属するサブカテゴリを持ってくる
} else {
model.addAttribute("subCategoryList", subCategoryRepository.findAll());
@@ -68,27 +70,18 @@ private BookInsertRepository bookInsertRepository;
return "bookInsertConfirm";
}
//確認画面から「もどる」ボタンを押したら入力画面に戻る
@PostMapping("/bookInsert")
public String bookInsertBack(BookInsert bookInsert,Model model) {
model.addAttribute("nextBookManageId",bookInsertService.createBookManageId());
model.addAttribute("categoryList",categoryRepository.findAll());
if(bookInsert.getBookCategoryId() !=null) {
model.addAttribute("subCategoryList",subCategoryRepository.findByBookCategory_BookCategoryId(bookInsert.getBookCategoryId()));
} else{
model.addAttribute("subCategoryList",subCategoryRepository.findAll());
}
model.addAttribute("locationList",storageLocationRepository.findAll());
model.addAttribute("bookInsert",bookInsert);
return "bookInsert";
}
@PostMapping("/bookInsert/category")
public String changeCategory(BookInsert bookInsert, Model model) {
//カテゴリプルダウンに表示するデータを取得
model.addAttribute("nextBookManageId", bookInsertService.createBookManageId());
model.addAttribute("categoryList", categoryRepository.findAll());
model.addAttribute("subCategoryList",subCategoryRepository.findByBookCategory_BookCategoryId(bookInsert.getBookCategoryId()));
if (bookInsert.getBookCategoryId() != null) { //nullじゃなかったら
model.addAttribute("subCategoryList",
subCategoryRepository.findByBookCategory_BookCategoryId(bookInsert.getBookCategoryId()));
//そのカテゴリに属するサブカテゴリを持ってくる
} else {
model.addAttribute("subCategoryList", subCategoryRepository.findAll());
}
model.addAttribute("locationList", storageLocationRepository.findAll());
model.addAttribute("bookInsert", bookInsert);
@@ -97,13 +90,7 @@ private BookInsertRepository bookInsertRepository;
}
//画面で選択したカテゴリbookInsert.getBookCategoryId()に選択した結果をいれる
//subCategoryRepository.findBookCategory_BookCategoryId(bookInsert.getBookCategoryId(1)));
//「カテゴリIDが1のサブカテゴリを取ってくる」
//model.addAttribute("subCategoryList",取得結果)

View File

@@ -74,7 +74,7 @@ public class LoginController {
AccountEntity accountEntity = loginService.login(loginForm);
if (accountEntity == null) {
model.addAttribute("loginError",
"社員IDまたはパスワードが正しくありません");
"ログインIDまたはパスワードが正しくありません");
return "login";
}

View File

@@ -1,5 +1,7 @@
package com.example.demo.repository;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@@ -8,4 +10,6 @@ import com.example.demo.entity.BookLend;
@Repository
public interface BookLendRepository extends JpaRepository<BookLend, Integer> {
List<BookLend> findBybookStatus(Integer bookStatus);
}

View File

@@ -15,7 +15,7 @@ public class BookLendService {
private BookLendRepository bookLendRepository;
public List<BookLend> findAll() {
return bookLendRepository.findAll();
return bookLendRepository.findBybookStatus(1);
}
}

View File

@@ -4,7 +4,6 @@
<head>
<meta charset="UTF-8">
<title>ログイン</title>
</head>
<body>
@@ -17,7 +16,7 @@
<form th:action="@{/login}" th:object="${loginForm}" method="post">
<div class="form-group">
<label for="employeeId">社員ID</label>
<input id="employeeId" type="text" th:field="*{employeeId}"pattern="^[0-9]+$"title="数値以外は入力しないでください">
<input id="employeeId" type="text" th:field="*{employeeId}">
<p class="field-error" th:errors="*{employeeId}"></p>
</div>

View File

@@ -97,7 +97,6 @@
</a>
<hr>
</th>
<a class="card" href="/passwordChange">
<h3>パスワード変更</h3>
@@ -106,7 +105,7 @@
初期パスワードを<br> 変更します。
</p>
</a>
</th>
</body>