17 Commits

Author SHA1 Message Date
044210adc3 [add]誤字修正 2026-09-25 16:59:14 +09:00
8e9a73afa7 Merge branch 's-tajihi' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/ShareBooks_new into y-watanabe 2026-09-25 16:38:17 +09:00
cff0436daf Merge branch 'h-seya' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/ShareBooks_new into y-watanabe 2026-09-25 16:38:10 +09:00
h-seya
856913615f [EDIT]:社員IDプルダウンとDB連携処理の実装途中 2026-09-25 16:36:17 +09:00
s-tajihi
d7e12cc4f1 [edit] 図書一覧画面の検索機能を追加しました 2026-09-25 16:12:16 +09:00
h-seya
795058750b Merge branch 'y-kumaki' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/ShareBooks_new into h-seya
# Conflicts:
#	src/main/java/com/example/demo/repository/BookLendRepository.java
#	src/main/java/com/example/demo/service/BookLendService.java
2026-09-25 15:34:37 +09:00
y-kumaki
ed78956074 no message 2026-09-25 15:30:31 +09:00
h-seya
63ddcdf82a Merge branch 's-tajihi' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/ShareBooks_new into h-seya 2026-09-25 13:37:38 +09:00
s-tajihi
772d0ef594 [edit] 表示内容の修正をしました 2026-09-25 13:36:06 +09:00
y-kumaki
ea262e10c5 no message 2026-09-25 13:30:55 +09:00
h-seya
8d69541d09 Merge branch 'y-watanabe' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/ShareBooks_new into h-seya 2026-09-25 13:30:20 +09:00
h-seya
8a859d8dea Merge branch 'y-watanabe' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/ShareBooks_new into h-seya 2026-09-25 13:27:06 +09:00
h-seya
453892baaf Merge branch 's-tajihi' of https://gitea.it-college.co.jp/2026_09_5H_Spring_KIZAKI/ShareBooks_new into h-seya 2026-09-25 12:44:11 +09:00
s-tajihi
14e060588c [edit] 「更新」ボタンからの遷移を追加しました 2026-09-25 12:43:41 +09:00
s-tajihi
67a8576a59 [delete] 不要なファイルを削除しました 2026-09-25 11:24:24 +09:00
h-seya
22b32a5ea2 [ADD]:図書貸出処理に使用予定の、クラス及びインターフェースを作成 2026-09-25 11:21:05 +09:00
s-tajihi
47c2df9db9 [edit] メソッド名の変更をしました 2026-09-25 10:56:37 +09:00
19 changed files with 454 additions and 115 deletions

View File

@@ -6,23 +6,55 @@ 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 org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import com.example.demo.entity.Book;
import com.example.demo.form.BookSearchForm;
import com.example.demo.service.BookServiceImpl;
@Controller
public class BookController {
@Autowired
private BookServiceImpl bookService;
/* 一覧表示 */
@GetMapping("/book")
public String book(Model model) {
List<Book> aaa = bookService.findAll();
// DBから取得したデータをHTMLで扱えるようにする
model.addAttribute("book",bookService.findAll());
model.addAttribute("book", bookService.findAll());
model.addAttribute("bookSearchForm", new BookSearchForm());
return "book";
}
/* 検索処理 */
@GetMapping("/searchBooks")
public String searchBooks(@ModelAttribute BookSearchForm bookSearchForm,
Model model) {
model.addAttribute("book", bookService.findBooks(bookSearchForm.getKeyword()));
model.addAttribute("bookSearchForm", bookSearchForm);
return "book";
}
/* クリア処理 */
@PostMapping("/clearBookList")
public String clearBookList(Model model) {
model.addAttribute("book", bookService.findAll());
model.addAttribute("bookSearchForm", new BookSearchForm());
// 一覧表示画面に戻る
return "/book";
}
}

View File

@@ -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";
}
}

View File

@@ -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";
}

View File

@@ -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;
//備考

View File

@@ -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)

View File

@@ -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<>();
}

View File

@@ -1,5 +0,0 @@
package com.example.demo.form;
public class BookForm {
}

View File

@@ -0,0 +1,7 @@
package com.example.demo.form;
// 図書の貸出処理に使用予定
public class BookLendForm {
}

View File

@@ -0,0 +1,10 @@
package com.example.demo.form;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class BookSearchForm {
private String keyword;
}

View File

@@ -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> {
}

View File

@@ -1,10 +1,20 @@
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 com.example.demo.entity.Book;
public interface BookRepository extends JpaRepository<Book, Integer>{
@Query("""
SELECT b FROM Book b
WHERE b.title LIKE %:keyword%
OR b.publisher LIKE %:keyword%
OR b.author LIKE %:keyword%
""")
List<Book> searchBooks(@Param("keyword")String keyword);
}

View File

@@ -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);
}

View 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();
}
}

View File

@@ -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();
}

View File

@@ -1,6 +1,5 @@
package com.example.demo.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
@@ -10,26 +9,17 @@ import com.example.demo.entity.Book;
import com.example.demo.repository.BookRepository;
@Service
public class BookServiceImpl{
public class BookServiceImpl {
@Autowired
private BookRepository bookRepository;
// @Override
// public String booklist(com.example.demo.entity.Book book) {
// Book booklist = new Book();
// booklist.setBookId(book.getBookId());
//
// return null;
// }
public List<Book> findAll() {
return bookRepository.findAll();
}
public List<Book> findBooks(String keyword){
return bookRepository.searchBooks(keyword);
}
}

View File

@@ -12,12 +12,33 @@
<h1>社内図書一覧</h1>
<div class="float-end">
</div>
<form class="input-group" th:action="@{/searchBooks}" th:object="${bookSearchForm}" method="get">
<input type="text" th:field="*{keyword}" class="form-control" placeholder="キーワードを入力">
<button class="btn btn-outline-success" type="submit">
検索
</button>
</form>
<form method="post" th:action="@{/clearBookList}">
<button class="button button-secondary" type="submit">
クリア
</button>
</form>
<p>※「タイトル」「出版社」「著者名」で検索</p>
<form method="get" action="bookLend">
<table class="table table-striped">
<thead>
<tr>
<th>図書ID</th>
<th>図書管理ID</th>
<th>ISBN</th>
<th>タイトル</th>
<th>著者名</th>
@@ -30,14 +51,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 +68,47 @@
<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="post" 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>
<tr th:if="${#lists.isEmpty(book)}">
<td colspan="15">
該当する図書がありません
</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>

View File

@@ -9,7 +9,7 @@
<body>
<h1>新規図書登録入力</h1>
<br><br>
<h4>新しく図書を登録します。必要事項jを入力し、「登録」ボタンを押してください</h4>
<h4>新しく図書を登録します。必要事項を入力し、「登録」ボタンを押してください</h4>
<span style="color:red;">※は必須項目です</span>
<br><br>
<form action="/bookInsertConfirm" method="POST" th:object="${bookInsert}">
@@ -78,7 +78,7 @@
</select>
<br><br>
<label for="publisher">主パン者</label><br>
<label for="publisher">出版社</label><br>
<input type="text" id="publisher" name="publisher" th:value="${bookInsert.publisher}">
<br><br>

View File

@@ -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>

View File

@@ -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>
<!-- 以下ポップアップ -->