[edit] 図書一覧表示のエラー箇所を修正しました

This commit is contained in:
s-tajihi
2026-09-24 12:52:54 +09:00
parent ab48f30b6e
commit a6a42295c4
6 changed files with 90 additions and 28 deletions

View File

@@ -1,13 +1,21 @@
package com.example.demo.controller;
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 com.example.demo.service.BookServiceImpl;
@Controller
public class BookController {
@Autowired
private BookServiceImpl bookService;
@GetMapping("/book")
public String book(Model model) {
// DBから取得したデータをHTMLで扱えるようにする
model.addAttribute("book",bookService.findAll());
return "book";
}

View File

@@ -15,7 +15,8 @@ import lombok.Data;
@Data
@Table(name = "book")
public class Book {
//貸出処理で使用する図書ID
//図書ID
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "book_Id", nullable = false)
@@ -46,7 +47,7 @@ public class Book {
private Date publicationDate;
// サブカテゴリーID
@Column(name = "subcategory_id", nullable = false)
@Column(name = "book_subcategory_id", nullable = false)
private Integer subcategoryId;
// // カテゴリー名

View File

@@ -1,9 +1,10 @@
package com.example.demo.repository;
import java.awt.print.Book;
import org.springframework.data.jpa.repository.JpaRepository;
import com.example.demo.entity.Book;
public interface BookRepository extends JpaRepository<Book, Integer>{
}

View File

@@ -7,5 +7,5 @@ import com.example.demo.entity.Book;
public interface BookService {
String booklist(Book book);
List<Book> findAll();
List<java.awt.print.Book> findAll();
}

View File

@@ -1,6 +1,6 @@
package com.example.demo.service;
import java.awt.print.Book;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
@@ -10,24 +10,26 @@ import com.example.demo.entity.Book;
import com.example.demo.repository.BookRepository;
@Service
public class BookServiceImpl implements BookService{
public class BookServiceImpl{
@Autowired
private BookRepository bookRepository;
@Override
public String booklist(Book book) {
Book booklist = new Book();
booklist.set
return null;
}
// @Override
// public String booklist(com.example.demo.entity.Book book) {
// Book booklist = new Book();
// booklist.setBookId(book.getBookId());
//
// return null;
// }
@Override
public List<Book> findAll() {
// TODO 自動生成されたメソッド・スタブ
return null;
return bookRepository.findAll();
}
}

View File

@@ -1,5 +1,6 @@
<!DOCTYPE html>
<html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
@@ -7,8 +8,57 @@
</head>
<body>
<div class="container">
<h1>社内図書一覧</h1>
<div class="float-end">
</div>
<form method="get" action="bookLend">
<table class="table table-striped">
<thead>
<tr>
<th>図書ID</th>
<th>ISBN</th>
<th>書籍名</th>
<th>著者名</th>
<th>出版社</th>
<th>出版日</th>
<th>カテゴリー名</th>
<th>サブカテゴリー名</th>
<th>保管場所</th>
<th>貸出状態</th>
<th>本の状態</th>
<th>備考</th>
<th>登録日時</th>
<th>更新日時</th>
<th>寄贈者</th>
<th>寄贈者</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr th:each="b : ${book}">
<td th:text="*{b.bookId}"></td>
<td th:text="*{b.bookManageId}"></td>
<td th:text="*{b.title}"></td>
<td th:text="*{b.isbn}"></td>
<td th:text="*{b.author}"></td>
<td th:text="*{b.publisher}"></td>
<td th:text="*{b.publicationDate}"></td>
<td th:text="*{b.subcategoryId}"></td>
<td th:text="*{b.locationId}"></td>
<td th:text="*{b.condition}"></td>
<td th:text="*{b.createdAt}"></td>
<td th:text="*{b.updatedAt}"></td>
<td th:text="*{b.isDeleted}"></td>
<td th:text="*{b.donorId}"></td>
<td th:text="*{b.description}"></td>
<td th:text="*{b.bookApproval}"></td>
</tr>
</tbody>
</table>
<button type="submit" class="btn-login">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"