Controller・Repository・bookList修正・編集

This commit is contained in:
2026-10-23 13:06:03 +09:00
parent 6885633be3
commit db40c5e558
3 changed files with 10 additions and 10 deletions

View File

@@ -45,13 +45,7 @@ public class SelectBookController {
@RequestMapping(value = "/selectBook", method = RequestMethod.GET) @RequestMapping(value = "/selectBook", method = RequestMethod.GET)
public String selectBook(Model model) { public String selectBook(Model model) {
try { try {
// LoginUser loginUser = (LoginUser) httpsession.getAttribute("loginUser"); //貸出可能な書籍を全て取得
//
// //ログイン情報が存在しない場合はログイン画面へ
// if(loginUser == null) {
// return "/login";
// }
// //貸出可能な書籍を全て取得
List<Book_collectionEntity> books = returnService.availableSelectAll(); List<Book_collectionEntity> books = returnService.availableSelectAll();
//取得した書籍情報をModelに登録する //取得した書籍情報をModelに登録する

View File

@@ -13,13 +13,14 @@ import com.example.demo.entity.Book_collectionEntity;
public interface Book_CollectionRepository extends JpaRepository<Book_collectionEntity, Integer> { public interface Book_CollectionRepository extends JpaRepository<Book_collectionEntity, Integer> {
//JpaRepositoruを継承することで基本的なDB操作が使用できる //JpaRepositoruを継承することで基本的なDB操作が使用できる
//Book_collctionEntity:操作するEntity //Book_collctionEntity:操作するEntity
//Integer: Entity の主キーの方 //Integer: Entity の主キーの"id_book"の型
List<Book_collectionEntity> findByFlgLending(Character flgLending); List<Book_collectionEntity> findByFlgLending(Character flgLending);
// [ b.noteText ] …Entityのフィールドを表す // [ b.noteText ] …Entityのフィールドを表す
// [ :noteText ]…Javaから渡された検索条件を表す。ユーザが入力した(Java)などの文字列が入る // [ :noteText ]…Javaから渡された検索条件を表す。ユーザが入力した(Java)などの文字列が入る
// [:]…JPQLでは、名前付きパラメータを指定するときに、名前の前に : を付け // [:]…JPQLでは、名前付きパラメータを指定するときに、名前の前に : を付け
//    └[ : ] 以降の名前は @Param("noteText") の名前と一致させる
@Query(""" @Query("""
SELECT b FROM Book_collectionEntity b SELECT b FROM Book_collectionEntity b
@@ -40,6 +41,8 @@ public interface Book_CollectionRepository extends JpaRepository<Book_collection
//検索結果はBook_collectionEntityのListで返す //検索結果はBook_collectionEntityのListで返す
List<Book_collectionEntity> searchBooks( List<Book_collectionEntity> searchBooks(
//入力された書籍名をJPQLの:nmBookに返す //入力された書籍名をJPQLの:nmBookに返す
// [:]…JPQLでは、名前付きパラメータを指定するときに、名前の前に : を付け
//    └[ : ] 以降の名前は @Param("noteText") の名前と一致させる
@Param("nmBook") String nmBook, @Param("nmBook") String nmBook,
@Param("pubLisher") String pubLisher, @Param("pubLisher") String pubLisher,
@Param("noteText") String noteText); @Param("noteText") String noteText);

View File

@@ -12,7 +12,7 @@
<!--ログアウトボタン--> <!--ログアウトボタン-->
<a href="@{/logout}">ログアウト</a> <a href="@{/logout}">ログアウト</a>
<h2>書籍一覧・検索</h2> <h1>書籍一覧・検索</h1>
<!-- 検索条件をControllerの/selectBookへPOST送信--> <!-- 検索条件をControllerの/selectBookへPOST送信-->
<!--bookSearchFormはControllerから渡されるForm--> <!--bookSearchFormはControllerから渡されるForm-->
<!--Controllerと@{/selectBook}合わせる--> <!--Controllerと@{/selectBook}合わせる-->
@@ -44,11 +44,14 @@
<!-- 検索ボタン--> <!-- 検索ボタン-->
<button type="submit">検索</button> <button type="submit">検索</button>
</form> </form>
<!-- メニュー画面へ戻るリンク--> <!-- メニュー画面へ戻るリンク-->
<a th:href="@{/menu}">メニューに戻る </a> <a th:href="@{/menu}">メニューに戻る </a>
<h3>検索結果</h3> <h3>検索結果</h3>
<!--検索結果を表示するテーブル--> <!--検索結果を表示するテーブル-->
<!-- border ="1"は表のセルを区切るための線を表示-->
<table border="1"> <table border="1">
<thead> <thead>
<tr> <tr>