Compare commits
5 Commits
adae4c5de5
...
service
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
341365aa81 | ||
|
|
5a5bfd9112 | ||
|
|
85d1d3715b | ||
|
|
16f4aacf23 | ||
|
|
307f8951b3 |
@@ -74,6 +74,7 @@
|
||||
<artifactId>spring-boot-starter-webmvc-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
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;
|
||||
//
|
||||
// }
|
||||
}
|
||||
@@ -45,32 +45,15 @@ public class SelectBookController {
|
||||
|
||||
// ① 書籍一覧の初期表示
|
||||
|
||||
@RequestMapping(value ="/selectBook", method = RequestMethod.POST)
|
||||
@RequestMapping(value ="/selectBook", method = RequestMethod.GET)
|
||||
public String select(Model model) {
|
||||
try {
|
||||
//貸出可能な書籍を全権取得する
|
||||
List<Book_collectionEntity> books = searchBook.selectAll();
|
||||
//検索結果をmodelに登録する
|
||||
model.addAttribute("books" , books);
|
||||
|
||||
//!!ここに管理者か一般ユーザか判断・でボタンを表示するための処理が必要
|
||||
|
||||
// 一旦コメントアウト
|
||||
// LoginUser loginUser = httpSession.getAttribute("loginUser");
|
||||
// //ログイン情報が存在しない場合はログイン画面へ
|
||||
// if(LoginUser == null) {
|
||||
// return "/login";
|
||||
// }
|
||||
// //LoginUserのisAdminUser()を呼び出す
|
||||
// //管理者ならtrue、一般社員ならfalse
|
||||
// boolean isAdmin = loginUser.isAdminUser();
|
||||
// //判定結果をModelに格納あうる
|
||||
// //HTMLでは"{isAdmin}"として使用
|
||||
// model.addAttribute("isAdmin",isAdmin);
|
||||
// // Sessionからログイン者情報を取得する
|
||||
|
||||
return "bookList";
|
||||
|
||||
//書籍一覧画面を表示する
|
||||
return "book-search";
|
||||
|
||||
}catch(Exception e) {
|
||||
//httpSessionを破棄
|
||||
@@ -83,45 +66,13 @@ public class SelectBookController {
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
|
||||
// ② 検索ボタン押下時の処理
|
||||
|
||||
@RequestMapping(value ="/selectBook", method = RequestMethod.GET)
|
||||
public String select(SearchConditionBookForm searchConditionBookForm, Model model) {
|
||||
try {
|
||||
List<Book_collectionEntity> books = searchBook.searchByWithLike(searchConditionBookForm);
|
||||
model.addAttribute("books", books);
|
||||
//
|
||||
//!!ここに管理者か一般ユーザか判断・でボタンを表示するための処理が必要?
|
||||
//
|
||||
// 一旦コメントアウト
|
||||
// LoginUser loginUser = httpSession.getAttribute("loginUser");
|
||||
// if(LoginUser == null) {
|
||||
// return "/login";
|
||||
// }
|
||||
// //LoginUserのisAdminUser()を呼び出す
|
||||
// //管理者ならtrue、一般社員ならfalse
|
||||
// boolean isAdmin = loginUser.isAdminUser();
|
||||
// //判定結果をModelに格納あうる
|
||||
// //HTMLでは"{isAdmin}"として使用
|
||||
// model.addAttribute("isAdmin",isAdmin);
|
||||
|
||||
return "bookList";
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
//httpSessionを破棄
|
||||
httpsession.invalidate();
|
||||
//エラー内容を出力
|
||||
e.printStackTrace();
|
||||
//ログにエラーを記録
|
||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||
//エラー画面へ遷移
|
||||
return "error";
|
||||
|
||||
}
|
||||
@RequestMapping(value ="/selectBook", method = RequestMethod.POST)
|
||||
public String ) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
// }
|
||||
}
|
||||
*/
|
||||
@@ -138,4 +138,4 @@ public class EmployeeEntity {
|
||||
// getIdUpdate(),
|
||||
// getDateUpdate());
|
||||
//}
|
||||
//}
|
||||
//}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
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;
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.example.demo.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@@ -7,5 +9,5 @@ import com.example.demo.entity.Borrow_booksEntity;
|
||||
|
||||
@Repository
|
||||
public interface Borrow_BooksRepository extends JpaRepository<Borrow_booksEntity, Integer> {
|
||||
|
||||
List<Borrow_booksEntity> findByStatus(Character status);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.example.demo.repository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@@ -7,6 +9,8 @@ import com.example.demo.entity.EmployeeEntity;
|
||||
|
||||
@Repository
|
||||
public interface EmployeeRepository extends JpaRepository<EmployeeEntity, Integer> {
|
||||
|
||||
|
||||
//メールアドレスとパスワードに合致するレコード
|
||||
Optional<EmployeeEntity> findByMailAddressAndPassword(String mailAddress, String password);
|
||||
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.example.demo.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@@ -9,8 +10,11 @@ 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;
|
||||
@@ -117,4 +121,79 @@ public class ReturnService {
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package com.example.demo.service;
|
||||
|
||||
public class S {
|
||||
|
||||
}
|
||||
@@ -1,162 +0,0 @@
|
||||
<!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>
|
||||
@@ -50,7 +50,7 @@
|
||||
<!-- 検索結果を表示-->
|
||||
<tbody>
|
||||
<!-- booksのデータを1件ずつ取り出す-->
|
||||
<tr th:each ="{book : ${books}">
|
||||
<td th:each="{book : ${books}}"></td>
|
||||
<!--ISBN-->
|
||||
<td th:each="{book.isbn}"></td>
|
||||
<!--書籍名-->
|
||||
@@ -63,11 +63,7 @@
|
||||
<td th:each="{book.noteText}"></td>
|
||||
<td>
|
||||
<!-- 管理者の場合は編集ボタン-->
|
||||
<!--一般ユーザーの場合は>
|
||||
|
||||
<form th:if = "${isAdmin}"
|
||||
th:action>
|
||||
|
||||
<!--一般ユーザーの場合は申請ボタン-->
|
||||
</td>
|
||||
|
||||
</table>
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
<!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>
|
||||
Reference in New Issue
Block a user