Merge branch 'h-seya' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/ShareBooks_new into y-watanabe
This commit is contained in:
@@ -1,13 +1,30 @@
|
||||
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.PostMapping;
|
||||
|
||||
import com.example.demo.entity.Employee;
|
||||
import com.example.demo.repository.EmployeeRepository;
|
||||
|
||||
@Controller
|
||||
public class BookLendController {
|
||||
@PostMapping("/bookLend")
|
||||
public String welcome() {
|
||||
return "bookLend";
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private EmployeeRepository employeeRepository;
|
||||
|
||||
@PostMapping("/bookLend")
|
||||
public String bookLend(Model model) {
|
||||
return "bookLend";
|
||||
}
|
||||
|
||||
// 社員IDを取得してプルダウンに表示させる
|
||||
@PostMapping("/bookLend/employeeId")
|
||||
public String selectEmployeeId(Employee employee, Model model) {
|
||||
model.addAttribute("employeeList", employeeRepository.findByEmployeeId(employee.getEmployeeId()));
|
||||
model.addAttribute("bookLend", employee);
|
||||
return "bookLend";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class Book {
|
||||
private int bookId;
|
||||
|
||||
// 図書管理ID(BK-1など)
|
||||
@Column(name = "book_manage_id", nullable = true)
|
||||
@Column(name = "book_manage_id", nullable = true, unique = true)
|
||||
private String bookManageId;
|
||||
|
||||
// タイトル
|
||||
@@ -78,7 +78,7 @@ public class Book {
|
||||
|
||||
// 寄贈者社員ID??
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "donor_id", nullable = false)
|
||||
@JoinColumn(name = "donor_id", nullable = true)
|
||||
private Employee employee;
|
||||
|
||||
//備考
|
||||
|
||||
@@ -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 employeeBooklend;
|
||||
|
||||
// 貸出日
|
||||
@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 = "employeeBooklend")
|
||||
private List<BookLend> employeesBooklend = new ArrayList<>();
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
package com.example.demo.form;
|
||||
|
||||
public class BookForm {
|
||||
|
||||
}
|
||||
7
src/main/java/com/example/demo/form/BookLendForm.java
Normal file
7
src/main/java/com/example/demo/form/BookLendForm.java
Normal file
@@ -0,0 +1,7 @@
|
||||
package com.example.demo.form;
|
||||
|
||||
// 図書の貸出処理に使用予定
|
||||
|
||||
public class BookLendForm {
|
||||
|
||||
}
|
||||
@@ -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> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.example.demo.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import com.example.demo.entity.Employee;
|
||||
|
||||
public interface EmployeeRepository extends JpaRepository<Employee, Integer>{
|
||||
|
||||
List<Employee> findByEmployeeId(Integer employeeId);
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.example.demo.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.example.demo.entity.Book;
|
||||
|
||||
public interface BookService {
|
||||
String booklist(Book book);
|
||||
|
||||
List<java.awt.print.Book> findAll();
|
||||
}
|
||||
@@ -17,7 +17,7 @@
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>図書ID</th>
|
||||
<th>図書管理ID</th>
|
||||
<th>ISBN</th>
|
||||
<th>タイトル</th>
|
||||
<th>著者名</th>
|
||||
@@ -30,14 +30,14 @@
|
||||
<th>登録日時</th>
|
||||
<th>更新日時</th>
|
||||
<th>寄贈者</th>
|
||||
<th>貸出状態??</th>
|
||||
<th>操作??</th>
|
||||
<th>貸出状態</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<tr th:each="book : ${book}">
|
||||
|
||||
<tr th:each="book : ${book}" th:if="${book.bookManageId != null}">
|
||||
|
||||
<td th:text="*{book.bookManageId}"></td>
|
||||
<td th:text="*{book.isbn}"></td>
|
||||
<td th:text="*{book.title}"></td>
|
||||
@@ -47,52 +47,43 @@
|
||||
<td th:text="*{book.bookSubcategory.bookCategory.bookCategoryName}"></td>
|
||||
<td th:text="*{book.bookSubcategory.bookSubcategoryName}"></td>
|
||||
<td th:text="*{book.storageLocation.locationName}"></td>
|
||||
<td th:text="*{book.condition}"></td>
|
||||
<td th:text="*{book.condition == 0 ? '分からない':
|
||||
book.condition == 1 ? '新品':
|
||||
book.condition == 2 ? '良好':
|
||||
book.condition == 3 ? '使用感あり':
|
||||
book.condition == 4 ? '痛みあり':
|
||||
'不明'}">
|
||||
</td>
|
||||
<td th:text="*{book.createdAt}"></td>
|
||||
<td th:text="*{book.updatedAt}"></td>
|
||||
<td th:text="*{book.employee != null ? book.employee.employeeId : '-'}"></td>
|
||||
<td th:text="*{book.bookLends != null ? book.bookLends.bookStatus : '-'}"></td>
|
||||
|
||||
|
||||
|
||||
<td th:text="*{book.employee != null ? book.employee.employeeName : '-'}"></td>
|
||||
<td
|
||||
th:text="*{book.bookLends != null ? (book.bookLends.bookStatus == 0 ? '貸出可': '貸出不可') : '貸出可'}">
|
||||
</td>
|
||||
<td>
|
||||
<form method="post" action="/bookLend">
|
||||
<input type="hidden" name="bookManageId" th:value="*{book.bookManageId}">
|
||||
<button type="submit"
|
||||
th:disabled="*{book.bookLends != null && book.bookLends.bookStatus == 1}">
|
||||
貸出
|
||||
</button>
|
||||
</form>
|
||||
<form method="get" action="/updateconfirm">
|
||||
<input type="hidden" name="bookManageId" th:value="*{book.bookManageId}">
|
||||
<button type="submit">更新</button>
|
||||
</form>
|
||||
<form method="get" action="/delete">
|
||||
<input type="hidden" name="bookManageId" th:value="*{book.bookManageId}">
|
||||
<button type="submit">削除</button>
|
||||
</form>
|
||||
</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"
|
||||
stroke-linejoin="round">
|
||||
<path d="M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4" />
|
||||
<polyline points="10 17 15 12 10 7" />
|
||||
<line x1="15" y1="12" x2="3" y2="12" />
|
||||
</svg>
|
||||
貸出
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<button type="submit" class="btn-login">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"
|
||||
stroke-linejoin="round">
|
||||
<path d="M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4" />
|
||||
<polyline points="10 17 15 12 10 7" />
|
||||
<line x1="15" y1="12" x2="3" y2="12" />
|
||||
</svg>
|
||||
貸出
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<form method="post" action="update">
|
||||
<button type="submit" class="btn-login">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"
|
||||
stroke-linejoin="round">
|
||||
<path d="M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4" />
|
||||
<polyline points="10 17 15 12 10 7" />
|
||||
<line x1="15" y1="12" x2="3" y2="12" />
|
||||
</svg>
|
||||
更新
|
||||
</button>
|
||||
</form>
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
@@ -1,32 +1,208 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>図書貸出処理</title>
|
||||
<meta charset="UTF-8">
|
||||
<title>図書貸出処理</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
図書貸出処理
|
||||
<form id="loanForm"action="bookLendConfirmation" method="post">
|
||||
<div class="button-area">
|
||||
|
||||
<div class="right-buttons">
|
||||
<button type="button" class="btn btn-primary"
|
||||
onclick="submitLoan()">貸出する</button>
|
||||
</div>
|
||||
</div>
|
||||
<h1>
|
||||
図書貸出処理
|
||||
</h1>
|
||||
|
||||
</form>
|
||||
<p>
|
||||
以下の図書を貸出します。貸出先と貸出日・返却予定日を入力してください。
|
||||
</p>
|
||||
|
||||
<h2>
|
||||
図書情報
|
||||
</h2>
|
||||
|
||||
<div class="card-body">
|
||||
<table class="info-table">
|
||||
<tr>
|
||||
<th>
|
||||
図書管理ID
|
||||
</th>
|
||||
|
||||
<td>
|
||||
(図書管理IDをここに表示させる)
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th>
|
||||
図書タイトル
|
||||
</th>
|
||||
|
||||
<td>
|
||||
(タイトルをここに表示させる)
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th>
|
||||
著者名
|
||||
</th>
|
||||
|
||||
<td>
|
||||
(著者名をここに表示させる)
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th>
|
||||
ISBN
|
||||
</th>
|
||||
|
||||
<td>
|
||||
(ISBNをここに表示させる)
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<h2>
|
||||
社員情報
|
||||
</h2>
|
||||
|
||||
<div class="card">
|
||||
|
||||
<div class="form-row">
|
||||
|
||||
<label for="employeeSelect">
|
||||
社員ID
|
||||
</label>
|
||||
|
||||
<!-- <select th:field="*{employeeId}" onchange="this.form.action='/bookLend/employeeId';this.form.submit();">-->
|
||||
|
||||
<select name="employeeId" id="employeeSelect">
|
||||
|
||||
<script>
|
||||
|
||||
function submitLoan() {
|
||||
<option value="">
|
||||
社員IDを選択してください
|
||||
</option>
|
||||
|
||||
if (confirm('この図書を貸出しますか?')) {
|
||||
// OK選択時にフォーム送信を実行し、BookLendReturnControllerに処理を投げる
|
||||
document.getElementById('loanForm').submit();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<!-- <option th:each="employee : ${employeeList}" th:value="${employee.employeeId}">-->
|
||||
<!-- </option>-->
|
||||
|
||||
<option value="1">1</option>
|
||||
<option value="2">2</option>
|
||||
<option value="3">3</option>
|
||||
<option value="4">4</option>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="employeeName">
|
||||
社員名
|
||||
</label>
|
||||
|
||||
<input type="text" id="employeeName" value="" placeholder="社員名が表示されます" readonly>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<h2>
|
||||
貸出・返却日入力
|
||||
</h2>
|
||||
|
||||
<div class="date-section">
|
||||
|
||||
<div class="date-box">
|
||||
|
||||
<label>
|
||||
貸出日(自動取得)
|
||||
</label>
|
||||
|
||||
<input type="date" id="loanDate" name="loanDate" value="">
|
||||
|
||||
<div class="note">
|
||||
※ 現在の日付が自動で設定されます。
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="date-box">
|
||||
|
||||
<label>
|
||||
貸出期間日数
|
||||
</label>
|
||||
|
||||
<input type="text" id="loanDays" placeholder="日数を入力してください">
|
||||
|
||||
<div class="note">
|
||||
※ 数値(1以上)で入力してください。
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="date-box">
|
||||
|
||||
<label>
|
||||
返却予定日(必須)
|
||||
</label>
|
||||
|
||||
<input type="date" id="returnDate" name="returnDate">
|
||||
|
||||
<div class="note">
|
||||
※ カレンダーから日付を選択してください。
|
||||
</div>
|
||||
|
||||
<div class="error">
|
||||
※ 現在の日付より前は選択できません。
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="warning-area">
|
||||
|
||||
<strong>
|
||||
注意事項
|
||||
</strong>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
貸出処理を行うと、対象の図書のステータスが「貸出中」に変更されます。
|
||||
</li>
|
||||
|
||||
<li>
|
||||
返却予定日を必ず指定してください。
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<form id="lendForm" action="bookLendConfirmation" method="post">
|
||||
<div class="button-area">
|
||||
|
||||
<div class="right-buttons">
|
||||
<button type="button" class="btn btn-primary" onclick="submitLend()">
|
||||
貸出する
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<script>
|
||||
|
||||
function submitLend() {
|
||||
|
||||
if (confirm('この図書を貸出しますか?')) {
|
||||
// OK選択時にフォーム送信を実行し、BookLendReturnControllerに処理を投げる
|
||||
document.getElementById('lendForm').submit();
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,17 +1,48 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>貸出中図書一覧</title>
|
||||
<link rel="stylesheet" th:href="@{/css/style.css}">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>貸出中図書一覧</h1>
|
||||
|
||||
|
||||
<!-- action先要修正 -->
|
||||
<form action="/lendList" method="GET">
|
||||
<input type="submit" value="返却" class="btn">
|
||||
|
||||
|
||||
<table>
|
||||
|
||||
<thead>
|
||||
<tr>
|
||||
<th>社員ID</th>
|
||||
<th>社員名</th>
|
||||
<th>管理ID</th>
|
||||
<th>タイトル</th>
|
||||
<th>返却予定日</th>
|
||||
<th>超過日数</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
|
||||
<tbody>
|
||||
<tr th:each="booklist : ${list}">
|
||||
|
||||
<td th:text="*{booklist.employeeBooklend.employeeId}"></td>
|
||||
<td th:text="*{booklist.employeeBooklend.employeeName}"></td>
|
||||
<td th:text="*{booklist.book.bookManageId}"></td>
|
||||
<td th:text="*{booklist.book.title}"></td>
|
||||
<td th:text="*{booklist.bookReturnDate}"></td>
|
||||
<!-- <td th:text="*{booklist.}"></td>-->
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
<!-- 以下ポップアップ -->
|
||||
|
||||
Reference in New Issue
Block a user