no message
This commit is contained in:
@@ -1,12 +1,30 @@
|
||||
package com.example.demo.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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.entity.BookLend;
|
||||
import com.example.demo.service.BookLendService;
|
||||
|
||||
|
||||
@Controller
|
||||
public class LendListController {
|
||||
|
||||
@Autowired
|
||||
private BookLendService lendlistService;
|
||||
|
||||
@GetMapping("/lendList")
|
||||
public String lendList() {
|
||||
public String list(Model model) {
|
||||
|
||||
List<BookLend> aaa = lendlistService.findAll();
|
||||
|
||||
// findAllを使って、DBから一覧を取得 でバックで取得したのを確認
|
||||
model.addAttribute("list",lendlistService.findAll());
|
||||
|
||||
return "lendList";
|
||||
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.OneToOne;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
@@ -28,9 +29,9 @@ public class BookLend {
|
||||
@JoinColumn(name = "book_manage_id", referencedColumnName = "book_manage_id",nullable = false)
|
||||
private Book book;
|
||||
|
||||
// 図書管理ID(BK-1など)
|
||||
@Column(name = "employee_id", nullable = false)
|
||||
private Integer employeeId;
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "employee_id", nullable = false)
|
||||
private Employee employee_booklend;
|
||||
|
||||
// 貸出日
|
||||
@Column(name = "book_lend_date", nullable = false)
|
||||
|
||||
@@ -34,4 +34,7 @@ public class Employee {
|
||||
@OneToMany(mappedBy = "employee")
|
||||
private List<Book> employees = new ArrayList<>();
|
||||
|
||||
@OneToMany(mappedBy = "employee_booklend")
|
||||
private List<BookLend> employees_booklend = new ArrayList<>();
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.example.demo.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.example.demo.entity.BookLend;
|
||||
|
||||
@Repository
|
||||
public interface BookLendRepository extends JpaRepository<BookLend, Integer> {
|
||||
|
||||
}
|
||||
21
src/main/java/com/example/demo/service/BookLendService.java
Normal file
21
src/main/java/com/example/demo/service/BookLendService.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package com.example.demo.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.example.demo.entity.BookLend;
|
||||
import com.example.demo.repository.BookLendRepository;
|
||||
|
||||
@Service
|
||||
public class BookLendService {
|
||||
|
||||
@Autowired
|
||||
private BookLendRepository bookLendRepository;
|
||||
|
||||
public List<BookLend> findAll() {
|
||||
return bookLendRepository.findAll();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>貸出中図書一覧</title>
|
||||
<link rel="stylesheet" th:href="@{/css/style.css}">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@@ -12,8 +13,22 @@
|
||||
<!-- action先要修正 -->
|
||||
<form action="/lendList" method="GET">
|
||||
<input type="submit" value="返却" class="btn">
|
||||
|
||||
|
||||
|
||||
<thead>
|
||||
<tr>
|
||||
<th>社員ID</th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr th:each="${lendlist}">
|
||||
<td th:text="${lendlist.employeeid}"></td>
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
<!-- 以下ポップアップ -->
|
||||
<div id="registerModal" class="modal-overlay">
|
||||
|
||||
|
||||
Reference in New Issue
Block a user