Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 15d510df3b | |||
| 43f91b4116 | |||
| f091771efc | |||
| bb9fdcca5e | |||
| ba81a9b50f |
@@ -74,7 +74,6 @@
|
||||
<artifactId>spring-boot-starter-webmvc-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -1,42 +1,50 @@
|
||||
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 ApprovalConfirmController {
|
||||
|
||||
// ログ出力用インスタンス
|
||||
//package com.example.demo.controller;
|
||||
//
|
||||
//import java.util.logging.Level;
|
||||
//import java.util.logging.Logger;
|
||||
//
|
||||
//import jakarta.servlet.http.HttpSession;
|
||||
//
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.stereotype.Controller;
|
||||
//import org.springframework.ui.Model;
|
||||
//import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
//import org.springframework.web.bind.annotation.RequestMapping;
|
||||
//import org.springframework.web.bind.annotation.RequestMethod;
|
||||
//
|
||||
//import com.example.demo.form.ApprovalForm;
|
||||
//
|
||||
///**
|
||||
// * 書籍貸出承認確認用のコントローラ
|
||||
// */
|
||||
//@Controller
|
||||
//public class ApprovalConfirmController {
|
||||
//
|
||||
// // ログ出力用インスタンス
|
||||
// private final static Logger LOGGER = Logger.getLogger(ApprovalConfirmController.class.getName());
|
||||
|
||||
// エラーメッセージ用の定数フィールド
|
||||
//
|
||||
// // エラーメッセージ用の定数フィールド
|
||||
// private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||
|
||||
//
|
||||
// HttpSession httpSession;
|
||||
// Request request;
|
||||
// ApprovalForm approvalform;
|
||||
//
|
||||
// @Autowired
|
||||
// public ApprovalConfirmController(
|
||||
// HttpSession httpSession,
|
||||
// Request request) {
|
||||
// ApprovalForm approvalform) {
|
||||
// this.httpSession = httpSession;
|
||||
// this.request = request;
|
||||
// this.approvalform = approvalform;
|
||||
// }
|
||||
//
|
||||
// @ModelAttribute
|
||||
// public ApprovalForm approvalForm() {
|
||||
// return new ApprovalForm();
|
||||
// }
|
||||
|
||||
@RequestMapping(value = "/approvalConfirm", method = RequestMethod.POST)
|
||||
public String AprrvalForm() {
|
||||
|
||||
System.out.println("a");
|
||||
return "bookList";
|
||||
//
|
||||
// @RequestMapping(value = "/ApprovalConfirm", method = RequestMethod.POST)
|
||||
// public String AprrvalForm(ApprovalForm ApprovalForm, Model model) {
|
||||
//
|
||||
// try {
|
||||
//
|
||||
//
|
||||
@@ -52,5 +60,5 @@ public class ApprovalConfirmController {
|
||||
// // エラー画面遷移
|
||||
// return "error";
|
||||
// }
|
||||
}
|
||||
}
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.example.demo.controller;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
/**
|
||||
* 書籍貸出完了・却下処理用のコントローラ
|
||||
*/
|
||||
@Controller
|
||||
public class ApprovalConfirmResultController {
|
||||
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
/*package com.example.demo.controller;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import main.java.com.example.rhizome.aop.aspect.PermissionCheck;
|
||||
import main.java.com.example.rhizome.aop.aspect.SessionCheck;
|
||||
import main.java.com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
||||
|
||||
/**
|
||||
* 書籍貸出申請に関する処理を制御するコントローラ
|
||||
*/
|
||||
/*@Controller
|
||||
public class LendingController {
|
||||
// ログ出力用インスタンス
|
||||
private final static Logger LOGGER = Logger.getLogger(LendingController.class.getName());
|
||||
// エラーメッセージ用の定数フィールド
|
||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||
|
||||
HttpSession httpSession;
|
||||
|
||||
//コンストラクタ注入(一番最初に動く処理)
|
||||
@Autowired
|
||||
public LendingController(HttpSession httpSession) {
|
||||
this.httpSession = httpSession;
|
||||
}
|
||||
|
||||
//画面を開くための初期化(!formクラス名要確認!)
|
||||
// @ModelAttribute
|
||||
// public LendingForm lendingForm() {
|
||||
// return new LendingForm();
|
||||
// }
|
||||
|
||||
// @PermissionCheck
|
||||
// @SessionCheck
|
||||
// @RequestMapping(value = "反応するURLを記載", method = RequestMethod.POST)
|
||||
// public String confirmLending(@ModelAttribute("lendingForm") LendingForm lendingForm, Model model) {
|
||||
// try {
|
||||
|
||||
// HTML側の th:object="${lendingForm}" に渡すデータをセット
|
||||
// model.addAllAttribute("lendingForm", lendingForm);
|
||||
// 貸出申請確認画面のHTML名を返す
|
||||
// return "applicationConform";
|
||||
// } catch (Exception e) {
|
||||
//ログイン情報の破棄
|
||||
// httpSession.invalidate();
|
||||
|
||||
// e.printStackTrace();
|
||||
|
||||
// エラーログ出力
|
||||
// LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||
// エラー画面遷移
|
||||
// return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
/**
|
||||
* 書籍貸出申請 実行処理
|
||||
*
|
||||
* @param lendingForm 確認画面の隠しフィールド(hidden)から引き継いだデータ
|
||||
* @param model ビューにデータを渡すためのコンテナ
|
||||
* @return 遷移先の画面
|
||||
*/
|
||||
//@PermissionCheck
|
||||
//@SessionCheck
|
||||
//@RequestMapping(value = "反応するURLを記載", method = RequestMethod.POST)
|
||||
//public String executeLending(@ModelAttribute("lendingForm") LendingForm lendingForm, Model model) {
|
||||
//final String LENDING_COMPLETE = "書籍申請完了しました";
|
||||
//try
|
||||
|
||||
//{
|
||||
|
||||
//} catch (Exception e) {
|
||||
// ログイン情報の破棄
|
||||
//httpSession.invalidate();
|
||||
//e.printStackTrace();
|
||||
|
||||
// エラーログ出力
|
||||
//LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||
// エラー画面遷移
|
||||
//return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||
//}
|
||||
//}
|
||||
//}
|
||||
@@ -1,77 +0,0 @@
|
||||
package com.example.demo.controller;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
import com.example.demo.form.LoginInfoForm;
|
||||
import com.example.demo.form.LoginUserForm;
|
||||
import com.example.demo.form.MessageForm;
|
||||
import com.example.demo.service.impl.Login;
|
||||
|
||||
@Controller
|
||||
public class LoginController {
|
||||
|
||||
// // ログ出力用インスタンス
|
||||
private static final Logger LOGGER = Logger.getLogger(LoginController.class.getName());
|
||||
|
||||
// ログイン処理を行う
|
||||
private final Login login;
|
||||
|
||||
// コンストラクタで部品を注入する(Autowired)
|
||||
@Autowired
|
||||
public LoginController(Login login) {
|
||||
this.login = login;
|
||||
}
|
||||
|
||||
// 画面で使うフォームの初期化
|
||||
@ModelAttribute
|
||||
public LoginUserForm loginUserForm() {
|
||||
return new LoginUserForm();
|
||||
}
|
||||
|
||||
// ログインボタンが押されたときの処理
|
||||
@PostMapping("/doLogin")
|
||||
public String doLogin(LoginInfoForm loginInfoForm, HttpSession session, Model model) {
|
||||
|
||||
try {
|
||||
// 入力チェック(メールアドレスやパスワードの形が正しいか)
|
||||
if (!LoginUserForm.checkParameter(loginInfoForm)) {
|
||||
// エラーメッセージと、入力されたデータを画面に返す
|
||||
model.addAttribute("messageError", new MessageForm("メールアドレス、パスワードの入力内容に誤りがあります"));
|
||||
model.addAttribute("loginInfoForm", loginInfoForm);
|
||||
return "login"; // login.html を表示
|
||||
}
|
||||
|
||||
// 認証チェック(IDとパスワードが一致するか)
|
||||
if (!login.canLogin(loginInfoForm)) {
|
||||
// 間違っている場合のメッセージを画面に返す
|
||||
model.addAttribute("messageError", new MessageForm("IDまたはパスワードが間違っています"));
|
||||
model.addAttribute("loginInfoForm", loginInfoForm);
|
||||
return "login"; // login.html を表示
|
||||
}
|
||||
|
||||
// ログイン処理の実行
|
||||
LoginUser loginUser = login.doLogin(loginInfoForm);
|
||||
|
||||
// セッション(サーバーの秘密のメモ帳)にユーザー情報を保存
|
||||
//「ログイン中」の状態
|
||||
session.setAttribute("loginUser", LoginUserForm.convertFrom(loginUser));
|
||||
|
||||
// 成功したらメニュー画面へ進む
|
||||
return "menu"; // menu.html を表示
|
||||
|
||||
} catch (Exception e) {
|
||||
// 予期せぬエラーが起きたら、セッションを消してエラー画面へ
|
||||
session.invalidate();
|
||||
LOGGER.error("エラーが発生しました!", e);
|
||||
return "error"; // error.html を表示
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
package com.example.demo.controller;
|
||||
|
||||
import static com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword.*;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
import com.example.rhizome.aop.aspect.PermissionCheck;
|
||||
import com.example.rhizome.aop.aspect.SessionCheck;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.PageReturnAttributeKeyword;
|
||||
import com.example.rhizome.app.presentation.controller.pageproperty.TransitionTargetPageNameKeyword;
|
||||
import com.example.rhizome.app.presentation.form.LoginUserForm;
|
||||
|
||||
@Controller
|
||||
public class LogoutController {
|
||||
// ログ出力用インスタンス
|
||||
private final static Logger LOGGER = Logger.getLogger(LogoutController.class.getName());
|
||||
// エラーメッセージ用の定数フィールド
|
||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||
|
||||
HttpSession httpSession;
|
||||
|
||||
@Autowired
|
||||
public LogoutController(HttpSession httpSession) {
|
||||
this.httpSession = httpSession;
|
||||
}
|
||||
|
||||
@ModelAttribute
|
||||
public LoginUserForm loginUserForm() {
|
||||
return new LoginUserForm();
|
||||
}
|
||||
|
||||
@PermissionCheck
|
||||
@SessionCheck
|
||||
@RequestMapping(value = LOGOUT, method = RequestMethod.POST)
|
||||
public String doLogout(Model model) {
|
||||
try {
|
||||
// セッション情報の破棄
|
||||
httpSession.invalidate();
|
||||
|
||||
// ログイン画面に遷移するための情報を設定
|
||||
model.addAttribute(PageReturnAttributeKeyword.LOGIN_INFO_FORM, loginUserForm());
|
||||
// login.html に遷移
|
||||
return TransitionTargetPageNameKeyword.LOGIN_HTML;
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
// エラーログ出力
|
||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||
// エラーページに遷移
|
||||
return TransitionTargetPageNameKeyword.ERROR_HTML;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
package com.example.demo.controller;
|
||||
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
import com.example.demo.form.ReturnForm;
|
||||
import com.example.demo.service.ReturnService;
|
||||
|
||||
//返却完了用のコントローラー
|
||||
@Controller
|
||||
public class ReturnCompleteController {
|
||||
|
||||
HttpSession httpSession;
|
||||
ReturnService rerurnService;
|
||||
|
||||
@Autowired
|
||||
public ReturnCompleteController(HttpSession httpSession, ReturnService rerurnService) {
|
||||
this.httpSession = httpSession;
|
||||
this.rerurnService = rerurnService;
|
||||
}
|
||||
|
||||
@ModelAttribute
|
||||
ReturnForm returnForm() {
|
||||
return new ReturnForm();
|
||||
}
|
||||
|
||||
//返却完了画面表示処理
|
||||
@RequestMapping(value = "/returnComplete", method = RequestMethod.POST)
|
||||
public String returnComplete(ReturnForm returnForm) {
|
||||
|
||||
try {
|
||||
//セッションからIDを拾いたい
|
||||
httpSession.getAttribute("");
|
||||
//いったん1ということで
|
||||
int id = 1;
|
||||
|
||||
rerurnService.setReturn(returnForm.getIdRequest(), id);
|
||||
|
||||
return "returnComplete";
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "エラー画面";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
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.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
import com.example.demo.form.ReturnForm;
|
||||
import com.example.demo.service.ReturnService;
|
||||
|
||||
@Controller
|
||||
public class ReturnConfirmController {
|
||||
|
||||
ReturnService rerurnService;
|
||||
|
||||
@Autowired
|
||||
ReturnConfirmController(ReturnService rerurnService) {
|
||||
this.rerurnService = rerurnService;
|
||||
}
|
||||
|
||||
@ModelAttribute
|
||||
ReturnForm returnForm() {
|
||||
return new ReturnForm();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/returnConfirm", method = { RequestMethod.POST, RequestMethod.GET })
|
||||
public String returnConfirm(Model model) {
|
||||
try {
|
||||
//仮の値を入れる
|
||||
Integer id = 1;
|
||||
//申請IDを元に取得
|
||||
ReturnForm resultForm = rerurnService.getReturnForm(id);
|
||||
resultForm.setIdRequest(id);
|
||||
|
||||
//returnFormに値をセット
|
||||
// 画面に返す為の情報をセット
|
||||
model.addAttribute("returnForm", resultForm);
|
||||
return "returnConfirm";
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "エラー画面";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
/*package com.example.demo.controller;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
import com.example.demo.entity.Book_collectionEntity;
|
||||
import com.example.demo.form.SearchConditionBookForm;
|
||||
import com.example.demo.service.SearchBook;
|
||||
|
||||
|
||||
|
||||
@Controller
|
||||
public class SelectBookController {
|
||||
|
||||
// ログ出力用インスタンス
|
||||
private final static Logger LOGGER = Logger.getLogger(SelectBookController.class.getName());
|
||||
// エラーメッセージ用の定数フィールド
|
||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||
|
||||
HttpSession httpsession;
|
||||
SearchBook searchBook;
|
||||
|
||||
@Autowired
|
||||
public SelectBookController(HttpSession httpSession, SearchBook searchBook) {
|
||||
this.httpsession = httpSession;
|
||||
this.searchBook = searchBook;
|
||||
}
|
||||
|
||||
//空の検索条件Form
|
||||
@ModelAttribute
|
||||
public SearchConditionBookForm searchConditionBookForm() {
|
||||
return new SearchConditionBookForm();
|
||||
}
|
||||
|
||||
// ① 書籍一覧の初期表示
|
||||
|
||||
@RequestMapping(value ="/selectBook", method = RequestMethod.GET)
|
||||
public String select(Model model) {
|
||||
try {
|
||||
//貸出可能な書籍を全権取得する
|
||||
List<Book_collectionEntity> books = searchBook.selectAll();
|
||||
//検索結果をmodelに登録する
|
||||
model.addAttribute("books" , books);
|
||||
//書籍一覧画面を表示する
|
||||
return "book-search";
|
||||
|
||||
}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 ) {
|
||||
|
||||
|
||||
|
||||
// }
|
||||
}
|
||||
*/
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.example.demo.entity;
|
||||
|
||||
import java.util.Date;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
@@ -23,6 +23,7 @@ import lombok.NoArgsConstructor;
|
||||
@AllArgsConstructor
|
||||
public class Book_collectionEntity {
|
||||
|
||||
|
||||
//蔵書ID
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@@ -46,7 +47,7 @@ public class Book_collectionEntity {
|
||||
private String pubLisher;
|
||||
|
||||
//特記事項
|
||||
@Column(name = "note", nullable = true)
|
||||
@Column(name = "note text", nullable = true)
|
||||
private String noteText;
|
||||
|
||||
//貸出フラグ -> charに変更する
|
||||
@@ -60,7 +61,7 @@ public class Book_collectionEntity {
|
||||
//更新日
|
||||
@Column(name = "date_update", nullable = false)
|
||||
@LastModifiedDate
|
||||
private Date dateUpdate;
|
||||
private Timestamp dateUpdate;
|
||||
|
||||
// public static Book_collection convertFrom(Book_collection book_collection) {
|
||||
// // 値を既に持ったインスタンスの生成に、コンストラクタを使用するとこうなります。
|
||||
@@ -91,6 +92,7 @@ public class Book_collectionEntity {
|
||||
// employeeEntity.setidUpdate(searchConditionEmployee.getidUpdate());
|
||||
// employeeEntity.setdateUpdate(searchConditionEmployee.getdateUupdate());
|
||||
|
||||
|
||||
//
|
||||
//// public static List<book_collection> createbook_collectionList(List<EmployeeEntity> employeeEntityList) {
|
||||
//// return employeeEntityList.stream().map(EmployeeEntity::createbook_collection).toList();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.example.demo.entity;
|
||||
|
||||
import java.security.Timestamp;
|
||||
import java.util.Date;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
@@ -7,9 +8,8 @@ import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
//import org.hibernate.annotations.Audited.Table;
|
||||
import org.hibernate.annotations.Audited.Table;
|
||||
import org.springframework.data.annotation.LastModifiedDate;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -97,5 +97,5 @@ public class Borrow_booksEntity {
|
||||
* */
|
||||
@Column(name = "date_update", nullable = false)
|
||||
@LastModifiedDate
|
||||
private Date dateUpdate;
|
||||
private Timestamp dateUpdate;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.example.demo.entity;
|
||||
|
||||
import java.util.Date;
|
||||
import java.security.Timestamp;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
@@ -81,7 +81,7 @@ public class EmployeeEntity {
|
||||
*/
|
||||
@Column(name = "date_update", nullable = false)
|
||||
@LastModifiedDate
|
||||
private Date dateUpdate;
|
||||
private Timestamp dateUpdate;
|
||||
}
|
||||
|
||||
// public static EmployeeEntity convertForm(Employee employee) {
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
package com.example.demo.form;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class LendingForm {
|
||||
/**
|
||||
* 蔵書ID
|
||||
*/
|
||||
private String id_book;
|
||||
/**
|
||||
* 書籍名
|
||||
*/
|
||||
private String nm_book;
|
||||
|
||||
//貸出日と返却予定日にアノテーションで日付や時刻の表示形式を指定
|
||||
|
||||
/**
|
||||
* 貸出日
|
||||
*/
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
//LocalDate型にて日付(年・月・日)を取り扱う
|
||||
private LocalDate date_borrow;
|
||||
|
||||
/**
|
||||
* 返却予定日
|
||||
*/
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private LocalDate date_scheduled_return;
|
||||
|
||||
//isNullメソッドを作り、未入力になってないか入力チェックを行う
|
||||
/**
|
||||
* 日付用の null 判定メソッド
|
||||
*/
|
||||
private static boolean isNull(LocalDate date) {
|
||||
return null == date;
|
||||
}
|
||||
|
||||
//画面でエラーが出た場合の表示
|
||||
//エラーが出た場合、リストに文言を追加する
|
||||
public List<String> validateParameter() {
|
||||
final String DATE_BORROW_NULL = "貸出日 が未入力です。";
|
||||
final String DATE_RETURN_NULL = "返却予定日 が未入力です。";
|
||||
final String DATE_ORDER_ERROR = "返却予定日 には、貸出日以降の日付を選択してください。";
|
||||
|
||||
List<String> error = new ArrayList<>();
|
||||
|
||||
// 1.「貸出日」が未入力(null)かどうかをチェックする
|
||||
if (date_borrow == null) {
|
||||
//errorリストの中にメッセージ"貸出日が未入力です"を入れる
|
||||
error.add(DATE_BORROW_NULL);
|
||||
}
|
||||
|
||||
// 2.「返却予定日」が未入力(null)かどうかをチェック
|
||||
if (date_scheduled_return == null) {
|
||||
//errorリストの中にメッセージ"返却予定日 が未入力です。"を入れる
|
||||
error.add(DATE_RETURN_NULL);
|
||||
}
|
||||
|
||||
//
|
||||
// 3「両方ともnullではない(入力されている)」ときのみ日付の前後を比較する
|
||||
if (date_borrow != null && date_scheduled_return != null) {
|
||||
|
||||
// 返却予定日が貸出日より過去の場合のエラー
|
||||
if (date_scheduled_return.isBefore(date_borrow)) {
|
||||
//errorリストの中にメッセージ"返却予定日 には、貸出日以降の日付を選択してください。"を入れる
|
||||
error.add(DATE_ORDER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package com.example.demo.form;
|
||||
|
||||
//ログイン情報
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
|
||||
public class LoginInfoForm {
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
private String mailAddress;
|
||||
/**
|
||||
* パスワード
|
||||
*/
|
||||
private String password;
|
||||
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
package com.example.demo.form;
|
||||
|
||||
import com.example.rhizome.app.domain.model.LoginUser;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
//ログインをする人
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class LoginUserForm {
|
||||
/**
|
||||
* 社員ID
|
||||
*/
|
||||
private Integer idEmployee;
|
||||
/**
|
||||
* 社員名
|
||||
*/
|
||||
private String nmEmployee;
|
||||
/**
|
||||
* 社員名よみ
|
||||
*/
|
||||
private String knEmployee;
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
private String mailAddress;
|
||||
/**
|
||||
* パスワード
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 管理者フラグ
|
||||
*/
|
||||
private Integer flgadmin;
|
||||
|
||||
/**
|
||||
* business 層の LoginUser クラスから画面用(presentation 層)の LoginUserForm に
|
||||
* 変換します。
|
||||
*
|
||||
* @param loginUser business 層の LoginUser インスタンス
|
||||
* @return クラスから画面用(presentation 層)の LoginUserForm
|
||||
*/
|
||||
public static LoginUserForm convertFrom(LoginUser loginUser) {
|
||||
return new LoginUserForm(
|
||||
loginUser.getIdEmployee(),
|
||||
loginUser.getNmEmployee(),
|
||||
loginUser.getKnEmployee(),
|
||||
loginUser.getMailAddress(),
|
||||
loginUser.getPassword(),
|
||||
loginUser.getGetFlgadmin()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public static LoginUserForm convertTo(LoginUser loginUserForm) {
|
||||
return new LoginUserForm(
|
||||
loginUserForm.getIdEmployee(),
|
||||
loginUserForm.getNmEmployee(),
|
||||
loginUserForm.getKnEmployee(),
|
||||
loginUserForm.getMailAddress(),
|
||||
loginUserForm.getPassword(),
|
||||
loginUserForm.getGetFlgadmin()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public static boolean checkParameter(LoginInfoForm loginInfoForm) {
|
||||
if (null == loginInfoForm.getMailAddress()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (loginInfoForm.getMailAddress().isBlank()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (null == loginInfoForm.getPassword()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !loginInfoForm.getPassword().isBlank();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理者権限を持っているか確認
|
||||
*
|
||||
* @return true:管理者権限を持っている , false:管理者権限を持っていない
|
||||
*/
|
||||
public boolean isAdminUser() {
|
||||
return getFlgadmin() == 1;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.example.demo.form;
|
||||
|
||||
//画面にエラー表示する
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class MessageForm {
|
||||
private String message;
|
||||
}
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
package com.example.demo.form;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ReturnForm {
|
||||
//申請ID
|
||||
private Integer idRequest;
|
||||
//申請者名//社員名
|
||||
private String nmEmployee;
|
||||
//申請日
|
||||
@DateTimeFormat(pattern = "yyyy-mm-dd")
|
||||
private Date dateRequest;
|
||||
//貸出日
|
||||
@DateTimeFormat(pattern = "yyyy-mm-dd")
|
||||
private Date dateBorrow;
|
||||
//返却予定日
|
||||
@DateTimeFormat(pattern = "yyyy-mm-dd")
|
||||
private Date dateScheduledReturn;
|
||||
//ISBN
|
||||
private String isBn;
|
||||
//書籍名
|
||||
private String nmBook;
|
||||
//出版社
|
||||
private String pubLisher;
|
||||
//特記事項
|
||||
private String noteText;
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.example.demo.form;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class SearchConditionBookForm {
|
||||
//書籍名
|
||||
private String nmBook;
|
||||
//出版社
|
||||
private String pubLisher;
|
||||
//特記事項
|
||||
private String noteText;
|
||||
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.example.demo.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
//ログインを試みる
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class LoginInfo {
|
||||
private String maillAddress;
|
||||
private String password;
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -8,4 +10,9 @@ import com.example.demo.entity.Borrow_booksEntity;
|
||||
@Repository
|
||||
public interface Borrow_BooksRepository extends JpaRepository<Borrow_booksEntity, Integer> {
|
||||
|
||||
/*
|
||||
* 申請者IDで検索
|
||||
* */
|
||||
Optional<Borrow_booksEntity> findByIdApplicant(Integer idApplicant);
|
||||
|
||||
}
|
||||
|
||||
@@ -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,6 @@ import com.example.demo.entity.EmployeeEntity;
|
||||
|
||||
@Repository
|
||||
public interface EmployeeRepository extends JpaRepository<EmployeeEntity, Integer> {
|
||||
|
||||
Optional<EmployeeEntity> findByMailAddressAndPassword(String mailAddress, String password);
|
||||
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package com.example.demo.service;
|
||||
|
||||
public interface ApprovalBorrowBooks {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
//package com.example.demo.service.Impl;
|
||||
//
|
||||
//import java.util.List;
|
||||
//
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.stereotype.Service;
|
||||
//import org.springframework.transaction.annotation.Transactional;
|
||||
//
|
||||
//import com.example.demo.repository.Borrow_BooksRepository;
|
||||
//import com.example.demo.service.ApprovalBorrowBooks;
|
||||
//
|
||||
//@Service
|
||||
//@Transactional
|
||||
//public class ApprovalBorrowBooksImpl implements ApprovalBorrowBooks {
|
||||
//
|
||||
// Borrow_BooksRepository borrowbooksRepository;
|
||||
//
|
||||
// @Autowired
|
||||
// public ApprovalBorrowBooksImpl(Borrow_BooksRepository borrowbooksRepository) {
|
||||
// this.borrowbooksRepository = borrowbooksRepository;
|
||||
// }
|
||||
//
|
||||
// /* 申請情報から全件取得
|
||||
// * @return 取得した情報すべて
|
||||
// */
|
||||
// public List<???> selectAll() {
|
||||
// return ???Entity.create???List(???Repository.findAll());
|
||||
// }
|
||||
//
|
||||
//
|
||||
//}
|
||||
@@ -1,97 +0,0 @@
|
||||
package com.example.demo.service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.example.demo.entity.Borrow_booksEntity;
|
||||
import com.example.demo.form.ReturnForm;
|
||||
import com.example.demo.repository.Book_CollectionRepository;
|
||||
import com.example.demo.repository.Borrow_BooksRepository;
|
||||
import com.example.demo.repository.EmployeeRepository;
|
||||
|
||||
@Service
|
||||
public class ReturnService {
|
||||
|
||||
Book_CollectionRepository book_CollectionRepository;
|
||||
Borrow_BooksRepository borrowRepository;
|
||||
EmployeeRepository employeeRepository;
|
||||
|
||||
@Autowired
|
||||
public ReturnService(
|
||||
Book_CollectionRepository book_CollectionRepository,
|
||||
Borrow_BooksRepository borrowRepository,
|
||||
EmployeeRepository employeeRepository) {
|
||||
this.book_CollectionRepository = book_CollectionRepository;
|
||||
this.borrowRepository = borrowRepository;
|
||||
this.employeeRepository = employeeRepository;
|
||||
}
|
||||
|
||||
public ReturnForm getReturnForm(int id) {
|
||||
ReturnForm result = new ReturnForm();
|
||||
Optional<Borrow_booksEntity> borrow = borrowRepository.findById(id);
|
||||
// System.out.println(borrow);
|
||||
result.setDateRequest(borrow.get().getDateRequest());//申請日
|
||||
result.setDateBorrow(borrow.get().getDateBorrow());//貸出日
|
||||
result.setDateScheduledReturn(borrow.get().getDateScheduledReturn());//返却予定日
|
||||
|
||||
var emp = employeeRepository.findById(borrow.get().getIdApplicant());
|
||||
result.setNmEmployee(emp.get().getNmEmployee());//申請者名、社員名
|
||||
|
||||
var book = book_CollectionRepository.findById(borrow.get().getIdBook());
|
||||
result.setIsBn(book.get().getIsBn());//ISBN
|
||||
result.setNmBook(book.get().getNmBook());//書籍名
|
||||
result.setPubLisher(book.get().getPubLisher());//出版社
|
||||
result.setNoteText(book.get().getNoteText());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setReturn(int id_request, int id_employee) {
|
||||
var borrow = borrowRepository.findById(id_request);
|
||||
var book = book_CollectionRepository.findById(borrow.get().getIdBook());
|
||||
book.get().setFlgLending('0');//「貸出フラグ」を【貸出可】
|
||||
borrow.get().setStatus('0');//貸出テーブルの「ステータス」を【返却済
|
||||
borrow.get().setDateReturn(new Date());//「返却日」を当日日付
|
||||
borrow.get().setIdUpdate(id_employee);//「更新者」を更新した人のID
|
||||
borrow.get().setDateUpdate(new Date());//「更新日」を当日日付に更新する。
|
||||
|
||||
borrowRepository.save(borrow.get());
|
||||
book_CollectionRepository.save(book.get());
|
||||
}
|
||||
|
||||
//貸出承認
|
||||
public void setReturnComplete(int id_request, int id_employee) {
|
||||
var borrow = borrowRepository.findById(id_request);
|
||||
var book = book_CollectionRepository.findById(borrow.get().getIdBook());
|
||||
|
||||
borrow.get().setStatus('2');//貸出テーブルの「ステータス」を【貸出中】
|
||||
borrow.get().setDateApproval(new Date());//「承認日」を当日日付
|
||||
borrow.get().setIdUpdate(id_employee);//「更新者」を更新した人のID
|
||||
borrow.get().setDateUpdate(new Date());//「更新日」を当日日付に更新する。
|
||||
|
||||
borrowRepository.save(borrow.get());
|
||||
book_CollectionRepository.save(book.get());
|
||||
|
||||
}
|
||||
|
||||
//却下
|
||||
//貸出テーブルの「ステータス」を【却下】、「更新者」を却下した人のID、「更新日」を当日日付に更新する。
|
||||
//また、蔵書テーブルの「貸出フラグ」を【貸出可】に更新する。
|
||||
public void setReturnRejected(int id_request, int id_employee) {
|
||||
|
||||
var borrow = borrowRepository.findById(id_request);
|
||||
var book = book_CollectionRepository.findById(borrow.get().getIdBook());
|
||||
|
||||
book.get().setFlgLending('0');//「貸出フラグ」を【貸出可】
|
||||
borrow.get().setStatus('9');//貸出テーブルの「ステータス」を【却下】
|
||||
borrow.get().setIdUpdate(id_employee);//「更新者」を却下した人のID
|
||||
borrow.get().setDateUpdate(new Date());//「更新日」を当日日付に更新する。
|
||||
|
||||
borrowRepository.save(borrow.get());
|
||||
book_CollectionRepository.save(book.get());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.example.demo.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.example.demo.entity.Book_collectionEntity;
|
||||
import com.example.demo.form.SearchConditionBookForm;
|
||||
|
||||
public interface SearchBook {
|
||||
|
||||
//貸出可能な書籍を全件取得する
|
||||
List<Book_collectionEntity> selectAll();
|
||||
|
||||
//書籍名・出版社・特記事項を条件に検索する
|
||||
List<Book_collectionEntity> searchByWithLike(SearchConditionBookForm form);
|
||||
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/*package com.example.demo.service.Impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.example.demo.repository.Borrow_BooksRepository;
|
||||
import com.example.demo.service.ApprovalBorrowBooks;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class ApprovalBorrowBooksImpl implements ApprovalBorrowBooks {
|
||||
|
||||
Borrow_BooksRepository borrowbooksRepository;
|
||||
|
||||
@Autowired
|
||||
public ApprovalBorrowBooksImpl(Borrow_BooksRepository borrowbooksRepository) {
|
||||
this.borrowbooksRepository = borrowbooksRepository;
|
||||
}
|
||||
|
||||
/* 申請情報から全件取得
|
||||
* @return 取得した情報すべて
|
||||
*/
|
||||
//public List<???> selectAll() {
|
||||
//return ???Entity.create???List(???Repository.findAll());
|
||||
//}
|
||||
|
||||
|
||||
//}
|
||||
//package com;
|
||||
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.example.demo.service.impl;
|
||||
|
||||
import com.example.demo.form.LoginInfoForm;
|
||||
import com.example.rhizome.app.domain.model.LoginUser;
|
||||
|
||||
public interface Login {
|
||||
LoginUser doLogin(LoginInfoForm loginInfo);
|
||||
|
||||
boolean canLogin(LoginInfoForm loginInfo);
|
||||
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<!--書籍貸出申請画面-->
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>書籍貸出申請</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!--右上にログイン者名、ログアウトボタン配置-->
|
||||
<div class="rightSection">
|
||||
<span class="loginInfo">ログイン者名:<span th:text="${session.loginUser.nmEmployee}"></span></span>
|
||||
<button class="logoutButton" onclick="logoutSubmit()">ログアウト</button>
|
||||
</div>
|
||||
|
||||
<!--クラス名確認すること(現在仮入力)-->
|
||||
<form th:action="@{/confirmLending}" id="lendingForm" method="post" th:object="${lendingForm}">
|
||||
<table>
|
||||
<!--蔵書ID、書籍名はreadonlyにて固定-->
|
||||
<tr>
|
||||
<th class="header">蔵書ID</th>
|
||||
<td><input type="text" th:field="*{id_book}" readonly="readonly"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">書籍名</th>
|
||||
<td><input type="text" th:field="*{nm_book}" readonly="readonly"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<!--input type ="date"にてカレンダー入力表示-->
|
||||
<!--required属性を追加、未入力をブラウザ側ではじく-->
|
||||
<!--Thymeleafにてエラー表示エリアを作成-->
|
||||
<th class="header">貸出日</th>
|
||||
<td><input type="date" th:field="*{date_borrow}" required></td>
|
||||
<span th:if="${#fields.hasErrors('date_borrow')}" th:errors="*{date_borrow}" style="color:red;"></span>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">返却予定日</th>
|
||||
<td><input type="date" th:field="*{date_scheduled_return}" required></td>
|
||||
<span th:if="${#fields.hasErrors('date_scheduled_return')}" th:errors="*{date_scheduled_return}"
|
||||
style="color:red;"></span>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="btnArea" colspan="2">
|
||||
<input type="submit" value="申請確認" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<!--書籍一覧に戻る処理、URL確認を行う-->
|
||||
<a th:href="@{/bookList}"> 書籍一覧に戻る</a>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,30 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<!--書籍貸出申請完了画面-->
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>書籍貸出申請完了</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!--右上にログイン者名、ログアウトボタン配置-->
|
||||
<div class="rightSection">
|
||||
<span class="loginInfo">ログイン者名:<span th:text="${session.loginUser.nmEmployee}"></span></span>
|
||||
<button class="logoutButton" onclick="logoutSubmit()">ログアウト</button>
|
||||
</div>
|
||||
|
||||
<!--見出し表示-->
|
||||
<h1>書籍貸出申請完了しました</h1>
|
||||
|
||||
<div class="navigation-links">
|
||||
<!--書籍一覧に戻る処理、URL確認を行う-->
|
||||
<a th:href="@{/bookList}"> 書籍一覧に戻る</a>
|
||||
|
||||
<!--メニュー画面に戻る処理、URL確認を行う-->
|
||||
<a th:href="@{/menu}">メニューに戻る</a>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,58 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<!--書籍貸出申請確認画面-->
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>書籍貸出申請確認</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!--右上にログイン者名、ログアウトボタン配置-->
|
||||
<div class="rightSection">
|
||||
<span class="loginInfo">ログイン者名:<span th:text="${session.loginUser.nmEmployee}"></span></span>
|
||||
<button class="logoutButton" onclick="logoutSubmit()">ログアウト</button>
|
||||
</div>
|
||||
<form th:action="@{/executeLending}" id="lendingConfirmForm" method="post" th:object="${lendingForm}">
|
||||
|
||||
<!--Java側へデータを引き継ぐための隠しフィールド(必須) -->
|
||||
<input type="hidden" th:field="*{id_book}" />
|
||||
<input type="hidden" th:field="*{nm_book}" />
|
||||
<input type="hidden" th:field="*{date_borrow}" />
|
||||
<input type="hidden" th:field="*{date_scheduled_return}" />
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<!-- 以下4項目<span>タグを用いてテキスト表示として画面に固定表示 -->
|
||||
<th class="header">蔵書ID</th>
|
||||
<td><span th:text="*{id_book}"></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">書籍名</th>
|
||||
<td><span th:text="*{nm_book}"></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">貸出日</th>
|
||||
<td><span th:text="${#temporals.format(*{date_borrow}, 'yyyy/MM/dd')}"></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">返却予定日</th>
|
||||
<td><span th:text="${#temporals.format(*{date_scheduled_return}, 'yyyy/MM/dd')}"></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="btnArea" colspan="2">
|
||||
<!-- 申請確定 -->
|
||||
<input type="submit" value="申請" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<!--申請情報入力(一つ前の画面)に戻る処理-->
|
||||
<!--ブラウザバック処理(history.back())を記述-->
|
||||
<div class="link-return-area">
|
||||
<a class="back-link" onclick="history.back()">申請情報入力に戻る</a>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
69
team1/src/main/resources/templates/applicationList.html
Normal file
69
team1/src/main/resources/templates/applicationList.html
Normal file
@@ -0,0 +1,69 @@
|
||||
<!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>
|
||||
<div class="rightSection">
|
||||
<button class="logoutButton" onclick="logoutSubmit()">ログアウト</button>
|
||||
</div>
|
||||
|
||||
<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="${employeeInfoFormList != null and employeeInfoFormList.size() > 0}">
|
||||
<!-- 検索結果が1件以上ある場合 -->
|
||||
<table class="table-grid table-striped table-hover">
|
||||
<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="employeeInfoForm : ${employeeInfoFormList}">
|
||||
<td th:text="${employeeInfoForm.idRequest}"></td>
|
||||
<td th:text="${employeeInfoForm.nmApplicant}"></td>
|
||||
<td th:text="${employeeInfoForm.nmBook}"></td>
|
||||
<td th:text="${employeeInfoForm.dateRequest}"></td>
|
||||
<td th:text="${employeeInfoForm.dateBorrow}"></td>
|
||||
<td th:text="${employeeInfoForm.dateReturn}"></td>
|
||||
<td th:text="${employeeInfoForm.dateRequest}"></td>
|
||||
|
||||
|
||||
<td>
|
||||
<form action="/approve" method="get">
|
||||
<input name="idRequest" th:value="${employeeInfoForm.idRequest}" type="hidden">
|
||||
<input type="submit" value="承認">
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</th:block>
|
||||
|
||||
<th:block th:if="${employeeInfoFormList == null or employeeInfoFormList.size() == 0}">
|
||||
<!-- 検索結果が0件の場合 -->
|
||||
現在書籍貸出の申請はありません。
|
||||
</th:block>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,40 +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>
|
||||
<h2>書籍貸出申請を承認しました。</h2>
|
||||
<br/>
|
||||
<a href="javascript:insertSubmit()">承認待ち一覧に戻る</a> | <a href="showMenu">メニューに戻る</a>
|
||||
</body>
|
||||
<script type="text/javascript">
|
||||
function insertSubmit() {
|
||||
const form = document.createElement('form');
|
||||
form.setAttribute('method', 'post');
|
||||
form.setAttribute('action', 'approvalConfirm');
|
||||
|
||||
// 動的送信用のHidden
|
||||
// 動的にFormを作成する場合は何かしら送信しないと、正しく動作しない
|
||||
const inputField = document.createElement("input");
|
||||
inputField.setAttribute("type", "hidden");
|
||||
inputField.setAttribute("value", "select");
|
||||
|
||||
form.appendChild(inputField);
|
||||
|
||||
// フォームをDOMに追加
|
||||
document.body.appendChild(form);
|
||||
|
||||
form.submit();
|
||||
}
|
||||
</script>
|
||||
</html>
|
||||
@@ -18,8 +18,10 @@
|
||||
</h1>
|
||||
<!-- 変数名は変更したが、中身は変更していない -->
|
||||
<!-- ボタンや遷移も手を付けていない -->
|
||||
<form action="approvalConfirm"
|
||||
method="post">
|
||||
<form action="insertEmployee"
|
||||
id="insertForm"
|
||||
method="post"
|
||||
th:object="${insertEmployeeForm}">
|
||||
|
||||
<div class="msgBox error" th:if="${messageError != null}">
|
||||
<span class="error" th:each="message : ${messageError.message}" th:text="${message}"></span>
|
||||
@@ -133,20 +135,7 @@
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="btnArea" colspan="2">
|
||||
<input type="submit" value="承認"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="btnArea" colspan="2">
|
||||
<input type="submit" value="却下"/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br/>
|
||||
<a href="javascript:insertSubmit()">承認待ち一覧に戻る</a>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,40 +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>
|
||||
<h2>書籍貸出申請を却下しました。</h2>
|
||||
<br/>
|
||||
<a href="javascript:insertSubmit()">承認待ち一覧に戻る</a> | <a href="showMenu">メニューに戻る</a>
|
||||
</body>
|
||||
<script type="text/javascript">
|
||||
function insertSubmit() {
|
||||
const form = document.createElement('form');
|
||||
form.setAttribute('method', 'post');
|
||||
form.setAttribute('action', 'approvalConfirm');
|
||||
|
||||
// 動的送信用のHidden
|
||||
// 動的にFormを作成する場合は何かしら送信しないと、正しく動作しない
|
||||
const inputField = document.createElement("input");
|
||||
inputField.setAttribute("type", "hidden");
|
||||
inputField.setAttribute("value", "select");
|
||||
|
||||
form.appendChild(inputField);
|
||||
|
||||
// フォームをDOMに追加
|
||||
document.body.appendChild(form);
|
||||
|
||||
form.submit();
|
||||
}
|
||||
</script>
|
||||
</html>
|
||||
@@ -1,72 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>書籍一覧・検索</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!--ログアウトボタン-->
|
||||
<a href="@{/logout}">ログアウト</a>
|
||||
<h2>書籍一覧・検索</h2>
|
||||
<!--Controllerと@{/selectBook}合わせる-->
|
||||
<form th:action ="@{/selectBook}" th:object = "${}"method="post">
|
||||
|
||||
<table>
|
||||
<!-- 書籍名-->
|
||||
<tr>
|
||||
<th class="header">書籍名</th>
|
||||
<td><input type="text" th:field="*{nmBook}"/></td>
|
||||
</tr>
|
||||
<!-- 出版社-->
|
||||
<tr>
|
||||
<th class="header">出版社</th>
|
||||
<td><input type="text" th:field="*{pubLisher}"></td>
|
||||
</tr>
|
||||
<!-- 特記事項-->
|
||||
<tr>
|
||||
<th class="header">特記事項</th>
|
||||
<td><input type="text" th:field="*{noteText}"></td>
|
||||
</tr>
|
||||
|
||||
<button type="submit">検索</button>
|
||||
</form>
|
||||
<!-- メニュー画面へ戻る-->
|
||||
<a th:href = "@{/menu}">メニューに戻る </a>
|
||||
<h3>検索結果</h3>
|
||||
<!-- 検索結果一覧-->
|
||||
<table border="1">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ISBN</th>
|
||||
<th>書籍名</th>
|
||||
<th>書籍名よみ</th>
|
||||
<th>出版社</th>
|
||||
<th>特記事項</th>
|
||||
<th style="width: 150px;">操作</th">
|
||||
</tr>
|
||||
</thead>
|
||||
<!-- 検索結果を表示-->
|
||||
<tbody>
|
||||
<!-- booksのデータを1件ずつ取り出す-->
|
||||
<td th:each="{book : ${books}}"></td>
|
||||
<!--ISBN-->
|
||||
<td th:each="{book.isbn}"></td>
|
||||
<!--書籍名-->
|
||||
<td th:each="{book.nmBook}"></td>
|
||||
<!--書籍名よみ-->
|
||||
<td th:each="{book.kmBook}"></td>
|
||||
<!--出版社-->
|
||||
<td th:each="{book.pubLisher}"></td>
|
||||
<!--特記事項-->
|
||||
<td th:each="{book.noteText}"></td>
|
||||
<td>
|
||||
<!-- 管理者の場合は編集ボタン-->
|
||||
<!--一般ユーザーの場合は申請ボタン-->
|
||||
</td>
|
||||
|
||||
</table>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,65 +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>ログイン</h1>
|
||||
<form action="doLogin"
|
||||
method="post"
|
||||
th:object="${loginInfoForm}">
|
||||
|
||||
<div class="msgBox error" th:if="${messageError} != null">
|
||||
<span class="error" th:text="${messageError.message}"></span>
|
||||
</div>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<!-- メアド記入欄 -->
|
||||
<th class="header">メールアドレス</th>
|
||||
<td style="width: 250px;">
|
||||
<input placeholder="メールアドレス"
|
||||
required="required"
|
||||
style="width: 100%;"
|
||||
th:field="*{mailAddress}"
|
||||
type="text"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<!-- パスワード記入欄 -->
|
||||
<th style="text-align: right;">パスワード</th>
|
||||
<td>
|
||||
<input placeholder="パスワード"
|
||||
required="required"
|
||||
style="width: 100%;"
|
||||
th:field="*{password}"
|
||||
type="password"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="btnArea" colspan="2">
|
||||
<input type="submit" value="ログイン"/>
|
||||
<button onclick="clearInput()">リセット</button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</body>
|
||||
<!-- 入力を消去 -->
|
||||
<script type="text/javascript">
|
||||
function clearInput() {
|
||||
document.getElementById('mailAddress').value = '';
|
||||
document.getElementById('password').value = '';
|
||||
}
|
||||
|
||||
</script>
|
||||
</html>
|
||||
@@ -1,22 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>書籍返却完了</title>
|
||||
</head>
|
||||
|
||||
|
||||
<div style="text-align: right;">
|
||||
<button class="logoutButton" onclick="logoutSubmit()">ログアウト</button>
|
||||
</div>
|
||||
<h2 style="text-align: center;">書籍の返却が完了しました</h2>
|
||||
|
||||
|
||||
<div style="text-align: center;">
|
||||
<!-- コントローラーのメソッド名-->
|
||||
<a href="lendingList">貸出中書籍一覧に戻る</a> | <a href="showMenu">メニューに戻る</a>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,137 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>書籍返却確認</title>
|
||||
</head>
|
||||
<body>
|
||||
<div style="text-align: right;">
|
||||
<button class="logoutButton" onclick="logoutSubmit()">ログアウト</button>
|
||||
</div>
|
||||
|
||||
|
||||
<form action ="returnComplete"
|
||||
method="post"
|
||||
th:object="${returnForm}">
|
||||
<table style="margin:auto">
|
||||
<tr>
|
||||
<th class="header">申請ID</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
name="idRequest"
|
||||
readonly="readonly"
|
||||
th:field="*{idRequest}"
|
||||
type="text" />
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">申請者名</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
name="nmEmployee"
|
||||
readonly="readonly"
|
||||
th:field="*{nmEmployee}"
|
||||
type="text" />
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">申請日</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
name="dateRequest"
|
||||
readonly="readonly"
|
||||
th:field="*{dateRequest}"
|
||||
type="text" />
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">ISBN</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
name="isBn"
|
||||
readonly="readonly"
|
||||
th:field="*{isBn}"
|
||||
type="text" />
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">書籍名</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
name="nmBook"
|
||||
readonly="readonly"
|
||||
th:field="*{nmBook}"
|
||||
type="text" />
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">出版社</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
name="pubLisher"
|
||||
readonly="readonly"
|
||||
th:field="*{pubLisher}"
|
||||
type="text" />
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">特記事項</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
name="noteText"
|
||||
readonly="readonly"
|
||||
th:field="*{noteText}"
|
||||
type="text" />
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">貸出日</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
name="dateBorrow"
|
||||
readonly="readonly"
|
||||
th:field="*{dateBorrow}"
|
||||
type="text" />
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">返却予定日</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
name="dateScheduledReturn"
|
||||
readonly="readonly"
|
||||
th:field="*{dateScheduledReturn}"
|
||||
type="text" />
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="text-align: right;">
|
||||
<td>
|
||||
<input type="submit" value="返却"/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- コントローラーのメソッド名-->
|
||||
<a href="lendingList">貸出中書籍一覧に戻る</a>
|
||||
</form>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
2
test/.gitattributes
vendored
2
test/.gitattributes
vendored
@@ -1,2 +0,0 @@
|
||||
/mvnw text eol=lf
|
||||
*.cmd text eol=crlf
|
||||
33
test/.gitignore
vendored
33
test/.gitignore
vendored
@@ -1,33 +0,0 @@
|
||||
HELP.md
|
||||
target/
|
||||
.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
3
test/.mvn/wrapper/maven-wrapper.properties
vendored
3
test/.mvn/wrapper/maven-wrapper.properties
vendored
@@ -1,3 +0,0 @@
|
||||
wrapperVersion=3.3.4
|
||||
distributionType=only-script
|
||||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.10.0/apache-maven-3.10.0-bin.zip
|
||||
295
test/mvnw
vendored
295
test/mvnw
vendored
@@ -1,295 +0,0 @@
|
||||
#!/bin/sh
|
||||
# ----------------------------------------------------------------------------
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Apache Maven Wrapper startup batch script, version 3.3.4
|
||||
#
|
||||
# Optional ENV vars
|
||||
# -----------------
|
||||
# JAVA_HOME - location of a JDK home dir, required when download maven via java source
|
||||
# MVNW_REPOURL - repo url base for downloading maven distribution
|
||||
# MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven
|
||||
# MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
set -euf
|
||||
[ "${MVNW_VERBOSE-}" != debug ] || set -x
|
||||
|
||||
# OS specific support.
|
||||
native_path() { printf %s\\n "$1"; }
|
||||
case "$(uname)" in
|
||||
CYGWIN* | MINGW*)
|
||||
[ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")"
|
||||
native_path() { cygpath --path --windows "$1"; }
|
||||
;;
|
||||
esac
|
||||
|
||||
# set JAVACMD and JAVACCMD
|
||||
set_java_home() {
|
||||
# For Cygwin and MinGW, ensure paths are in Unix format before anything is touched
|
||||
if [ -n "${JAVA_HOME-}" ]; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ]; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
JAVACCMD="$JAVA_HOME/jre/sh/javac"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
JAVACCMD="$JAVA_HOME/bin/javac"
|
||||
|
||||
if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then
|
||||
echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2
|
||||
echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
else
|
||||
JAVACMD="$(
|
||||
'set' +e
|
||||
'unset' -f command 2>/dev/null
|
||||
'command' -v java
|
||||
)" || :
|
||||
JAVACCMD="$(
|
||||
'set' +e
|
||||
'unset' -f command 2>/dev/null
|
||||
'command' -v javac
|
||||
)" || :
|
||||
|
||||
if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then
|
||||
echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# hash string like Java String::hashCode
|
||||
hash_string() {
|
||||
str="${1:-}" h=0
|
||||
while [ -n "$str" ]; do
|
||||
char="${str%"${str#?}"}"
|
||||
h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296))
|
||||
str="${str#?}"
|
||||
done
|
||||
printf %x\\n $h
|
||||
}
|
||||
|
||||
verbose() { :; }
|
||||
[ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; }
|
||||
|
||||
die() {
|
||||
printf %s\\n "$1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
trim() {
|
||||
# MWRAPPER-139:
|
||||
# Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds.
|
||||
# Needed for removing poorly interpreted newline sequences when running in more
|
||||
# exotic environments such as mingw bash on Windows.
|
||||
printf "%s" "${1}" | tr -d '[:space:]'
|
||||
}
|
||||
|
||||
scriptDir="$(dirname "$0")"
|
||||
scriptName="$(basename "$0")"
|
||||
|
||||
# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties
|
||||
while IFS="=" read -r key value; do
|
||||
case "${key-}" in
|
||||
distributionUrl) distributionUrl=$(trim "${value-}") ;;
|
||||
distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;;
|
||||
esac
|
||||
done <"$scriptDir/.mvn/wrapper/maven-wrapper.properties"
|
||||
[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties"
|
||||
|
||||
case "${distributionUrl##*/}" in
|
||||
maven-mvnd-*bin.*)
|
||||
MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/
|
||||
case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in
|
||||
*AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;;
|
||||
:Darwin*x86_64) distributionPlatform=darwin-amd64 ;;
|
||||
:Darwin*arm64) distributionPlatform=darwin-aarch64 ;;
|
||||
:Linux*x86_64*) distributionPlatform=linux-amd64 ;;
|
||||
*)
|
||||
echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2
|
||||
distributionPlatform=linux-amd64
|
||||
;;
|
||||
esac
|
||||
distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip"
|
||||
;;
|
||||
maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;;
|
||||
*) MVN_CMD="mvn${scriptName#mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;;
|
||||
esac
|
||||
|
||||
# apply MVNW_REPOURL and calculate MAVEN_HOME
|
||||
# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash>
|
||||
[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}"
|
||||
distributionUrlName="${distributionUrl##*/}"
|
||||
distributionUrlNameMain="${distributionUrlName%.*}"
|
||||
distributionUrlNameMain="${distributionUrlNameMain%-bin}"
|
||||
MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}"
|
||||
MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")"
|
||||
|
||||
exec_maven() {
|
||||
unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || :
|
||||
exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD"
|
||||
}
|
||||
|
||||
if [ -d "$MAVEN_HOME" ]; then
|
||||
verbose "found existing MAVEN_HOME at $MAVEN_HOME"
|
||||
exec_maven "$@"
|
||||
fi
|
||||
|
||||
case "${distributionUrl-}" in
|
||||
*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;;
|
||||
*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;;
|
||||
esac
|
||||
|
||||
# prepare tmp dir
|
||||
if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then
|
||||
clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; }
|
||||
trap clean HUP INT TERM EXIT
|
||||
else
|
||||
die "cannot create temp dir"
|
||||
fi
|
||||
|
||||
mkdir -p -- "${MAVEN_HOME%/*}"
|
||||
|
||||
# Download and Install Apache Maven
|
||||
verbose "Couldn't find MAVEN_HOME, downloading and installing it ..."
|
||||
verbose "Downloading from: $distributionUrl"
|
||||
verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName"
|
||||
|
||||
# select .zip or .tar.gz
|
||||
if ! command -v unzip >/dev/null; then
|
||||
distributionUrl="${distributionUrl%.zip}.tar.gz"
|
||||
distributionUrlName="${distributionUrl##*/}"
|
||||
fi
|
||||
|
||||
# verbose opt
|
||||
__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR=''
|
||||
[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v
|
||||
|
||||
# normalize http auth
|
||||
case "${MVNW_PASSWORD:+has-password}" in
|
||||
'') MVNW_USERNAME='' MVNW_PASSWORD='' ;;
|
||||
has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;;
|
||||
esac
|
||||
|
||||
if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then
|
||||
verbose "Found wget ... using wget"
|
||||
wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl"
|
||||
elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then
|
||||
verbose "Found curl ... using curl"
|
||||
curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl"
|
||||
elif set_java_home; then
|
||||
verbose "Falling back to use Java to download"
|
||||
javaSource="$TMP_DOWNLOAD_DIR/Downloader.java"
|
||||
targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName"
|
||||
cat >"$javaSource" <<-END
|
||||
public class Downloader extends java.net.Authenticator
|
||||
{
|
||||
protected java.net.PasswordAuthentication getPasswordAuthentication()
|
||||
{
|
||||
return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() );
|
||||
}
|
||||
public static void main( String[] args ) throws Exception
|
||||
{
|
||||
setDefault( new Downloader() );
|
||||
java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() );
|
||||
}
|
||||
}
|
||||
END
|
||||
# For Cygwin/MinGW, switch paths to Windows format before running javac and java
|
||||
verbose " - Compiling Downloader.java ..."
|
||||
"$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java"
|
||||
verbose " - Running Downloader.java ..."
|
||||
"$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")"
|
||||
fi
|
||||
|
||||
# If specified, validate the SHA-256 sum of the Maven distribution zip file
|
||||
if [ -n "${distributionSha256Sum-}" ]; then
|
||||
distributionSha256Result=false
|
||||
if [ "$MVN_CMD" = mvnd.sh ]; then
|
||||
echo "Checksum validation is not supported for maven-mvnd." >&2
|
||||
echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2
|
||||
exit 1
|
||||
elif command -v sha256sum >/dev/null; then
|
||||
if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c - >/dev/null 2>&1; then
|
||||
distributionSha256Result=true
|
||||
fi
|
||||
elif command -v shasum >/dev/null; then
|
||||
if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then
|
||||
distributionSha256Result=true
|
||||
fi
|
||||
else
|
||||
echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2
|
||||
echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ $distributionSha256Result = false ]; then
|
||||
echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2
|
||||
echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# unzip and move
|
||||
if command -v unzip >/dev/null; then
|
||||
unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip"
|
||||
else
|
||||
tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar"
|
||||
fi
|
||||
|
||||
# Find the actual extracted directory name (handles snapshots where filename != directory name)
|
||||
actualDistributionDir=""
|
||||
|
||||
# First try the expected directory name (for regular distributions)
|
||||
if [ -d "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" ]; then
|
||||
if [ -f "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/bin/$MVN_CMD" ]; then
|
||||
actualDistributionDir="$distributionUrlNameMain"
|
||||
fi
|
||||
fi
|
||||
|
||||
# If not found, search for any directory with the Maven executable (for snapshots)
|
||||
if [ -z "$actualDistributionDir" ]; then
|
||||
# enable globbing to iterate over items
|
||||
set +f
|
||||
for dir in "$TMP_DOWNLOAD_DIR"/*; do
|
||||
if [ -d "$dir" ]; then
|
||||
if [ -f "$dir/bin/$MVN_CMD" ]; then
|
||||
actualDistributionDir="$(basename "$dir")"
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
set -f
|
||||
fi
|
||||
|
||||
if [ -z "$actualDistributionDir" ]; then
|
||||
verbose "Contents of $TMP_DOWNLOAD_DIR:"
|
||||
verbose "$(ls -la "$TMP_DOWNLOAD_DIR")"
|
||||
die "Could not find Maven distribution directory in extracted archive"
|
||||
fi
|
||||
|
||||
verbose "Found extracted Maven distribution directory: $actualDistributionDir"
|
||||
printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$actualDistributionDir/mvnw.url"
|
||||
mv -- "$TMP_DOWNLOAD_DIR/$actualDistributionDir" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME"
|
||||
|
||||
clean || :
|
||||
exec_maven "$@"
|
||||
189
test/mvnw.cmd
vendored
189
test/mvnw.cmd
vendored
@@ -1,189 +0,0 @@
|
||||
<# : batch portion
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Licensed to the Apache Software Foundation (ASF) under one
|
||||
@REM or more contributor license agreements. See the NOTICE file
|
||||
@REM distributed with this work for additional information
|
||||
@REM regarding copyright ownership. The ASF licenses this file
|
||||
@REM to you under the Apache License, Version 2.0 (the
|
||||
@REM "License"); you may not use this file except in compliance
|
||||
@REM with the License. You may obtain a copy of the License at
|
||||
@REM
|
||||
@REM http://www.apache.org/licenses/LICENSE-2.0
|
||||
@REM
|
||||
@REM Unless required by applicable law or agreed to in writing,
|
||||
@REM software distributed under the License is distributed on an
|
||||
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
@REM KIND, either express or implied. See the License for the
|
||||
@REM specific language governing permissions and limitations
|
||||
@REM under the License.
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Apache Maven Wrapper startup batch script, version 3.3.4
|
||||
@REM
|
||||
@REM Optional ENV vars
|
||||
@REM MVNW_REPOURL - repo url base for downloading maven distribution
|
||||
@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven
|
||||
@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0)
|
||||
@SET __MVNW_CMD__=
|
||||
@SET __MVNW_ERROR__=
|
||||
@SET __MVNW_PSMODULEP_SAVE=%PSModulePath%
|
||||
@SET PSModulePath=
|
||||
@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @(
|
||||
IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B)
|
||||
)
|
||||
@SET PSModulePath=%__MVNW_PSMODULEP_SAVE%
|
||||
@SET __MVNW_PSMODULEP_SAVE=
|
||||
@SET __MVNW_ARG0_NAME__=
|
||||
@SET MVNW_USERNAME=
|
||||
@SET MVNW_PASSWORD=
|
||||
@IF NOT "%__MVNW_CMD__%"=="" ("%__MVNW_CMD__%" %*)
|
||||
@echo Cannot start maven from wrapper >&2 && exit /b 1
|
||||
@GOTO :EOF
|
||||
: end batch / begin powershell #>
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
if ($env:MVNW_VERBOSE -eq "true") {
|
||||
$VerbosePreference = "Continue"
|
||||
}
|
||||
|
||||
# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties
|
||||
$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl
|
||||
if (!$distributionUrl) {
|
||||
Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties"
|
||||
}
|
||||
|
||||
switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) {
|
||||
"maven-mvnd-*" {
|
||||
$USE_MVND = $true
|
||||
$distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip"
|
||||
$MVN_CMD = "mvnd.cmd"
|
||||
break
|
||||
}
|
||||
default {
|
||||
$USE_MVND = $false
|
||||
$MVN_CMD = $script -replace '^mvnw','mvn'
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
# apply MVNW_REPOURL and calculate MAVEN_HOME
|
||||
# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash>
|
||||
if ($env:MVNW_REPOURL) {
|
||||
$MVNW_REPO_PATTERN = if ($USE_MVND -eq $False) { "/org/apache/maven/" } else { "/maven/mvnd/" }
|
||||
$distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace "^.*$MVNW_REPO_PATTERN",'')"
|
||||
}
|
||||
$distributionUrlName = $distributionUrl -replace '^.*/',''
|
||||
$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$',''
|
||||
|
||||
$MAVEN_M2_PATH = "$HOME/.m2"
|
||||
if ($env:MAVEN_USER_HOME) {
|
||||
$MAVEN_M2_PATH = "$env:MAVEN_USER_HOME"
|
||||
}
|
||||
|
||||
if (-not (Test-Path -Path $MAVEN_M2_PATH)) {
|
||||
New-Item -Path $MAVEN_M2_PATH -ItemType Directory | Out-Null
|
||||
}
|
||||
|
||||
$MAVEN_WRAPPER_DISTS = $null
|
||||
if ((Get-Item $MAVEN_M2_PATH).Target[0] -eq $null) {
|
||||
$MAVEN_WRAPPER_DISTS = "$MAVEN_M2_PATH/wrapper/dists"
|
||||
} else {
|
||||
$MAVEN_WRAPPER_DISTS = (Get-Item $MAVEN_M2_PATH).Target[0] + "/wrapper/dists"
|
||||
}
|
||||
|
||||
$MAVEN_HOME_PARENT = "$MAVEN_WRAPPER_DISTS/$distributionUrlNameMain"
|
||||
$MAVEN_HOME_NAME = ([System.Security.Cryptography.SHA256]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join ''
|
||||
$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME"
|
||||
|
||||
if (Test-Path -Path "$MAVEN_HOME" -PathType Container) {
|
||||
Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME"
|
||||
Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD"
|
||||
exit $?
|
||||
}
|
||||
|
||||
if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) {
|
||||
Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl"
|
||||
}
|
||||
|
||||
# prepare tmp dir
|
||||
$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile
|
||||
$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir"
|
||||
$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null
|
||||
trap {
|
||||
if ($TMP_DOWNLOAD_DIR.Exists) {
|
||||
try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null }
|
||||
catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" }
|
||||
}
|
||||
}
|
||||
|
||||
New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null
|
||||
|
||||
# Download and Install Apache Maven
|
||||
Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..."
|
||||
Write-Verbose "Downloading from: $distributionUrl"
|
||||
Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName"
|
||||
|
||||
$webclient = New-Object System.Net.WebClient
|
||||
if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) {
|
||||
$webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD)
|
||||
}
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||
$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null
|
||||
|
||||
# If specified, validate the SHA-256 sum of the Maven distribution zip file
|
||||
$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum
|
||||
if ($distributionSha256Sum) {
|
||||
if ($USE_MVND) {
|
||||
Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties."
|
||||
}
|
||||
Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash
|
||||
if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) {
|
||||
Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property."
|
||||
}
|
||||
}
|
||||
|
||||
# unzip and move
|
||||
Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null
|
||||
|
||||
# Find the actual extracted directory name (handles snapshots where filename != directory name)
|
||||
$actualDistributionDir = ""
|
||||
|
||||
# First try the expected directory name (for regular distributions)
|
||||
$expectedPath = Join-Path "$TMP_DOWNLOAD_DIR" "$distributionUrlNameMain"
|
||||
$expectedMvnPath = Join-Path "$expectedPath" "bin/$MVN_CMD"
|
||||
if ((Test-Path -Path $expectedPath -PathType Container) -and (Test-Path -Path $expectedMvnPath -PathType Leaf)) {
|
||||
$actualDistributionDir = $distributionUrlNameMain
|
||||
}
|
||||
|
||||
# If not found, search for any directory with the Maven executable (for snapshots)
|
||||
if (!$actualDistributionDir) {
|
||||
Get-ChildItem -Path "$TMP_DOWNLOAD_DIR" -Directory | ForEach-Object {
|
||||
$testPath = Join-Path $_.FullName "bin/$MVN_CMD"
|
||||
if (Test-Path -Path $testPath -PathType Leaf) {
|
||||
$actualDistributionDir = $_.Name
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$actualDistributionDir) {
|
||||
Write-Error "Could not find Maven distribution directory in extracted archive"
|
||||
}
|
||||
|
||||
Write-Verbose "Found extracted Maven distribution directory: $actualDistributionDir"
|
||||
Rename-Item -Path "$TMP_DOWNLOAD_DIR/$actualDistributionDir" -NewName $MAVEN_HOME_NAME | Out-Null
|
||||
try {
|
||||
Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null
|
||||
} catch {
|
||||
if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) {
|
||||
Write-Error "fail to move MAVEN_HOME"
|
||||
}
|
||||
} finally {
|
||||
try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null }
|
||||
catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" }
|
||||
}
|
||||
|
||||
Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD"
|
||||
130
test/pom.xml
130
test/pom.xml
@@ -1,130 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>4.1.1</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>com.example</groupId>
|
||||
<artifactId>test</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>war</packaging>
|
||||
<name>test</name>
|
||||
<description/>
|
||||
<url/>
|
||||
<licenses>
|
||||
<license/>
|
||||
</licenses>
|
||||
<developers>
|
||||
<developer/>
|
||||
</developers>
|
||||
<scm>
|
||||
<connection/>
|
||||
<developerConnection/>
|
||||
<tag/>
|
||||
<url/>
|
||||
</scm>
|
||||
<properties>
|
||||
<java.version>21</java.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-webmvc</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<scope>runtime</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-thymeleaf-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-webmvc-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>default-compile</id>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>default-testCompile</id>
|
||||
<phase>test-compile</phase>
|
||||
<goals>
|
||||
<goal>testCompile</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.example.demo;
|
||||
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||
|
||||
public class ServletInitializer extends SpringBootServletInitializer {
|
||||
|
||||
@Override
|
||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
|
||||
return application.sources(TestApplication.class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.example.demo;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class TestApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(TestApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
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.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import com.example.demo.service.ReturnService;
|
||||
|
||||
@Controller
|
||||
public class ApplicationListController{
|
||||
|
||||
@Autowired
|
||||
ReturnService returnService;
|
||||
|
||||
public ApplicationListController(ReturnService returnService) {
|
||||
this.returnService = returnService;
|
||||
}
|
||||
|
||||
//applicationListにアクセスしたときに実行されるメソッド
|
||||
@RequestMapping(value = "/applicationList", method = { RequestMethod.POST, RequestMethod.GET })
|
||||
public String index(Model model) {
|
||||
//サービスから一覧を取得し、getAwaitingApprovalListという名前でHTMLに渡す
|
||||
model.addAttribute("applicationList", returnService.getAwaitingApprovalList());
|
||||
return "applicationList";
|
||||
}
|
||||
|
||||
// //メニュー画面に戻るURLへMapping
|
||||
// @RequestMapping(value = "/menu", method = RequestMethod.POST)
|
||||
// public String menu() {
|
||||
// return "menu";
|
||||
// }
|
||||
|
||||
//申請承認待ちページに遷移するためのMapping
|
||||
@RequestMapping(value = "/returnApproval", method = RequestMethod.POST)
|
||||
//返却確認ページにアクセスしたときに実行されるメソッド
|
||||
public String returnApproval(
|
||||
//URLから送られた申請IDを受け取る
|
||||
@RequestParam("idRequest") Integer idRequest, Model model) {
|
||||
//受け取った申請IDをidRequestという名前でModelに登録してHTMLに渡す
|
||||
model.addAttribute("idRequest", idRequest);
|
||||
//上記で渡すHTMLのURL
|
||||
return "returnApproval";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
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.ModelAttribute;
|
||||
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.form.ReturnForm;
|
||||
import com.example.demo.service.ReturnService;
|
||||
|
||||
/**
|
||||
* 書籍貸出承認確認用のコントローラ
|
||||
*/
|
||||
@Controller
|
||||
public class ApprovalConfirmController {
|
||||
|
||||
// HttpSession httpSession;
|
||||
ReturnService returnService;
|
||||
|
||||
@Autowired
|
||||
ApprovalConfirmController(ReturnService returnService) {
|
||||
this.returnService = returnService;
|
||||
}
|
||||
|
||||
@ModelAttribute
|
||||
ReturnForm returnForm() {
|
||||
return new ReturnForm();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/approvalConfirm", method = { RequestMethod.POST, RequestMethod.GET })
|
||||
public String ApporvalForm(@RequestParam("idRequest") int idRequest,Model model) {
|
||||
//System.out.println("a");
|
||||
try {
|
||||
//仮の値を入れる 貸出テーブルのID
|
||||
Integer id = idRequest;
|
||||
//申請IDを元に取得
|
||||
ReturnForm approvalresultForm = returnService.getReturnForm(id);
|
||||
approvalresultForm.setIdRequest(id);
|
||||
|
||||
//returnFormに値をセット
|
||||
// 画面に返す為の情報をセット
|
||||
model.addAttribute("returnForm", approvalresultForm);
|
||||
return "approvalConfirm";
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
package com.example.demo.controller;
|
||||
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
import com.example.demo.form.ReturnForm;
|
||||
import com.example.demo.service.ReturnService;
|
||||
|
||||
/**
|
||||
* 書籍貸出承認完了・却下処理用のコントローラ
|
||||
*/
|
||||
@Controller
|
||||
public class ApprovalConfirmResultController {
|
||||
|
||||
HttpSession httpSession;
|
||||
ReturnService returnService;
|
||||
|
||||
@Autowired
|
||||
public ApprovalConfirmResultController(HttpSession httpSession, ReturnService returnService) {
|
||||
this.httpSession = httpSession;
|
||||
this.returnService = returnService;
|
||||
}
|
||||
|
||||
@ModelAttribute
|
||||
ReturnForm returnForm() {
|
||||
return new ReturnForm();
|
||||
}
|
||||
|
||||
//承認完了画面表示処理
|
||||
@RequestMapping(value = "/approvalComplete", method = RequestMethod.POST)
|
||||
public String approvalComplete(ReturnForm returnForm) {
|
||||
|
||||
try {
|
||||
//セッションからIDを拾いたい
|
||||
//いったん1ということで
|
||||
int id =(int)httpSession.getAttribute("loginUser");;
|
||||
|
||||
returnService.setReturnComplete(returnForm.getIdRequest(), id);
|
||||
|
||||
return "approvalComplete";
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
|
||||
//却下完了画面表示処理
|
||||
@RequestMapping(value = "/approvalRejected", method = RequestMethod.POST)
|
||||
public String approvalRejected(ReturnForm returnForm) {
|
||||
|
||||
try {
|
||||
//セッションからIDを拾いたい
|
||||
httpSession.getAttribute("");
|
||||
//いったん1ということで
|
||||
int id =(int)httpSession.getAttribute("loginUser");;
|
||||
|
||||
returnService.setReturnRejected(returnForm.getIdRequest(), id);
|
||||
|
||||
return "approvalRejected";
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,141 +0,0 @@
|
||||
package com.example.demo.controller;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import com.example.demo.form.LendingForm;
|
||||
import com.example.demo.service.ReturnService;
|
||||
|
||||
@Controller
|
||||
public class LendingController {
|
||||
|
||||
// ログ出力用インスタンス
|
||||
private final static Logger LOGGER = Logger.getLogger(LendingController.class.getName());
|
||||
|
||||
// エラーメッセージ用の定数フィールド
|
||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||
|
||||
//まとめられたserviceクラスを入れる準備
|
||||
private final ReturnService returnService;
|
||||
private final HttpSession httpSession;
|
||||
|
||||
//アノテーションを使用してコンストラクタにインスタンスを代入する
|
||||
@Autowired
|
||||
public LendingController(ReturnService returnService,HttpSession httpSession) {
|
||||
this.returnService = returnService;
|
||||
this.httpSession=httpSession;
|
||||
}
|
||||
|
||||
/**
|
||||
* 【画面1】書籍貸出申請入力画面を表示する
|
||||
*/
|
||||
|
||||
@GetMapping("/requestLending")
|
||||
public String showLendingForm(
|
||||
//書籍一覧から送られてくる蔵書ID
|
||||
@RequestParam("idBook") int idBook,
|
||||
//書籍一覧から送られてくる書籍名
|
||||
@RequestParam("nmBook") String nmBook,
|
||||
Model model) {
|
||||
|
||||
LendingForm form = new LendingForm();
|
||||
|
||||
//前の画面(bookList)から貰ったデータの移し替え
|
||||
form.setIdBook(idBook);
|
||||
form.setNmBook(nmBook);
|
||||
|
||||
//次の画面(application.html)へ渡す
|
||||
model.addAttribute("lendingForm", form);
|
||||
return "application";
|
||||
}
|
||||
|
||||
/**
|
||||
* 申請画面から確認画面へ進む
|
||||
*/
|
||||
//@PostMappingでデータを送信(POST)
|
||||
@PostMapping("/confirmLending")
|
||||
public String confirmLending(@ModelAttribute("lendingForm") LendingForm form,
|
||||
BindingResult result, //
|
||||
Model model) {
|
||||
|
||||
validateParameter(form, result);
|
||||
|
||||
// result.hasErrors() でエラー判定
|
||||
if (result.hasErrors()) {
|
||||
// エラーが1つでもあったら入力画面に戻す
|
||||
return "application";
|
||||
}
|
||||
|
||||
return "applicationConfirm";
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 確認画面の「申請情報入力に戻る」文字を押すとリンクさせた入力画面へ戻る処理
|
||||
*/
|
||||
//@PostMappingで確認画面のデータ(hidden)を持ったまま送信(POST)
|
||||
@PostMapping("/backToRequest")
|
||||
public String backToRequest(@ModelAttribute("lendingForm") LendingForm form, Model model) {
|
||||
// 確認画面に隠されていたデータを、もう一度トレイ(Model)に載せて引き継ぐ
|
||||
model.addAttribute("lendingForm", form);
|
||||
// 1番目の入力画面「application.html」を表示して戻す(日付が残る!)
|
||||
return "application";
|
||||
}
|
||||
|
||||
/**
|
||||
* 確認画面の「申請」ボタンを押して完了画面へ遷移
|
||||
*/
|
||||
// @PostMappingでデータを送信(POST)
|
||||
@PostMapping("/executeLending")
|
||||
public String executeLending(@ModelAttribute("lendingForm") LendingForm form) {
|
||||
|
||||
// 1. 仮のログイン社員ID準備
|
||||
int loginEmployeeId = (int)httpSession.getAttribute("loginUser");
|
||||
|
||||
// 2. サービスクラス内の貸出申請機能を呼び出しを行う
|
||||
returnService.executeLending(form, loginEmployeeId);
|
||||
|
||||
// 3. redirectメソッドにて次画面である完了画面のURLへ接続し直す
|
||||
return "redirect:/lendingComplete";
|
||||
}
|
||||
|
||||
/**
|
||||
* 書籍貸出申請完了画面を表示する
|
||||
*/
|
||||
//@GetMappingでデータをもらう
|
||||
@GetMapping("/lendingComplete")
|
||||
public String showCompletePage() {
|
||||
return "applicationComplete";
|
||||
}
|
||||
|
||||
// 画面でエラーが出た場合の表示
|
||||
// エラーが出た場合、BindingResultに直接エラーを登録する
|
||||
public void validateParameter(LendingForm form, BindingResult result) {
|
||||
// 1.「貸出日」が未入力(null)かどうかをチェックする
|
||||
if (form.getDateBorrow() == null) {
|
||||
result.rejectValue("dateBorrow", "error.dateBorrow", "貸出日 が未入力です。");
|
||||
}
|
||||
// 2.「返却予定日」が未入力(null)かどうかをチェック
|
||||
if (form.getDateScheduledReturn() == null) {
|
||||
result.rejectValue("dateScheduledReturn", "error.dateScheduledReturn", "返却予定日 が未入力です。");
|
||||
}
|
||||
// 3「両方ともnullではない(入力されている)」ときのみ日付の前後を比較する
|
||||
if (form.getDateBorrow() != null && form.getDateScheduledReturn() != null) {
|
||||
if (form.getDateScheduledReturn().before(form.getDateBorrow())) {
|
||||
// 日付の前後エラーを返却予定日のエラーとして登録
|
||||
result.rejectValue("dateScheduledReturn", "error.dateOrder", "返却予定日 には、貸出日以降の日付を選択してください。");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
package com.example.demo.controller;
|
||||
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
|
||||
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 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.ReturnService;
|
||||
|
||||
@Controller
|
||||
public class LendingListController {
|
||||
|
||||
@Autowired
|
||||
ReturnService returnService;
|
||||
|
||||
public LendingListController(ReturnService returnService) {
|
||||
this.returnService = returnService;
|
||||
}
|
||||
|
||||
//貸出中書籍一覧を表示
|
||||
@RequestMapping(value = "/lendingList", method = { RequestMethod.POST, RequestMethod.GET })
|
||||
//lendingListにアクセスしたときに実行されるメソッド
|
||||
public String index(Model model) {
|
||||
//サービスと連携する処理
|
||||
//サービスから一覧を取得し、borrowListという名前でHTMLに渡す
|
||||
model.addAttribute("borrowList", returnService.getBorrowList());
|
||||
//表示するHTML
|
||||
return "lendingList";
|
||||
}
|
||||
@RequestMapping(value = "/menu", method = RequestMethod.GET)
|
||||
|
||||
@PostMapping("/menu")
|
||||
public String menu(HttpSession session, Model model) {
|
||||
Character FlgAdmin = (Character) session.getAttribute("FlgAdmin");
|
||||
model.addAttribute("FlgAdmin", FlgAdmin);
|
||||
if(FlgAdmin=='1') {
|
||||
return "admin_menu";
|
||||
}
|
||||
return "menu";
|
||||
}
|
||||
// //メニューに戻る
|
||||
// @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")//登録されているデータを取得する役割を果たす
|
||||
// public String show(Model model) {
|
||||
// List<X> x = xservice.getX();
|
||||
// model.addAttribute("Y", x);
|
||||
// return LendingListService.select;
|
||||
// }
|
||||
//
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
package com.example.demo.controller;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
|
||||
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.PostMapping;
|
||||
|
||||
import com.example.demo.form.LoginInfoForm;
|
||||
import com.example.demo.form.LoginUserForm;
|
||||
import com.example.demo.form.MessageForm;
|
||||
import com.example.demo.repository.EmployeeRepository;
|
||||
import com.example.demo.service.ReturnService;
|
||||
|
||||
@Controller
|
||||
public class LoginController {
|
||||
|
||||
// // ログ出力用インスタンス
|
||||
private static final Logger LOGGER = Logger.getLogger(LoginController.class.getName());
|
||||
|
||||
@Autowired
|
||||
ReturnService service;
|
||||
@Autowired
|
||||
EmployeeRepository repo;
|
||||
|
||||
@GetMapping("/login")
|
||||
public String view(Model model) {
|
||||
model.addAttribute("loginInfoForm",new LoginInfoForm());
|
||||
return "login";
|
||||
}
|
||||
|
||||
// ログインボタンが押されたときの処理
|
||||
@PostMapping("/doLogin")
|
||||
public String doLogin(LoginInfoForm form, HttpSession session, Model model) {
|
||||
|
||||
// 入力チェック(メールアドレスやパスワードの形が正しいか)
|
||||
if (!LoginUserForm.checkParameter(form)) {
|
||||
// エラーメッセージと、入力されたデータを画面に返す
|
||||
model.addAttribute("messageError", new MessageForm("メールアドレス、パスワードの入力内容に誤りがあります"));
|
||||
model.addAttribute("loginInfoForm", form);
|
||||
return "login"; // login.html を表示
|
||||
}
|
||||
|
||||
// 認証チェック(メールアドレスとパスワードが一致するか)
|
||||
if (service.canlogin(form.getMailAddress(), form.getPassword()) == false) {
|
||||
// 間違っている場合のメッセージを画面に返す
|
||||
model.addAttribute("messageError", new MessageForm("IDまたはパスワードが間違っています"));
|
||||
model.addAttribute("loginInfoForm", form);
|
||||
return "login"; // login.html を表示
|
||||
}
|
||||
|
||||
int userId = service.getUserID(form);
|
||||
session.setAttribute("loginUser", userId);// セッションにユーザー情報を保存 = 「ログイン中」の状態
|
||||
String userName=repo.findById(userId).get().getNmEmployee();
|
||||
session.setAttribute("loginName" ,userName);
|
||||
|
||||
//管理者チェック
|
||||
Character adminFlg = service.getUserFlg(form);
|
||||
if (adminFlg != null && adminFlg == '1') {
|
||||
// return "admin_menu";//admin_menuを表示
|
||||
}
|
||||
session.setAttribute("FlgAdmin", adminFlg);
|
||||
|
||||
model.addAttribute("FlgAdmin", adminFlg);
|
||||
|
||||
// 成功したらメニュー画面へ進む
|
||||
if(adminFlg=='1') {
|
||||
return "admin_menu";
|
||||
}
|
||||
return "menu"; // menu.html を表示
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.example.demo.controller;
|
||||
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
|
||||
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.form.LoginInfoForm;
|
||||
|
||||
@Controller
|
||||
public class LogoutController {
|
||||
@Autowired
|
||||
HttpSession session;
|
||||
|
||||
@PostMapping("/doLogout")
|
||||
public String doLogout(Model model) {
|
||||
//セッションをすべて破棄
|
||||
session.invalidate();
|
||||
model.addAttribute("loginInfoForm",new LoginInfoForm());
|
||||
return "login";
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.example.demo.controller;
|
||||
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
|
||||
@Controller
|
||||
public class MenuController {
|
||||
|
||||
// @RequestMapping(value = "/menu", method = RequestMethod.GET)
|
||||
// public String showmenu() {
|
||||
// return "menu";
|
||||
// }
|
||||
|
||||
@PostMapping("/menu")
|
||||
public String menu(HttpSession session, Model model) {
|
||||
Character FlgAdmin = (Character) session.getAttribute("FlgAdmin");
|
||||
model.addAttribute("FlgAdmin", FlgAdmin);
|
||||
if(FlgAdmin=='1') {
|
||||
return "admin_menu";
|
||||
}
|
||||
return "menu";
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package com.example.demo.controller;
|
||||
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
import com.example.demo.form.ReturnForm;
|
||||
import com.example.demo.service.ReturnService;
|
||||
|
||||
//返却完了用のコントローラー
|
||||
@Controller
|
||||
public class ReturnCompleteController {
|
||||
|
||||
HttpSession httpSession;
|
||||
ReturnService returnService;
|
||||
|
||||
@Autowired
|
||||
public ReturnCompleteController(HttpSession httpSession, ReturnService returnService) {
|
||||
this.httpSession = httpSession;
|
||||
this.returnService = returnService;
|
||||
}
|
||||
|
||||
@ModelAttribute
|
||||
ReturnForm returnForm() {
|
||||
return new ReturnForm();
|
||||
}
|
||||
|
||||
//返却完了画面表示処理
|
||||
@RequestMapping(value = "/returnComplete", method = RequestMethod.POST)
|
||||
public String returnComplete(ReturnForm returnForm) {
|
||||
|
||||
try {
|
||||
//いったん1ということで
|
||||
int id = 1;
|
||||
//sessionから
|
||||
id=(int)httpSession.getAttribute("loginUser");
|
||||
returnService.setReturn(returnForm.getIdRequest(), id);
|
||||
|
||||
return "returnComplete";
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "error";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
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.ModelAttribute;
|
||||
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.form.ReturnForm;
|
||||
import com.example.demo.service.ReturnService;
|
||||
|
||||
@Controller
|
||||
public class ReturnConfirmController {
|
||||
|
||||
ReturnService returnService;
|
||||
|
||||
@Autowired
|
||||
ReturnConfirmController(ReturnService returnService) {
|
||||
this.returnService = returnService;
|
||||
}
|
||||
|
||||
@ModelAttribute
|
||||
ReturnForm returnForm() {
|
||||
return new ReturnForm();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/returnConfirm", method = { RequestMethod.POST, RequestMethod.GET })
|
||||
public String returnConfirm(@RequestParam("idRequest") int idRequest,Model model) {
|
||||
try {
|
||||
//仮の値を入れる
|
||||
Integer id = idRequest;
|
||||
//申請IDを元に取得
|
||||
ReturnForm resultForm = returnService.getReturnForm(id);
|
||||
resultForm.setIdRequest(id);
|
||||
|
||||
//returnFormに値をセット
|
||||
// 画面に返す為の情報をセット
|
||||
model.addAttribute("returnForm", resultForm);
|
||||
return "returnConfirm";
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,141 +0,0 @@
|
||||
package com.example.demo.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
import com.example.demo.entity.Book_collectionEntity;
|
||||
import com.example.demo.form.SearchConditionBookForm;
|
||||
import com.example.demo.service.ReturnService;
|
||||
|
||||
@Controller
|
||||
public class SelectBookController {
|
||||
|
||||
// ログ出力用インスタンス
|
||||
private final static Logger LOGGER = Logger.getLogger(SelectBookController.class.getName());
|
||||
// エラーメッセージ用の定数フィールド
|
||||
private final static String SEVERE_ERROR_MESSAGE = "エラーが発生しました!";
|
||||
|
||||
HttpSession httpsession;
|
||||
ReturnService returnService;
|
||||
|
||||
@Autowired
|
||||
public SelectBookController(HttpSession httpSession, ReturnService returnService) {
|
||||
this.httpsession = httpSession;
|
||||
this.returnService = returnService;
|
||||
}
|
||||
|
||||
//空の検索条件Form
|
||||
@ModelAttribute("bookSearchForm")
|
||||
public SearchConditionBookForm searchConditionBookForm() {
|
||||
return new SearchConditionBookForm();
|
||||
}
|
||||
|
||||
// ① 書籍一覧の初期表示
|
||||
|
||||
@RequestMapping(value = "/selectBook", method = RequestMethod.GET)
|
||||
public String selectBook(Model model) {
|
||||
try {
|
||||
//貸出可能な書籍を全て取得
|
||||
List<Book_collectionEntity> books = returnService.availableSelectAll();
|
||||
|
||||
//取得した書籍情報をModelに登録する
|
||||
model.addAttribute("books", books);
|
||||
//
|
||||
// //管理者か一般ユーザかを判定
|
||||
// boolean isAdmin = loginUser.isAdminUser();
|
||||
//
|
||||
// //判定結果をModelに登録する
|
||||
// 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 select(@ModelAttribute("bookSearchForm") SearchConditionBookForm searchConditionBookForm,
|
||||
Model model) {
|
||||
try {
|
||||
|
||||
System.out.println("検索処理が実行されました");
|
||||
// HTMLから受け取った書籍名を確認する
|
||||
System.out.println("書籍名:" + searchConditionBookForm.getNmBook());
|
||||
// Serviceを呼び出して検索する
|
||||
List<Book_collectionEntity> books = returnService.searchByWithLike(searchConditionBookForm);
|
||||
// 検索結果の件数を確認する
|
||||
System.out.println("検索結果;" + books.size() + "件");
|
||||
// 検索結果をModelに登録する
|
||||
model.addAttribute("books", books);
|
||||
model.addAttribute("searched", true);
|
||||
// 書籍一覧画面へ遷移
|
||||
return "bookList";
|
||||
|
||||
// // 検索結果をModelに登録する
|
||||
// model.addAttribute("books", books);
|
||||
// // 書籍一覧画面へ遷移
|
||||
// return "bookList";
|
||||
|
||||
// model.addAttribute("isAdmin" , isAdmin);
|
||||
// return "bookList";
|
||||
|
||||
} catch (Exception e) {
|
||||
//httpSessionを破棄
|
||||
httpsession.invalidate();
|
||||
//エラー内容を出力
|
||||
e.printStackTrace();
|
||||
//ログにエラーを記録
|
||||
LOGGER.log(Level.SEVERE, SEVERE_ERROR_MESSAGE, e);
|
||||
//エラー画面へ遷移
|
||||
return "error";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// //書籍一覧画面へ遷移
|
||||
// model.addAttribute("isAdmin", isAdmin);
|
||||
//return "bookList";
|
||||
////貸出可能な書籍を全権取得する
|
||||
////List<Book_collectionEntity> books = returnService.availableSelectAll();
|
||||
////検索結果をmodelに登録する
|
||||
//model.addAttribute("books" , books);
|
||||
//
|
||||
//!!ここに管理者か一般ユーザか判断・でボタンを表示するための処理が必要
|
||||
|
||||
////一旦コメントアウト
|
||||
//LoginUser loginUser = (LoginUser)httpSession.getAttribute("loginUser");
|
||||
|
||||
//
|
||||
//
|
||||
////LoginUserのisAdminUser()を呼び出す
|
||||
|
||||
//////管理者ならtrue、一般社員ならfalse
|
||||
//boolean isAdmin = loginUser.isAdminUser();
|
||||
//////判定結果をModelに格納あうる
|
||||
//////HTMLでは"{isAdmin}"として使用
|
||||
//model.addAttribute("isAdmin",isAdmin);
|
||||
////// Sessionからログイン者情報を取得する
|
||||
//
|
||||
@@ -1,121 +0,0 @@
|
||||
package com.example.demo.entity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
import org.springframework.data.annotation.LastModifiedDate;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
//テーブル名
|
||||
@Table(name = "book_collection")
|
||||
@Entity
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Book_collectionEntity {
|
||||
|
||||
//蔵書ID
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id_book", nullable = false)
|
||||
private Integer idBook;
|
||||
|
||||
//ISBN
|
||||
@Column(name = "isbn", nullable = false, length = 13)
|
||||
private String isBn;
|
||||
|
||||
//書籍名
|
||||
@Column(name = "nm_book", nullable = false, length = 50)
|
||||
private String nmBook;
|
||||
|
||||
//書籍名よみ
|
||||
@Column(name = "kn_book", nullable = true, length = 100)
|
||||
private String knBook;
|
||||
|
||||
//出版社
|
||||
@Column(name = "publisher", nullable = true, length = 50)
|
||||
private String pubLisher;
|
||||
|
||||
//特記事項
|
||||
@Column(name = "note", nullable = true)
|
||||
private String noteText;
|
||||
|
||||
//貸出フラグ -> charに変更する
|
||||
@Column(name = "flg_lending", nullable = false, columnDefinition = "default 0")
|
||||
private Character flgLending;
|
||||
|
||||
//更新者
|
||||
@Column(name = "id_update", nullable = false)
|
||||
private Integer idUpdate;
|
||||
|
||||
//更新日
|
||||
@Column(name = "date_update", nullable = false)
|
||||
@LastModifiedDate
|
||||
private Date dateUpdate;
|
||||
|
||||
// public static Book_collection convertFrom(Book_collection book_collection) {
|
||||
// // 値を既に持ったインスタンスの生成に、コンストラクタを使用するとこうなります。
|
||||
// return new Book_collection Entity(
|
||||
// book_colletion.getIdBook(),
|
||||
// book_colletion.getisBn(),
|
||||
// book_colletion.getnmBook(),
|
||||
// book_colletion..getknBook(),
|
||||
// book_colletion.getpublisher(),
|
||||
// book_colletion.getnoteText(),
|
||||
// book_colletion.getflgLending(),
|
||||
// book_colletion.getidUpdate(),
|
||||
// book_colletion.getdateUupdate()
|
||||
// );
|
||||
//
|
||||
//}
|
||||
//public static EmployeeEntity convertFrom(SearchConditionEmployee searchConditionEmployee) {
|
||||
// EmployeeEntity employeeEntity = new EmployeeEntity();
|
||||
//
|
||||
// employeeEntity.setIdBook(searchConditionEmployee.getIdBook());
|
||||
// employeeEntity.setisBn(searchConditionEmployee.getisBn());
|
||||
// employeeEntity.setnmBook(searchConditionEmployee.getnmBook());
|
||||
|
||||
// employeeEntity.setknBook(searchConditionEmployee.knBook());
|
||||
// employeeEntity.setpublisher(searchConditionEmployee.getpublisher());
|
||||
// employeeEntity.setnoteText(searchConditionEmployee.getnoteText());
|
||||
// employeeEntity.setflgLending(searchConditionEmployee.getflgLending());
|
||||
// employeeEntity.setidUpdate(searchConditionEmployee.getidUpdate());
|
||||
// employeeEntity.setdateUpdate(searchConditionEmployee.getdateUupdate());
|
||||
|
||||
//
|
||||
//// public static List<book_collection> createbook_collectionList(List<EmployeeEntity> employeeEntityList) {
|
||||
//// return employeeEntityList.stream().map(EmployeeEntity::createbook_collection).toList();
|
||||
//// }
|
||||
//
|
||||
// List<book_collection> book_collectionList = new ArrayList<>();
|
||||
// for(book_collectionEntity book_collectionEntity:employeeEntityList){
|
||||
// book_collection employee = book_collectionEntity.createbook_collection(book_collectionEntity);
|
||||
// book_collectionList.add(employee);
|
||||
// }
|
||||
// return employeeList;
|
||||
//
|
||||
//
|
||||
// public LoginUser createLoginUser() {
|
||||
// // 値を既に持ったインスタンスの生成に、コンストラクタを使用するとこうなります。
|
||||
// return new LoginUser(
|
||||
// getidBook(),
|
||||
// getisBn(),
|
||||
// getnmBook(),
|
||||
// getknBook(),
|
||||
// getpublisher(),
|
||||
// getnoteText(),
|
||||
// getflgLending(),
|
||||
// getidUpdate(),
|
||||
// getdateUpdate()
|
||||
// );
|
||||
// }
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
package com.example.demo.entity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
//import org.hibernate.annotations.Audited.Table;
|
||||
import org.springframework.data.annotation.LastModifiedDate;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Entity
|
||||
@Table(name = "borrow_books")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
|
||||
public class Borrow_booksEntity {
|
||||
|
||||
/*
|
||||
* 申請ID
|
||||
* */
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id_request", nullable = false)
|
||||
private Integer idRequest;
|
||||
|
||||
/*
|
||||
* 申請者ID
|
||||
* */
|
||||
@Column(name = "id_applicant", nullable = false)
|
||||
private Integer idApplicant;
|
||||
|
||||
/*
|
||||
* 蔵書ID
|
||||
* */
|
||||
@Column(name = "id_book", nullable = false)
|
||||
private Integer idBook;
|
||||
|
||||
/*
|
||||
* 申請日
|
||||
* */
|
||||
@Column(name = "date_request", nullable = false)
|
||||
private Date dateRequest;
|
||||
|
||||
/*
|
||||
* ステータス
|
||||
* */
|
||||
@Column(name = "status", nullable = false, columnDefinition = "default 1")
|
||||
private Character status;
|
||||
|
||||
/*
|
||||
* 承認者
|
||||
* */
|
||||
@Column(name = "id_approval", nullable = true)
|
||||
private Integer idApproval;
|
||||
|
||||
/*
|
||||
* 承認日
|
||||
* */
|
||||
@Column(name = "date_approval", nullable = true)
|
||||
private Date dateApproval;
|
||||
|
||||
/*
|
||||
* 貸出日
|
||||
* */
|
||||
@Column(name = "date_borrow", nullable = false)
|
||||
private Date dateBorrow;
|
||||
|
||||
/*
|
||||
* 返却予定日
|
||||
* */
|
||||
@Column(name = "date_scheduled_return", nullable = false)
|
||||
private Date dateScheduledReturn;
|
||||
|
||||
/*
|
||||
* 返却日
|
||||
* */
|
||||
@Column(name = "date_return", nullable = true)
|
||||
private Date dateReturn;
|
||||
|
||||
/*
|
||||
* 更新者
|
||||
* */
|
||||
@Column(name = "id_update", nullable = false)
|
||||
private Integer idUpdate;
|
||||
|
||||
/*
|
||||
* 更新日
|
||||
* */
|
||||
@Column(name = "date_update", nullable = false)
|
||||
@LastModifiedDate
|
||||
private Date dateUpdate;
|
||||
}
|
||||
@@ -1,141 +0,0 @@
|
||||
package com.example.demo.entity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
import org.springframework.data.annotation.LastModifiedDate;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* EmployeeテーブルのEntity
|
||||
*/
|
||||
|
||||
@Entity
|
||||
@Table(name = "employee")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
|
||||
public class EmployeeEntity {
|
||||
/**
|
||||
* 社員ID
|
||||
*/
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id_employee", nullable = false)
|
||||
private Integer idEmployee;
|
||||
|
||||
/**
|
||||
* 社員名
|
||||
*/
|
||||
@Column(name = "nm_employee", nullable = false, length = 50)
|
||||
private String nmEmployee;
|
||||
|
||||
/**
|
||||
* 社員よみ
|
||||
*/
|
||||
@Column(name = "kn_employee", nullable = false, length = 100)
|
||||
private String knEmployee;
|
||||
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
@Column(name = "mail_address", nullable = false, length = 256)
|
||||
private String mailAddress;
|
||||
|
||||
/**
|
||||
* パスワード
|
||||
*/
|
||||
@Column(name = "password", nullable = false, length = 256)
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 管理者フラグ
|
||||
*/
|
||||
@Column(name = "flg_admin", nullable = false)
|
||||
private Character FlgAdmin;
|
||||
|
||||
/**
|
||||
* 退職者フラグ
|
||||
*/
|
||||
@Column(name = "flg_retirement", nullable = false)
|
||||
private Character FlgRetirement;
|
||||
|
||||
/**
|
||||
* 更新者
|
||||
*/
|
||||
@Column(name = "id_update", nullable = false)
|
||||
private Integer idUpdate;
|
||||
|
||||
/**
|
||||
* 更新日
|
||||
*/
|
||||
@Column(name = "date_update", nullable = false)
|
||||
@LastModifiedDate
|
||||
private Date dateUpdate;
|
||||
}
|
||||
|
||||
// public static EmployeeEntity convertForm(Employee employee) {
|
||||
// return new EmployeeEntity(
|
||||
// employee.getIdEmployee(),
|
||||
// employee.getnmEmployee(),
|
||||
// employee.getknEmployee(),
|
||||
// employee.getMailAddress(),
|
||||
// employee.getPassword(),
|
||||
// employee.getFlgAdmin(),
|
||||
// employee.getFlgRetirement(),
|
||||
// employee.getIdUpdate(),
|
||||
// employee.getDateUpdate());
|
||||
//
|
||||
// }
|
||||
//
|
||||
// public static EmployeeEntity convertFrom(SearchConditionEmployee searchConditionEmployee) {
|
||||
// EmployeeEntity employeeEntity = new EmployeeEntity();
|
||||
//
|
||||
// employeeEntity.setIdEmployee(searchConditionEmployee.getIdEmployee());
|
||||
// employeeEntity.setNmEmployee(searchConditionEmployee.getNmEmployee());
|
||||
// employeeEntity.setKnEmployee(searchConditionEmployee.getKnEmployee());
|
||||
// employeeEntity.setMailAddress(searchConditionEmployee.getMailAddress());
|
||||
//
|
||||
// return employeeEntity;
|
||||
//
|
||||
// }
|
||||
//
|
||||
// public static Employee createEmployee(EmployeeEntity employeeEntity) {
|
||||
// return new Employee(
|
||||
// employeeEntity.getIdEmployee(),
|
||||
// employeeEntity.getNmEmployee(),
|
||||
// employeeEntity.getKnEmployee(),
|
||||
// employeeEntity.getMailAddress(),
|
||||
// employeeEntity.getPassword(),
|
||||
// employeeEntity.getFlgAdmin(),
|
||||
// employeeEntity.getFlgRetirement(),
|
||||
// employeeEntity.getIdUpdate(),
|
||||
// employeeEntity.getDateUpdate());
|
||||
// }
|
||||
//
|
||||
// public static List<Employee> createEmployeeList(List<EmployeeEntity> employeeEntityList) {
|
||||
// return employeeEntityList.stream().map(EmployeeEntity::createEmployee).toList();
|
||||
// }
|
||||
//
|
||||
// public LoginUser createLoginUser() {
|
||||
// getIdEmployee(),
|
||||
// getNmEmployee(),
|
||||
// getKnEmployee(),
|
||||
// getMailAddress(),
|
||||
// getPassword(),
|
||||
// getFlgAdmin(),
|
||||
// getFlgRetirement(),
|
||||
// getIdUpdate(),
|
||||
// getDateUpdate());
|
||||
//}
|
||||
//}
|
||||
@@ -1,60 +0,0 @@
|
||||
package com.example.demo.form;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class LendingForm {
|
||||
/**
|
||||
* 蔵書ID
|
||||
*/
|
||||
private int idBook;
|
||||
/**
|
||||
* 書籍名
|
||||
*/
|
||||
private String nmBook;
|
||||
|
||||
//貸出日と返却予定日にアノテーションで日付や時刻の表示形式を指定
|
||||
|
||||
/**
|
||||
* 貸出日
|
||||
*/
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
//Date型で取り扱う
|
||||
private Date dateBorrow;
|
||||
|
||||
/**
|
||||
* 返却予定日
|
||||
*/
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private Date dateScheduledReturn;
|
||||
|
||||
/**
|
||||
* 貸出日を取得するメソッド
|
||||
*/
|
||||
public Date getDate_borrow() {
|
||||
return this.dateBorrow;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返却予定日を取得するメソッド
|
||||
*/
|
||||
public Date getDate_scheduled_return() {
|
||||
return this.dateScheduledReturn;
|
||||
}
|
||||
|
||||
/**
|
||||
* サービスクラスの表記に合わせるためのメソッド
|
||||
*/
|
||||
public int getId_book() {
|
||||
return this.idBook;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package com.example.demo.form;
|
||||
|
||||
//ログイン情報
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
|
||||
public class LoginInfoForm {
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
private String mailAddress;
|
||||
/**
|
||||
* パスワード
|
||||
*/
|
||||
private String password;
|
||||
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
package com.example.demo.form;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
//ログインをする人
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class LoginUserForm {
|
||||
/**
|
||||
* 社員ID
|
||||
*/
|
||||
private Integer idEmployee;
|
||||
/**
|
||||
* 社員名
|
||||
*/
|
||||
private String nmEmployee;
|
||||
/**
|
||||
* 社員名よみ
|
||||
*/
|
||||
private String knEmployee;
|
||||
/**
|
||||
* メールアドレス
|
||||
*/
|
||||
private String mailAddress;
|
||||
/**
|
||||
* パスワード
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 管理者フラグ
|
||||
*/
|
||||
private Integer flgadmin;
|
||||
|
||||
/**
|
||||
* business 層の LoginUser クラスから画面用(presentation 層)の LoginUserForm に
|
||||
* 変換します。
|
||||
*
|
||||
* @param loginUser business 層の LoginUser インスタンス
|
||||
* @return クラスから画面用(presentation 層)の LoginUserForm
|
||||
*/
|
||||
public static LoginUserForm convertFrom(LoginUserForm loginUser) {
|
||||
return new LoginUserForm(
|
||||
loginUser.getIdEmployee(),
|
||||
loginUser.getNmEmployee(),
|
||||
loginUser.getKnEmployee(),
|
||||
loginUser.getMailAddress(),
|
||||
loginUser.getPassword(),
|
||||
loginUser.getFlgadmin()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public static LoginUserForm convertTo(LoginUserForm loginUserForm) {
|
||||
return new LoginUserForm(
|
||||
loginUserForm.getIdEmployee(),
|
||||
loginUserForm.getNmEmployee(),
|
||||
loginUserForm.getKnEmployee(),
|
||||
loginUserForm.getMailAddress(),
|
||||
loginUserForm.getPassword(),
|
||||
loginUserForm.getFlgadmin()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public static boolean checkParameter(LoginInfoForm loginInfoForm) {
|
||||
if (null == loginInfoForm.getMailAddress()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (loginInfoForm.getMailAddress().isBlank()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (null == loginInfoForm.getPassword()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !loginInfoForm.getPassword().isBlank();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理者権限を持っているか確認
|
||||
*
|
||||
* @return true:管理者権限を持っている , false:管理者権限を持っていない
|
||||
*/
|
||||
public boolean isAdminUser() {
|
||||
return getFlgadmin() == 1;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.example.demo.form;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 画面に表示するエラーメッセージを管理するクラスです。
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class MessageForm {
|
||||
private String message;
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package com.example.demo.form;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ReturnForm {
|
||||
//申請ID
|
||||
private Integer idRequest;
|
||||
//申請者名//社員名
|
||||
private String nmEmployee;
|
||||
//申請日
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private Date dateRequest;
|
||||
//貸出日
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private Date dateBorrow;
|
||||
//返却予定日
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private Date dateScheduledReturn;
|
||||
//ISBN
|
||||
private String isBn;
|
||||
//書籍名
|
||||
private String nmBook;
|
||||
//出版社
|
||||
private String pubLisher;
|
||||
//特記事項
|
||||
private String noteText;
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.example.demo.form;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class SearchConditionBookForm {
|
||||
//書籍名
|
||||
private String nmBook;
|
||||
//出版社
|
||||
private String pubLisher;
|
||||
//特記事項
|
||||
private String noteText;
|
||||
|
||||
}
|
||||
@@ -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 nmEmployee;
|
||||
private final String nmBook;
|
||||
private final Date dateRequest;
|
||||
private final Date dateBorrow;
|
||||
private final Date dateScheduledReturn;
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
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> {
|
||||
//JpaRepositoruを継承することで基本的なDB操作が使用できる
|
||||
//Book_collctionEntity:操作するEntity
|
||||
//Integer: Entity の主キーの"id_book"の型
|
||||
|
||||
List<Book_collectionEntity> findByFlgLending(Character flgLending);
|
||||
|
||||
// [ b.noteText ] …Entityのフィールドを表す
|
||||
// [ :noteText ]…Javaから渡された検索条件を表す。ユーザが入力した(Java)などの文字列が入る
|
||||
// [:]…JPQLでは、名前付きパラメータを指定するときに、名前の前に : を付け
|
||||
|
||||
|
||||
@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
|
||||
""")
|
||||
//上から:貸出フラグが'0'の書籍だけを取得する
|
||||
//書籍名が空欄なら絞り込まない、入力されてるなら部分一致検索する
|
||||
//出版社が...
|
||||
//特記事項が...
|
||||
//蔵書IDの昇順で並べる
|
||||
|
||||
|
||||
//書籍名・出版社・特記事項を条件に書籍を検索するメソッド
|
||||
//検索結果はBook_collectionEntityのListで返す
|
||||
List<Book_collectionEntity> searchBooks(
|
||||
//入力された書籍名をJPQLの:nmBookに返す
|
||||
// [:]…JPQLでは、名前付きパラメータを指定するときに、名前の前に : を付け
|
||||
// └[ : ] 以降の名前は @Param("noteText") の名前と一致させる
|
||||
@Param("nmBook") String nmBook,
|
||||
@Param("pubLisher") String pubLisher,
|
||||
@Param("noteText") String noteText);
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.example.demo.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.example.demo.entity.Borrow_booksEntity;
|
||||
|
||||
@Repository
|
||||
public interface Borrow_BooksRepository extends JpaRepository<Borrow_booksEntity, Integer> {
|
||||
List<Borrow_booksEntity> findByStatus(Character status);
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.example.demo.repository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.example.demo.entity.EmployeeEntity;
|
||||
|
||||
@Repository
|
||||
public interface EmployeeRepository extends JpaRepository<EmployeeEntity, Integer> {
|
||||
|
||||
//メールアドレスとパスワードに合致するレコード
|
||||
Optional<EmployeeEntity> findByMailAddressAndPassword(String mailAddress, String password);
|
||||
}
|
||||
@@ -1,201 +0,0 @@
|
||||
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;
|
||||
|
||||
@Service
|
||||
public class ReturnService {
|
||||
|
||||
Book_CollectionRepository book_CollectionRepository;
|
||||
Borrow_BooksRepository borrowRepository;
|
||||
EmployeeRepository employeeRepository;
|
||||
|
||||
@Autowired
|
||||
public ReturnService(
|
||||
Book_CollectionRepository book_CollectionRepository,
|
||||
Borrow_BooksRepository borrowRepository,
|
||||
EmployeeRepository employeeRepository) {
|
||||
this.book_CollectionRepository = book_CollectionRepository;
|
||||
this.borrowRepository = borrowRepository;
|
||||
this.employeeRepository = employeeRepository;
|
||||
}
|
||||
|
||||
public ReturnForm getReturnForm(int id) {
|
||||
ReturnForm result = new ReturnForm();
|
||||
Optional<Borrow_booksEntity> borrow = borrowRepository.findById(id);
|
||||
// System.out.println(borrow);
|
||||
result.setDateRequest(borrow.get().getDateRequest());//申請日
|
||||
result.setDateBorrow(borrow.get().getDateBorrow());//貸出日
|
||||
result.setDateScheduledReturn(borrow.get().getDateScheduledReturn());//返却予定日
|
||||
|
||||
var emp = employeeRepository.findById(borrow.get().getIdApplicant());
|
||||
result.setNmEmployee(emp.get().getNmEmployee());//申請者名、社員名
|
||||
|
||||
var book = book_CollectionRepository.findById(borrow.get().getIdBook());
|
||||
result.setIsBn(book.get().getIsBn());//ISBN
|
||||
result.setNmBook(book.get().getNmBook());//書籍名
|
||||
result.setPubLisher(book.get().getPubLisher());//出版社
|
||||
result.setNoteText(book.get().getNoteText());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setReturn(int id_request, int id_employee) {
|
||||
var borrow = borrowRepository.findById(id_request);
|
||||
var book = book_CollectionRepository.findById(borrow.get().getIdBook());
|
||||
book.get().setFlgLending('0');//「貸出フラグ」を【貸出可】
|
||||
borrow.get().setStatus('0');//貸出テーブルの「ステータス」を【返却済
|
||||
borrow.get().setDateReturn(new Date());//「返却日」を当日日付
|
||||
borrow.get().setIdUpdate(id_employee);//「更新者」を更新した人のID
|
||||
borrow.get().setDateUpdate(new Date());//「更新日」を当日日付に更新する。
|
||||
|
||||
borrowRepository.save(borrow.get());
|
||||
book_CollectionRepository.save(book.get());
|
||||
}
|
||||
|
||||
//貸出承認
|
||||
public void setReturnComplete(int id_request, int id_employee) {
|
||||
var borrow = borrowRepository.findById(id_request);
|
||||
var book = book_CollectionRepository.findById(borrow.get().getIdBook());
|
||||
|
||||
borrow.get().setStatus('2');//貸出テーブルの「ステータス」を【貸出中】
|
||||
borrow.get().setDateApproval(new Date());//「承認日」を当日日付
|
||||
borrow.get().setIdUpdate(id_employee);//「更新者」を更新した人のID
|
||||
borrow.get().setDateUpdate(new Date());//「更新日」を当日日付に更新する。
|
||||
borrow.get().setIdApproval(id_employee);
|
||||
borrowRepository.save(borrow.get());
|
||||
book_CollectionRepository.save(book.get());
|
||||
|
||||
}
|
||||
|
||||
//却下
|
||||
//貸出テーブルの「ステータス」を【却下】、「更新者」を却下した人のID、「更新日」を当日日付に更新する。
|
||||
//また、蔵書テーブルの「貸出フラグ」を【貸出可】に更新する。
|
||||
public void setReturnRejected(int id_request, int id_employee) {
|
||||
|
||||
var borrow = borrowRepository.findById(id_request);
|
||||
var book = book_CollectionRepository.findById(borrow.get().getIdBook());
|
||||
|
||||
book.get().setFlgLending('0');//「貸出フラグ」を【貸出可】
|
||||
borrow.get().setStatus('9');//貸出テーブルの「ステータス」を【却下】
|
||||
borrow.get().setIdUpdate(id_employee);//「更新者」を却下した人のID
|
||||
borrow.get().setDateUpdate(new Date());//「更新日」を当日日付に更新する。
|
||||
borrowRepository.save(borrow.get());
|
||||
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.setIdApplicant(idEmployee);//申請者ID
|
||||
borrow.setIdBook(form.getId_book());//蔵書ID
|
||||
borrow.setDateRequest(new Date());//申請日
|
||||
borrow.setStatus('1');//ステータスを承認待ちに
|
||||
borrow.setIdUpdate(idEmployee);//更新者ID
|
||||
borrow.setDateUpdate(new Date());//更新日
|
||||
|
||||
//必要だったため追記
|
||||
borrow.setDateBorrow(form.getDate_borrow()); //貸出日
|
||||
borrow.setDateScheduledReturn(form.getDate_scheduled_return()); //返却予定日
|
||||
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,4 +0,0 @@
|
||||
spring.application.name=test
|
||||
spring.datasource.url=jdbc:mysql://localhost:3306/rezodb
|
||||
spring.datasource.username=rezouser
|
||||
spring.datasource.password=Rezo_0000
|
||||
@@ -1,47 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>メニュー</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div style="text-align: right;">
|
||||
|
||||
<form method="POST">
|
||||
<span class="loginInfo">ログイン者名:<span th:text="${session.loginName}"></span></span>
|
||||
<input type="submit" name="action" th:formaction="@{/doLogout}" value="ログアウト"/>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<h1>メニュー</h1>
|
||||
<!-- 管理者フラグのチェック処理-->
|
||||
|
||||
<!-- 管理ユーザー向けのメニュー-->
|
||||
<form method="POST">
|
||||
<table class="menuClass">
|
||||
|
||||
<tr>
|
||||
<td class="btn" colspan="2">
|
||||
<input type="submit" name="action" th:formaction="@{/selectBook}" value="書籍検索"/>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="btn" colspan="2">
|
||||
<input type="submit" name="action" th:formaction="@{/applicationList}" value="書籍貸出申請一覧"/>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="btn" colspan="2">
|
||||
<input type="submit" name="action" th:formaction="@{/lendingList}" value="貸出中書籍一覧"/>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</form>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,76 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<!--書籍貸出申請画面-->
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>書籍貸出申請</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div style="text-align: right;">
|
||||
<form method="POST">
|
||||
<span class="loginInfo">ログイン者名:<span th:text="${session.loginName}"></span></span>
|
||||
<input type="submit" name="action" th:formaction="@{/doLogout}" value="ログアウト"/>
|
||||
</form>
|
||||
</div>
|
||||
<!--タイトル表示-->
|
||||
<h1>書籍貸出申請</h1>
|
||||
<!--右上にログイン者名、ログアウトボタン配置-->
|
||||
<!--現在ダミー配置-->
|
||||
<!-- <div class="rightSection">-->
|
||||
<!-- <button class="logoutButton" onclick="logoutSubmit()">ログアウト</button>-->
|
||||
<!-- <span class="loginInfo">ログイン者名:<span>テスト太郎(ダミー)</span></span>-->
|
||||
<!-- </div>-->
|
||||
<!--配置予定の記述-->
|
||||
<!-- <div class="rightSection">
|
||||
<button class="logoutButton" onclick="logoutSubmit()">ログアウト</button>
|
||||
<span class="loginInfo">ログイン者名:<span th:text="${session.loginUser.nmEmployee}"></span>
|
||||
</div>
|
||||
-->
|
||||
|
||||
<!--クラス名確認すること(現在仮入力)-->
|
||||
<form th:action="@{/confirmLending}" id="lendingForm" method="post" th:object="${lendingForm}">
|
||||
<table>
|
||||
<!--蔵書ID、書籍名はreadonlyにて固定-->
|
||||
<tr>
|
||||
<th class="header">蔵書ID</th>
|
||||
<td><input type="text" th:field="*{idBook}" readonly="readonly"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">書籍名</th>
|
||||
<td><input type="text" th:field="*{nmBook}" readonly="readonly"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<!--input type ="date"にてカレンダー入力表示-->
|
||||
<!--required属性を追加、未入力をブラウザ側ではじく-->
|
||||
<!--Thymeleafにてエラー表示エリアを作成-->
|
||||
<th class="header">貸出日</th>
|
||||
<td>
|
||||
<input type="date" th:field="*{dateBorrow}" required>
|
||||
<span th:if="${#fields.hasErrors('dateBorrow')}" th:errors="*{dateBorrow}"
|
||||
style="color:red;"></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">返却予定日</th>
|
||||
<td>
|
||||
<input type="date" th:field="*{dateScheduledReturn}" required>
|
||||
<span th:if="${#fields.hasErrors('dateScheduledReturn')}" th:errors="*{dateScheduledReturn}"
|
||||
style="color:red;"></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="btnArea" colspan="2">
|
||||
<input type="submit" value="申請確認" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<!--書籍一覧に戻る処理、URL確認を行う-->
|
||||
<a th:href="@{/selectBook}"> 書籍一覧に戻る</a>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,46 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<!--書籍貸出申請完了画面-->
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>書籍貸出申請完了</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div style="text-align: right;">
|
||||
<form method="POST">
|
||||
<span class="loginInfo">ログイン者名:<span th:text="${session.loginName}"></span></span>
|
||||
<input type="submit" name="action" th:formaction="@{/doLogout}" value="ログアウト"/>
|
||||
</form>
|
||||
</div>
|
||||
<!--タイトル表示-->
|
||||
<h1>書籍貸出申請</h1>
|
||||
<!--右上にログイン者名、ログアウトボタン配置-->
|
||||
<!--現在ダミー配置-->
|
||||
<!-- <div class="rightSection">-->
|
||||
<!-- <span class="loginInfo">ログイン者名:<span>テスト太郎(ダミー)</span></span>-->
|
||||
<!-- <button class="logoutButton" onclick="logoutSubmit()">ログアウト</button>-->
|
||||
<!-- </div>-->
|
||||
<!--配置予定の記述-->
|
||||
<!-- <div class="rightSection">
|
||||
<button class="logoutButton" onclick="logoutSubmit()">ログアウト</button>
|
||||
<span class="loginInfo">ログイン者名:<span th:text="${session.loginUser.nmEmployee}"></span>
|
||||
</div>
|
||||
-->
|
||||
|
||||
|
||||
<!--見出し表示-->
|
||||
<h2>書籍貸出申請完了しました</h2>
|
||||
|
||||
<div class="navigation-links">
|
||||
<!--書籍一覧に戻る処理、URL確認を行う-->
|
||||
<a th:href="@{/selectBook}"> 書籍一覧に戻る</a>
|
||||
|
|
||||
<!--メニュー画面に戻る処理、URL確認を行う-->
|
||||
<a th:href="@{/menu}">メニューに戻る</a>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,80 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<!--書籍貸出申請確認画面-->
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>書籍貸出申請確認</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div style="text-align: right;">
|
||||
<form method="POST">
|
||||
<span class="loginInfo">ログイン者名:<span th:text="${session.loginName}"></span></span>
|
||||
<input type="submit" name="action" th:formaction="@{/doLogout}" value="ログアウト"/>
|
||||
</form>
|
||||
</div>
|
||||
<!--タイトル表示-->
|
||||
<h1>書籍貸出申請</h1>
|
||||
<!--右上にログイン者名、ログアウトボタン配置-->
|
||||
<!--現在ダミー配置-->
|
||||
<!-- <div class="rightSection">-->
|
||||
<!-- <span class="loginInfo">ログイン者名:<span>テスト太郎(ダミー)</span></span>-->
|
||||
<!-- <button class="logoutButton" onclick="logoutSubmit()">ログアウト</button>-->
|
||||
<!-- </div>-->
|
||||
<!--配置予定の記述-->
|
||||
<!-- <div class="rightSection">
|
||||
<button class="logoutButton" onclick="logoutSubmit()">ログアウト</button>
|
||||
<span class="loginInfo">ログイン者名:<span th:text="${session.loginUser.nmEmployee}"></span>
|
||||
</div>
|
||||
-->
|
||||
|
||||
|
||||
<form th:action="@{/executeLending}" id="lendingConfirmForm" method="post" th:object="${lendingForm}">
|
||||
|
||||
<!--Java側へデータを引き継ぐための隠しフィールド(必須) -->
|
||||
<input type="hidden" th:field="*{idBook}" />
|
||||
<input type="hidden" th:field="*{nmBook}" />
|
||||
<input type="hidden" th:field="*{dateBorrow}" />
|
||||
<input type="hidden" th:field="*{dateScheduledReturn}" />
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<!-- 以下4項目<span>タグを用いてテキスト表示として画面に固定表示 -->
|
||||
<th class="header">蔵書ID</th>
|
||||
<td><span th:text="*{idBook}"></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">書籍名</th>
|
||||
<td><span th:text="*{nmBook}"></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">貸出日</th>
|
||||
<td><span
|
||||
th:text="*{dateBorrow} != null ? ${#dates.format(lendingForm.dateBorrow, 'yyyy/MM/dd')} : ''"></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">返却予定日</th>
|
||||
<td><span
|
||||
th:text="*{dateScheduledReturn} != null ? ${#dates.format(lendingForm.dateScheduledReturn, 'yyyy/MM/dd')} : ''"></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="btnArea" colspan="2">
|
||||
<!-- 申請確定 -->
|
||||
<input type="submit" value="申請" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<!--申請情報入力(一つ前の画面)に戻る処理-->
|
||||
<div class="link-return-area">
|
||||
<a class="back-link" href="javascript:void(0);"
|
||||
onclick="const form = document.getElementById('lendingConfirmForm'); form.action='/backToRequest'; form.submit();">
|
||||
申請情報入力に戻る
|
||||
</a>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,57 +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>
|
||||
<div style="text-align: right;">
|
||||
<form method="POST">
|
||||
<span class="loginInfo">ログイン者名:<span th:text="${session.loginName}"></span></span>
|
||||
<input type="submit" name="action" th:formaction="@{/doLogout}" value="ログアウト" />
|
||||
</form>
|
||||
</div>
|
||||
<h1>書籍貸出申請一覧</h1>
|
||||
<a href="menu">メニューに戻る</a>
|
||||
<h2>検索結果</h2>
|
||||
<table border="1">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 150px;">申請ID</th>
|
||||
<th style="width: 150px;">申請者名</th>
|
||||
<th style="width: 150px;">書籍名</th>
|
||||
<th style="width: 150px;">申請日</th>
|
||||
<th style="width: 150px;">貸出日</th>
|
||||
<th style="width: 150px;">返却予定日</th>
|
||||
<th style="width: 150px;">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr th:each="employeeInfoForm : ${applicationList}">
|
||||
<td th:text="${employeeInfoForm.idRequest}"></td>
|
||||
<td th:text="${employeeInfoForm.nmEmployee}"></td>
|
||||
<td th:text="${employeeInfoForm.nmBook}"></td>
|
||||
<td th:text="${employeeInfoForm.dateRequest}"></td>
|
||||
<td th:text="${employeeInfoForm.dateBorrow}"></td>
|
||||
<td th:text="${employeeInfoForm.dateScheduledReturn}"></td>
|
||||
<td>
|
||||
<!--返却フォーム-->
|
||||
<form action="approvalConfirm" method="get">
|
||||
<!--送信するデータ名、送信する値、送信する指定-->
|
||||
<input name="idRequest" th:value="${employeeInfoForm.idRequest}" type="hidden">
|
||||
<input type="submit" value="承認">
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<br>
|
||||
<th:block th:if="${applicationList == null or applicationList.isEmpty()}">
|
||||
<!-- 検索結果が0件の場合 -->
|
||||
現在書籍貸出の申請はありません。
|
||||
</th:block>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,20 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>書籍貸出承認画面</title>
|
||||
</head>
|
||||
<div style="text-align: right;">
|
||||
<form method="POST">
|
||||
<span class="loginInfo">ログイン者名:<span th:text="${session.loginName}"></span></span>
|
||||
<input type="submit" name="action" th:formaction="@{/doLogout}" value="ログアウト"/>
|
||||
</form>
|
||||
</div>
|
||||
<body>
|
||||
<h2>書籍貸出申請を承認しました。</h2>
|
||||
<br/>
|
||||
<a href="applicationList">承認待ち一覧に戻る</a> | <a href="menu">メニューに戻る</a>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,141 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>書籍貸出承認確認</title>
|
||||
</head>
|
||||
<body>
|
||||
<div style="text-align: right;">
|
||||
<form method="POST">
|
||||
<span class="loginInfo">ログイン者名:<span th:text="${session.loginName}"></span></span>
|
||||
<input type="submit" name="action" th:formaction="@{/doLogout}" value="ログアウト"/>
|
||||
</form>
|
||||
</div>
|
||||
<h1>書籍貸出承認確認</h1>
|
||||
<form action ="approvalComplete"
|
||||
method="post"
|
||||
th:object="${returnForm}">
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th class="header">申請ID</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
name="idRequest"
|
||||
readonly="readonly"
|
||||
th:field="*{idRequest}"
|
||||
type="text"/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">申請者名</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
name="nmEmployee"
|
||||
readonly="readonly"
|
||||
th:field="*{nmEmployee}"
|
||||
type="text"/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">申請日</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
name="dateRequest"
|
||||
readonly="readonly"
|
||||
th:field="*{dateRequest}"
|
||||
type="text"/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">ISBN</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
name="isBn"
|
||||
readonly="readonly"
|
||||
th:field="*{isBn}"
|
||||
type="text"/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">書籍名</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
name="nmBook"
|
||||
readonly="readonly"
|
||||
th:field="*{nmBook}"
|
||||
type="text"/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">出版社</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
name="pubLisher"
|
||||
readonly="readonly"
|
||||
th:field="*{pubLisher}"
|
||||
type="text"/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">特記事項</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
name="noteText"
|
||||
readonly="readonly"
|
||||
th:field="*{noteText}"
|
||||
type="text"/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">貸出日</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
name="dateBorrow"
|
||||
readonly="readonly"
|
||||
th:field="*{dateBorrow}"
|
||||
type="text"/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">返却予定日</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
name="dateScheduledReturn"
|
||||
readonly="readonly"
|
||||
th:field="*{dateScheduledReturn}"
|
||||
type="text"/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="btn" colspan="2">
|
||||
<input type="submit" name="action" formaction="approvalComplete" value="承認"/>
|
||||
<input type="submit" name="action" formaction="approvalRejected" value="却下"/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br/>
|
||||
|
||||
<a href="applicationList">承認待ち一覧に戻る</a>
|
||||
</form>
|
||||
<div style="text-align: left;">
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,19 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>書籍貸出却下画面</title>
|
||||
</head>
|
||||
<div style="text-align: right;">
|
||||
<form method="POST">
|
||||
<span class="loginInfo">ログイン者名:<span th:text="${session.loginName}"></span></span>
|
||||
<input type="submit" name="action" th:formaction="@{/doLogout}" value="ログアウト"/>
|
||||
</form>
|
||||
</div>
|
||||
<body>
|
||||
<h2>書籍貸出申請を却下しました。</h2>
|
||||
<br/>
|
||||
<a href="applicationList">承認待ち一覧に戻る</a> | <a href="menu">メニューに戻る</a>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,114 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>書籍一覧・検索</title>
|
||||
</head>
|
||||
|
||||
<!--画面に表示する内容-->
|
||||
|
||||
<body>
|
||||
<!--ログアウトボタン-->
|
||||
<div style="text-align: right;">
|
||||
<form method="POST">
|
||||
<span class="loginInfo">ログイン者名:<span th:text="${session.loginName}"></span></span>
|
||||
<input type="submit" name="action" th:formaction="@{/doLogout}" value="ログアウト" />
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<h1>書籍一覧・検索</h1>
|
||||
<!-- 検索条件をControllerの/selectBookへPOST送信-->
|
||||
<!--bookSearchFormはControllerから渡されるForm-->
|
||||
<!--Controllerと@{/selectBook}合わせる-->
|
||||
<form th:action="@{/selectBook}" th:object="${bookSearchForm}" method="post">
|
||||
|
||||
<!-- 検索条件を入力するためのテーブル-->
|
||||
<table>
|
||||
<!-- 書籍名-->
|
||||
<tr>
|
||||
<th class="header">書籍名</th>
|
||||
<!-- FormのnmBookフィールドと関連付ける-->
|
||||
<td><input type="text" th:field="*{nmBook}" /></td>
|
||||
</tr>
|
||||
<!-- 出版社-->
|
||||
<tr>
|
||||
<th class="header">出版社</th>
|
||||
<!-- FormのpubLisherフィールドと関連付ける-->
|
||||
<td><input type="text" th:field="*{pubLisher}"></td>
|
||||
</tr>
|
||||
<!-- 特記事項-->
|
||||
<tr>
|
||||
<th class="header">特記事項</th>
|
||||
<!-- FormのnoteTextフィールドと関連付ける-->
|
||||
<td><input type="text" th:field="*{noteText}"></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
<!-- 検索ボタン-->
|
||||
<button type="submit">検索</button>
|
||||
</form>
|
||||
|
||||
<!-- メニュー画面へ戻るリンク-->
|
||||
<a th:href="@{/menu}">メニューに戻る </a>
|
||||
|
||||
<h2>検索結果</h2>
|
||||
<p th:if="${searched == true and #lists.isEmpty(books)}">
|
||||
検索結果は0件です。
|
||||
</p>
|
||||
<!--検索結果を表示するテーブル-->
|
||||
<!-- border ="1"は表のセルを区切るための線を表示-->
|
||||
<table border="1">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>書籍ID</th>
|
||||
<th>ISBN</th>
|
||||
<th>書籍名</th>
|
||||
<th>書籍名よみ</th>
|
||||
<th>出版社</th>
|
||||
<th>特記事項</th>
|
||||
<th style="width: 150px;">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<!--検索結果を表示-->
|
||||
<tbody>
|
||||
<!--Controllerから渡されたbooksのデータを1件ずつ取り出す-->
|
||||
<!-- bookには1件分の書籍情報が入る-->
|
||||
<tr th:each="book : ${books}">
|
||||
<!--書籍ID-->
|
||||
<td th:text="${book.idBook}"></td>
|
||||
<!--ISBN-->
|
||||
<td th:text="${book.isBn}"></td>
|
||||
<!--書籍名-->
|
||||
<td th:text="${book.nmBook}"></td>
|
||||
<!--書籍名よみ-->
|
||||
<td th:text="${book.knBook}"></td>
|
||||
<!--出版社-->
|
||||
<td th:text="${book.pubLisher}"></td>
|
||||
<!--特記事項-->
|
||||
<td th:text="${book.noteText}"></td>
|
||||
<td>
|
||||
<!-- 管理者"flg_admin = 0"の場合は編集ボタン-->
|
||||
<!-- loginと連携するまでコメントアウト <form th:if="${isAdmin}" th:action="{@/selectEmployeeInfo}-->
|
||||
<!-- <form th:action="@{/selectEmployeeInfo}" method = "get">-->
|
||||
|
||||
<!-- <input type="hidden" name="idBook" th:value="${book.idBook}">-->
|
||||
|
||||
<!-- <button type="submit">貸出申請</button>-->
|
||||
<!-- </form>-->
|
||||
|
||||
|
||||
<!--一般ユーザー"flg_admin = 0"の場合は-->
|
||||
<!-- loginと連携するまでコメントアウト <form th:if="${isAdmin}" th:action="{@/confirmLending}-->
|
||||
<a th:href="@{/requestLending(idBook=${book.idBook}, nmBook=${book.nmBook})}"
|
||||
style="text-decoration: none;">
|
||||
<button type="button">貸出申請</button>
|
||||
</form>
|
||||
|
||||
</td>
|
||||
</table>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,56 +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>
|
||||
<div style="text-align: right;">
|
||||
<form method="POST">
|
||||
<span class="loginInfo">ログイン者名:<span th:text="${session.loginName}"></span></span>
|
||||
<input type="submit" name="action" th:formaction="@{/doLogout}" value="ログアウト" />
|
||||
</form>
|
||||
</div>
|
||||
<h1>貸出中書籍一覧</h1>
|
||||
<a href="menu">メニューに戻る</a>
|
||||
<h2>検索結果</h2>
|
||||
<table border="1">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 150px;">申請ID</th>
|
||||
<th style="width: 150px;">申請者名</th>
|
||||
<th style="width: 150px;">書籍名</th>
|
||||
<th style="width: 150px;">申請日</th>
|
||||
<th style="width: 150px;">貸出日</th>
|
||||
<th style="width: 150px;">返却予定日</th>
|
||||
<th style="width: 150px;">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr th:each="borrow : ${borrowList}">
|
||||
<td th:text="${borrow.idRequest}"></td>
|
||||
<td th:text="${borrow.nmEmployee}"></td>
|
||||
<td th:text="${borrow.nmBook}"></td>
|
||||
<td th:text="${borrow.dateRequest}"></td>
|
||||
<td th:text="${borrow.dateBorrow}"></td>
|
||||
<td th:text="${borrow.dateScheduledReturn}"></td>
|
||||
<td>
|
||||
<!--返却フォーム-->
|
||||
<form action="returnConfirm" method="post">
|
||||
<!--送信するデータ名、送信する値、送信する指定-->
|
||||
<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>
|
||||
|
||||
</html>
|
||||
@@ -1,67 +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>ログイン</h1>
|
||||
<form id="loginForm"
|
||||
th:action="@{/doLogin}"
|
||||
method="post"
|
||||
th:object="${loginInfoForm}">
|
||||
|
||||
<div class="msgBox error" th:if="${messageError} != null">
|
||||
<span class="error" th:text="${messageError.message}"></span>
|
||||
</div>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<!-- メアド記入欄 -->
|
||||
<th class="header">メールアドレス</th>
|
||||
<td style="width: 250px;">
|
||||
<input placeholder="メールアドレス"
|
||||
required="required"
|
||||
style="width: 100%;"
|
||||
th:field="*{mailAddress}"
|
||||
type="text"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<!-- パスワード記入欄 -->
|
||||
<th style="text-align: right;">パスワード</th>
|
||||
<td>
|
||||
<input placeholder="パスワード"
|
||||
required="required"
|
||||
style="width: 100%;"
|
||||
th:field="*{password}"
|
||||
type="password"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="btnArea" colspan="2">
|
||||
<input type="submit" value="ログイン"/>
|
||||
<button type="button" onclick="clearInput()">リセット</button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
<!-- 入力を消去 -->
|
||||
<script type="text/javascript">
|
||||
function clearInput() {
|
||||
document.getElementById('mailAddress').value = '';
|
||||
document.getElementById('password').value = '';
|
||||
}
|
||||
|
||||
</script>
|
||||
</html>
|
||||
@@ -1,32 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>メニュー</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div style="text-align: right;">
|
||||
<form method="POST">
|
||||
<span class="loginInfo">ログイン者名:<span th:text="${session.loginName}"></span></span>
|
||||
<input type="submit" name="action" th:formaction="@{/doLogout}" value="ログアウト"/>
|
||||
</form>
|
||||
</div>
|
||||
<h1>メニュー</h1>
|
||||
<!-- 管理者フラグのチェック処理-->
|
||||
|
||||
<!-- 一般ユーザー向けのメニュー-->
|
||||
<form method="POST">
|
||||
<table class="menuClass">
|
||||
|
||||
<tr>
|
||||
<td class="btn" colspan="2">
|
||||
<input type="submit" name="action" th:formaction="@{/selectBook}" value="書籍検索"/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,26 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>書籍返却完了</title>
|
||||
</head>
|
||||
|
||||
|
||||
<div style="text-align: right;">
|
||||
<form method="POST">
|
||||
<span class="loginInfo">ログイン者名:<span th:text="${session.loginName}"></span></span>
|
||||
<input type="submit" name="action" th:formaction="@{/doLogout}" value="ログアウト"/>
|
||||
</form>
|
||||
</div>
|
||||
<h1>書籍返却確認</h1>
|
||||
<h2 style="text-align: left;">書籍の返却が完了しました</h2>
|
||||
|
||||
|
||||
<div style="text-align: left;">
|
||||
<!-- コントローラーのメソッド名-->
|
||||
<a href="lendingList">貸出中書籍一覧に戻る</a> | <a href="menu">メニューに戻る</a>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,140 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>書籍返却確認</title>
|
||||
</head>
|
||||
<body>
|
||||
<div style="text-align: right;">
|
||||
<form method="POST">
|
||||
<span class="loginInfo">ログイン者名:<span th:text="${session.loginName}"></span></span>
|
||||
<input type="submit" name="action" th:formaction="@{/doLogout}" value="ログアウト"/>
|
||||
</form>
|
||||
</div>
|
||||
<h1>書籍返却確認</h1>
|
||||
|
||||
<form action ="returnComplete"
|
||||
method="post"
|
||||
th:object="${returnForm}">
|
||||
<table style="text-align: left;">
|
||||
<tr>
|
||||
<th class="header">申請ID</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
name="idRequest"
|
||||
readonly="readonly"
|
||||
th:field="*{idRequest}"
|
||||
type="text" />
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">申請者名</th>
|
||||
<td >
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
name="nmEmployee"
|
||||
readonly="readonly"
|
||||
th:field="*{nmEmployee}"
|
||||
type="text" />
|
||||
</label>
|
||||
</td >
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">申請日</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
name="dateRequest"
|
||||
readonly="readonly"
|
||||
th:field="*{dateRequest}"
|
||||
type="text" />
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">ISBN</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
name="isBn"
|
||||
readonly="readonly"
|
||||
th:field="*{isBn}"
|
||||
type="text" />
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">書籍名</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
name="nmBook"
|
||||
readonly="readonly"
|
||||
th:field="*{nmBook}"
|
||||
type="text" />
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">出版社</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
name="pubLisher"
|
||||
readonly="readonly"
|
||||
th:field="*{pubLisher}"
|
||||
type="text" />
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">特記事項</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
name="noteText"
|
||||
readonly="readonly"
|
||||
th:field="*{noteText}"
|
||||
type="text" />
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">貸出日</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
name="dateBorrow"
|
||||
readonly="readonly"
|
||||
th:field="*{dateBorrow}"
|
||||
type="text" />
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="header">返却予定日</th>
|
||||
<td>
|
||||
<label>
|
||||
<input class="readOnly"
|
||||
name="dateScheduledReturn"
|
||||
readonly="readonly"
|
||||
th:field="*{dateScheduledReturn}"
|
||||
type="text" />
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="text-align:left;">
|
||||
<td>
|
||||
<input type="submit" value="返却"/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- コントローラーのメソッド名-->
|
||||
<a href="lendingList">貸出中書籍一覧に戻る</a>
|
||||
</form>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.example.demo;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class TestApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user