機能6の修正

This commit is contained in:
2026-10-22 15:18:32 +09:00
parent a1f623cc90
commit 20460cd2d9
7 changed files with 179 additions and 79 deletions

View File

@@ -74,16 +74,6 @@
<artifactId>spring-boot-starter-webmvc-test</artifactId> <artifactId>spring-boot-starter-webmvc-test</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>com.example</groupId>
<artifactId>HelloSpring</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.example.rhizome</groupId>
<artifactId>EM-Spring</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@@ -1,35 +1,58 @@
package com.example.demo.controller; package com.example.demo.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import com.example.demo.service.LendingListService;
@Controller @Controller
public class LendingListController { public class LendingListController {
@Autowired
LendingListService lendingListService;
public LendingListController(LendingListService lendingListService) {
this.lendingListService = lendingListService;
}
//貸出中書籍一覧を表示
@RequestMapping(value = "/lendingList", method = RequestMethod.GET)
//lendingListにアクセスしたときに実行されるメソッド
public String index(Model model) {
//サービスと連携する処理
//サービスから一覧を取得し、borrowListという名前でHTMLに渡す
model.addAttribute("borrowList", lendingListService.getBorrowList());
//表示するHTML
return "lendingList";
}
//メニューに戻る
@RequestMapping(value = "/menu", method = RequestMethod.GET)
public String menu() {
return "menu";
}
//書籍返却ページに遷移
@RequestMapping(value = "/returnConfirm", method = RequestMethod.GET)
//返却確認ページにアクセスしたときに実行されるメソッド
public String returnConfirm(
//URLから送られた申請IDを受け取る
@RequestParam("idRequest") Integer idRequest, Model model) {
//受け取った申請IDをidRequestという名前でHTMLに渡す
model.addAttribute("idRequest", idRequest);
//上記で渡すHTMLのURL
return "returnConfirm";
}
// @GetMapping("/lendingList") //@GetMapping("/lendingList")//登録されているデータを取得する役割を果たす
// public String show(Model model) { // public String show(Model model) {
// List<X> x = xservice.getX(); // List<X> x = xservice.getX();
// model.addAttribute("Y", x); // model.addAttribute("Y", x);
// return "Y"; // return LendingListService.select;
// } // }
//
// HttpSession session;
//
// @Autowired
// public SelectListController(HttpSession session) {
// this.session=session;
// }
// @RequestMapping("/lendingList")
// public String lendList() {
// return "lendingList";
// }
// @RequestMapping(value = lendingList, method = RequestMethod.POST)
// public String select( , Model model) {
// model.addAttribute(
// );
// return lendingList;
//
// }
} }

View File

@@ -0,0 +1,15 @@
package com.example.demo.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
public class MenuController {
@RequestMapping(value = "/menu", method = RequestMethod.GET)
public String showmenu() {
return "menu";
}
}

View File

@@ -0,0 +1,21 @@
package com.example.demo.model;
import java.util.Date;
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@AllArgsConstructor
public class LeadingListModel {
//データの保持
private final Integer idRequest;
private final String nmBook;
private final String nmEmployee;
private final Date dateRequest;
private final Date dateBorrow;
private final Date dateScheduledReturn;
}

View File

@@ -1,12 +1,13 @@
package com.example.demo.service; package com.example.demo.service;
import javax.transaction.Transactional; import java.util.List;
import jakarta.transaction.Transactional;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.example.demo.entity.EmployeeEntity; import com.example.demo.model.LeadingListModel;
import com.example.demo.repository.Book_CollectionRepository;
import com.example.demo.repository.Borrow_BooksRepository; import com.example.demo.repository.Borrow_BooksRepository;
@Service @Service
@@ -14,14 +15,20 @@ import com.example.demo.repository.Borrow_BooksRepository;
public class LendingListService { public class LendingListService {
@Autowired @Autowired
private Book_CollectionRepository collection; Borrow_BooksRepository borrowrepo;
@Autowired
private Borrow_BooksRepository borrow; public LendingListService(Borrow_BooksRepository borrowrepo) {
@Autowired this.borrowrepo = borrowrepo;
private EmployeeEntity employee;
public List<table> getcollectionWithborrow(){
return collection;
} }
//貸出中書籍の一覧を取得したい
public List<LeadingListModel>getBorrowList(){
//リポジトリに取得を託す。取得したらコントローラーに返す
return borrowrepo.findLendingList();
}
// public List<LeadingListDto> getBorrowList(){
// List<Borrow_booksEntity> borrowentity = Borrow_BooksRepository.findAll();
// leadinglistdto.status(equals("2"));
// }
} }

View File

@@ -1,9 +1,9 @@
<!DOCTYPE html> <!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"> <html xmlns:th="http://www.thymeleaf.org">
<head> <head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"> <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<title>貸出中書籍一覧</title> <title>貸出中書籍一覧</title>
</head> </head>
<body> <body>
@@ -11,34 +11,44 @@
<div class="rightSection"> <div class="rightSection">
<button class="logoutButton" onclick="logoutSubmit()">ログアウト</button> <button class="logoutButton" onclick="logoutSubmit()">ログアウト</button>
</div> </div>
<a href="menu">メニューに戻る</a>
<h1><span>検索結果</span></h1>
</h1> </h1>
<thead> <a href="menu">メニューに戻る</a>
<tr> <h1><span>検索結果</span></h1>
<th style="width: 100px;">申請ID</th> <table>
<th style="width: 100px;">申請者名</th> <thead>
<th style="width: 100px;">書籍名</th> <tr>
<th style="width: 100px;">申請日</th> <th style="width: 150px;">申請ID</th>
<th style="width: 100px;">貸出日</th> <th style="width: 150px;">申請者名</th>
<th style="width: 100px;">返却予定日</th> <th style="width: 150px;">書籍名</th>
<th style="width: 100px;">操作</th> <th style="width: 150px;">申請日</th>
</tr> <th style="width: 150px;">貸出日</th>
</thead> <th style="width: 150px;">返却予定日</th>
<tbody> <th style="width: 150px;">操作</th>
<tr th:each=""> </tr>
<td th:text="${.idRequest}"></td> </thead>
<td th:text="${.}"></td> <tbody>
<td th:text="${.}"></td> <tr th:each="borrow : ${borrowList}">
<td th:text="${.dateRequest}"></td> <td th:text="${borrow.idRequest}"></td>
<td th:text="${.dateBorrow}"></td> <td th:text="${borrow.nmEmployee}"></td>
<td th:text="${.dateScheduledReturn}"></td> <td th:text="${borrow.nmBook}"></td>
<td> <td th:text="${borrow.dateRequest}"></td>
<form action="" method="post" style="display: inline;"> <td th:text="${borrow.dateBorrow}"></td>
<input name="" th:value="${}" type="hidden"> <td th:text="${borrow.dateScheduledReturn}"></td>
<input type="submit" value="返却"> <td>
</form> <!--返却フォーム-->
</td> <form action="/returnConfirm" method="get">
</tbody> <!--送信するデータ名、送信する値、送信する指定-->
<input name="idRequest" th:value="${borrow.idRequest}" type="hidden">
<input type="submit" value="返却">
</form>
</td>
</tr>
</tbody>
</table>
<br>
<th:block th:if="${borrowList == null or borrowList.isEmpty()}">
貸出中の書籍はありません
</th:block>
</body> </body>
</html> </html>

View File

@@ -0,0 +1,34 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>メニュー</title>
</head>
<body>
<h1>
メインメニュー
<div class="rightSection">
<span class="loginInfo">ログイン者名:<span th:text="${session.loginUser.nmEmployee}"></span></span>
<button class="logoutButton" onclick="logoutSubmit()">ログアウト</button>
</div>
</h1>
<table class="menuClass">
<tr>
<td>
<a class="menuClass" href="javascript:bookListSubmit()"><i class="fas fa-search"></i>書籍検索</a>
</td>
</tr>
<tr>
<td>
<a class="menuClass" href="javascript:appricationListSubmit()"><i class="fas fa-search"></i>書籍貸出申請一覧</a>
</td>
</tr>
</table>
</body>
</html>