SelectBookController・Book_CollectionRepository途中まで
This commit is contained in:
@@ -45,7 +45,7 @@ public class SelectBookController {
|
||||
|
||||
// ① 書籍一覧の初期表示
|
||||
|
||||
@RequestMapping(value ="/selectBook", method = RequestMethod.GET)
|
||||
@RequestMapping(value ="/selectBook", method = RequestMethod.POST)
|
||||
public String select(Model model) {
|
||||
try {
|
||||
//貸出可能な書籍を全権取得する
|
||||
|
||||
@@ -1,11 +1,35 @@
|
||||
package com.example.demo.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.example.demo.entity.Book_collectionEntity;
|
||||
|
||||
@Repository
|
||||
public interface Book_CollectionRepository extends JpaRepository<Book_collectionEntity, Integer> {
|
||||
|
||||
// List<Book_collectionEntity, Integer>{
|
||||
//①貸出フラグを指定して蔵書を取得する
|
||||
//初期表示は" 0 : 貸出可"を表示
|
||||
List<Book_collectionEntity> findByFlgLending(Character flgLending);
|
||||
|
||||
//②書籍名・出版社・特記事項で部分一致検索をする
|
||||
//@Queryのカッコ内の"SERECT ~"で
|
||||
@Query("""
|
||||
SELECT b FROM Book_collectionEntity b WHERE b.flgLending = '0'
|
||||
AND (:nmBook = '' OR b.nmBook LIKE CONCAT('%', :nmBook,'%'))
|
||||
AND (:pubLisher = '' OR b.pubLisher LIKE CONCAT('%', :pubLisher,'%'))
|
||||
AND (:noteText = '' OR b.noteText LIKE CONCAT('%', :noteText,'%'))
|
||||
ORDER BY b.idBook
|
||||
""")
|
||||
|
||||
List<Book_collectionEntity> searchBooks(
|
||||
@Param("nmBook") String nmBook,
|
||||
@Param("pubLisher") String pubLisher,
|
||||
@Param(" noteText") String noteText
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user