11 Commits

11 changed files with 277 additions and 147 deletions

View File

@@ -0,0 +1,35 @@
package com.example.demo.controller;
import org.springframework.stereotype.Controller;
@Controller
public class LendingListController {
// @GetMapping("/lendingList")
// public String show(Model model) {
// List<X> x = xservice.getX();
// model.addAttribute("Y", x);
// return "Y";
// }
// 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

@@ -138,4 +138,4 @@ public class EmployeeEntity {
// getIdUpdate(),
// getDateUpdate());
//}
//}
//}

View File

@@ -1,18 +0,0 @@
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,28 +1,11 @@
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 org.springframework.stereotype.Repository;
import com.example.demo.entity.Book_collectionEntity;
@Repository
public interface Book_CollectionRepository extends JpaRepository<Book_collectionEntity, Integer> {
List<Book_collectionEntity> findByFlgLending(Character flgLending);
@Query("""
SELECT b FROM Book_collectionEntity b
WHERE b.flgLending='0'
AND (:nmBook = '' OR b.nmBook LIKE CONCAT('%', :nmBook,'%'))
AND (:pubLisher = '' OR b.pubLisher LIKE CONCAT('%', :pubLisher,'%'))
AND (:noteText = '' OR b.noteText LIKE CONCAT('%',:noteText,'%'))
ORDER BY b.idBook
""")
List<Book_collectionEntity> searchBooks(
@Param("nmBook") String nmBook,
@Param("pubLisher") String pubLisher,
@Param(" noteText") String noteText);
}

View File

@@ -1,7 +1,5 @@
package com.example.demo.repository;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@@ -9,5 +7,5 @@ import com.example.demo.entity.Borrow_booksEntity;
@Repository
public interface Borrow_BooksRepository extends JpaRepository<Borrow_booksEntity, Integer> {
List<Borrow_booksEntity> findByStatus(Character status);
}

View File

@@ -1,7 +1,5 @@
package com.example.demo.repository;
import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@@ -9,8 +7,6 @@ import com.example.demo.entity.EmployeeEntity;
@Repository
public interface EmployeeRepository extends JpaRepository<EmployeeEntity, Integer> {
//メールアドレスとパスワードに合致するレコード
Optional<EmployeeEntity> findByMailAddressAndPassword(String mailAddress, String password);
}

View File

@@ -0,0 +1,27 @@
package com.example.demo.service;
import javax.transaction.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.example.demo.entity.EmployeeEntity;
import com.example.demo.repository.Book_CollectionRepository;
import com.example.demo.repository.Borrow_BooksRepository;
@Service
@Transactional
public class LendingListService {
@Autowired
private Book_CollectionRepository collection;
@Autowired
private Borrow_BooksRepository borrow;
@Autowired
private EmployeeEntity employee;
public List<table> getcollectionWithborrow(){
return collection;
}
}

View File

@@ -1,20 +1,13 @@
package com.example.demo.service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.example.demo.entity.Book_collectionEntity;
import com.example.demo.entity.Borrow_booksEntity;
import com.example.demo.form.LendingForm;
import com.example.demo.form.LoginInfoForm;
import com.example.demo.form.ReturnForm;
import com.example.demo.form.SearchConditionBookForm;
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.EmployeeRepository;
@@ -101,99 +94,4 @@ public class ReturnService {
book_CollectionRepository.save(book.get());
}
//貸し出し可能な書籍の全権取得
public List<Book_collectionEntity> availableSelectAll() {
return book_CollectionRepository.findByFlgLending('0');
}
//書籍名・出版社・特記事項の部分一致検索
public List<Book_collectionEntity> searchByWithLike(
SearchConditionBookForm form) {
String nmBook = form.getNmBook();
String pubLisher = form.getPubLisher();
String noteText = form.getNoteText();
nmBook = nmBook == null ? "" : nmBook;
pubLisher = pubLisher == null ? "" : pubLisher;
noteText = noteText == null ? "" : noteText;
return book_CollectionRepository.searchBooks(
nmBook,
pubLisher,
noteText);
}
public List<LeadingListModel> getBorrowList() {
List<LeadingListModel> result = new ArrayList<LeadingListModel>();
List<Borrow_booksEntity> borrow = borrowRepository.findByStatus('2');
for (Borrow_booksEntity borrow_booksEntity : borrow) {
String nmEmployee = employeeRepository.findById(borrow_booksEntity.getIdApplicant()).get().getNmEmployee();
String nmBook = book_CollectionRepository.findById(borrow_booksEntity.getIdBook()).get().getNmBook();
LeadingListModel a = new LeadingListModel(borrow_booksEntity.getIdRequest(),
nmEmployee,
nmBook,
borrow_booksEntity.getDateRequest(),
borrow_booksEntity.getDateBorrow(),
borrow_booksEntity.getDateScheduledReturn());
result.add(a);
}
return result;
}
//書籍貸出申請機能
public void executeLending(LendingForm form, int idEmployee) {
var book_collection = book_CollectionRepository.findById(form.getId_book());//更新したい本のEntityを取得
book_collection.get().setFlgLending('1');//フラグだけ書き換え
book_CollectionRepository.save(book_collection.get());
Borrow_booksEntity borrow = new Borrow_booksEntity();//空の申請レコード
borrow.setIdApproval(idEmployee);//申請者ID
borrow.setIdBook(form.getId_book());//蔵書ID
borrow.setDateRequest(new Date());//申請日
borrow.setStatus('1');//ステータスを承認待ちに
borrow.setIdUpdate(idEmployee);//更新者ID
borrow.setDateUpdate(new Date());//更新日
borrowRepository.save(borrow);
}
//貸出テーブルの「ステータス」が「1:承認待」の情報を全件取得
public List<LeadingListModel> getAwaitingApprovalList() {
List<LeadingListModel> result = new ArrayList<LeadingListModel>();
List<Borrow_booksEntity> borrow = borrowRepository.findByStatus('1');
for (Borrow_booksEntity borrow_booksEntity : borrow) {
String nmEmployee = employeeRepository.findById(borrow_booksEntity.getIdApplicant()).get().getNmEmployee();
String nmBook = book_CollectionRepository.findById(borrow_booksEntity.getIdBook()).get().getNmBook();
LeadingListModel a = new LeadingListModel(borrow_booksEntity.getIdRequest(),
nmEmployee,
nmBook,
borrow_booksEntity.getDateRequest(),
borrow_booksEntity.getDateBorrow(),
borrow_booksEntity.getDateScheduledReturn());
result.add(a);
}
return result;
}
//メアドとパスワードが合っていればtureで返す
public boolean canlogin(String mail, String pass) {
if (mail == null || mail.isEmpty() || pass == null || pass.isEmpty()) {
return false;
}
return employeeRepository.findByMailAddressAndPassword(mail, pass).isPresent();
}
//LoginInfoFormの情報からidEmployeeを返す
public int getUserID(LoginInfoForm form) {
return employeeRepository.findByMailAddressAndPassword(form.getMailAddress(), form.getPassword()).get()
.getIdEmployee();
}
//LoginInfoFormの情報からFlgを返す 0なら一般,1なら管理
public Character getUserFlg(LoginInfoForm form) {
return employeeRepository.findByMailAddressAndPassword(form.getMailAddress(), form.getPassword()).get()
.getFlgAdmin();
}
}
}

View File

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

View File

@@ -0,0 +1,162 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<!-- 外部のスクリプトファイルを読み込む -->
<script th:src="@{/js/common.js}"></script>
<!-- CSSの読み込み -->
<link rel="stylesheet" th:href="@{/css/all.css}">
<link rel=stylesheet th:href="@{/css/style.css}" type="text/css">
<title>検索</title>
</head>
<body>
<h1>
<div class="rightSection">
<button class="logoutButton" onclick="logoutSubmit()">ログアウト</button>
</div>
</h1>
<form action="selectEmployeeInfo"
method="post"
th:object="${searchConditionEmployeeForm}">
<div class="msgBox error" th:if="${messageError} != null">
<span class="error" th:text="${messageError.message}"></span>
</div>
<trtable>
<tr>
<th class="header">申請ID</th>
<td>
<input placeholder="申請ID"
th:field="*{idRequest}"
type="number"/>
</td>
</tr>
<tr>
<th class="header">申請者名</th>
<td>
<select th:field="*{nmApplication}">
<option value=""></option>
<option th:each="department : ${departmentFormList}"
th:selected="${searchConditionEmployeeForm.idDepartment != null && department.idDepartment == searchConditionEmployeeForm.idDepartment}"
th:text="${department.nmDepartment}"
th:value="${department.idDepartment}">
</option>
</select>
<input placeholder="申請者名"
th:field="*{nmApplicant}"
type="text"/>
</td>
</tr>
<tr>
<th class="header">書籍名</th>
<td>
<input placeholder="書籍名"
th:field="*{nmBook}"
type="text"/>
</td>
</tr>
<tr>
<th class="header">申請日</th>
<td>
<input placeholder="申請日"
th:field="*{dateRequest}"
type="date"/>
</td>
</tr>
<td>
<th class="header">貸出日</th>
<td>
<input placeholder="貸出日"
th:field="*{dateBorrow}"
type="date"/>
</td>
</tr>
<tr>
<th class="header">返却予定日</th>
<td>
<input placeholder="返却予定日"
th:field="*{dateScheduledReturn}"
type="date"/>
</td>
</tr>
<tr>
<th class="header">操作</th>
<td>
<button class="approvalButton" onclick="approvalSubmit()">承認</button>
</td>
</tr>
</table>
</form>
<div class="header-spacing"></div>
<a href="showMenu">メニューに戻る</a>
<div class="header-spacing"></div>
<h1><span>検索結果</span></h1>
<div class="header-spacing"></div>
<th:block th:if="${messageInfo != null}">
<script th:inline="javascript">
alert([[${messageInfo.message}]]);
</script>
</th:block>
<div class="header-spacing"></div>
<th:block th:if="${employeeInfoFormList != null and employeeInfoFormList.size() > 0}">
<!-- 検索結果が1件以上ある場合 -->
<table class="table-grid table-striped table-hover">
<thead>
<tr>
<th style="width: 60px;">申請ID</th>
<th style="width: 100px;">申請者名</th>
<th style="width: 150px;">書籍名</th>
<th style="width: 150px;">申請日</th>
<th style="width: 100px;">貸出日</th>
<th style="width: 70px;">返却予定日</th>
<th style="width: 150px;">操作</th>
</tr>
</thead>
<tbody>
<tr th:each="employeeInfoForm : ${employeeInfoFormList}">
<td th:text="${employeeInfoForm.idEmployee}"></td>
<td th:text="${employeeInfoForm.nmEmployee}"></td>
<td th:text="${employeeInfoForm.knEmployee}"></td>
<td th:text="${employeeInfoForm.mailAddress}"></td>
<td th:text="${employeeInfoForm.password}"></td>
<td th:text="${employeeInfoForm.adminAuth}"></td>
<td th:text="${employeeInfoForm.nmDepartment}"></td>
</tr>
</tbody>
</table>
</th:block>
<th:block th:if="${employeeInfoFormList == null or employeeInfoFormList.size() == 0}">
<!-- 検索結果が0件の場合 -->
現在書籍貸出の申請はありません。
</th:block>
</body>
<script type="text/javascript">
function clearInput() {
document.getElementById('idRequest').value = '';
document.getElementById('idApplicant').value = '';
document.getElementById('nmBook').value = '';
document.getElementById('dateRequest').value = '';
document.getElementById('dateBorrow').value = '';
document.getElementById('dateReturn').value = '';
document.getElementById('dateRequest').selectedIndex = 0;
}
</script>
</html>

View File

@@ -0,0 +1,44 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<title>貸出中書籍一覧</title>
</head>
<body>
<h1>
<div class="rightSection">
<button class="logoutButton" onclick="logoutSubmit()">ログアウト</button>
</div>
<a href="menu">メニューに戻る</a>
<h1><span>検索結果</span></h1>
</h1>
<thead>
<tr>
<th style="width: 100px;">申請ID</th>
<th style="width: 100px;">申請者名</th>
<th style="width: 100px;">書籍名</th>
<th style="width: 100px;">申請日</th>
<th style="width: 100px;">貸出日</th>
<th style="width: 100px;">返却予定日</th>
<th style="width: 100px;">操作</th>
</tr>
</thead>
<tbody>
<tr th:each="">
<td th:text="${.idRequest}"></td>
<td th:text="${.}"></td>
<td th:text="${.}"></td>
<td th:text="${.dateRequest}"></td>
<td th:text="${.dateBorrow}"></td>
<td th:text="${.dateScheduledReturn}"></td>
<td>
<form action="" method="post" style="display: inline;">
<input name="" th:value="${}" type="hidden">
<input type="submit" value="返却">
</form>
</td>
</tbody>
</body>
</html>