Merge branch 'main' of https://gitea.it-college.co.jp/2026_0910_AI_5G_Java_MUN/last-group-delevelopment-team2 into t-eguchi
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
package com.example.demo.common;
|
package com.example.demo.common;
|
||||||
|
|
||||||
public class BusinessException {
|
public class BusinessException extends RuntimeException {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public BusinessException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,31 @@
|
|||||||
package com.example.demo.common;
|
package com.example.demo.common;
|
||||||
|
|
||||||
public class Const {
|
|
||||||
|
|
||||||
|
|
||||||
|
/** テーブル定義書のコード値(数値の直書きを避けるため一箇所に集約) */
|
||||||
|
public final class Const {
|
||||||
|
private Const() {}
|
||||||
|
|
||||||
|
public static final String SESSION_LOGIN_USER = "loginUser";
|
||||||
|
|
||||||
|
/** 管理者フラグ */
|
||||||
|
public static final String ADMIN_NO = "0";
|
||||||
|
public static final String ADMIN_YES = "1";
|
||||||
|
|
||||||
|
/** 初期パスワード(機能一覧 EMP-01) */
|
||||||
|
public static final String DEFAULT_PASSWORD = "sakura2024";
|
||||||
|
|
||||||
|
/** 退職フラグ */
|
||||||
|
public static final String RETIRE_NO = "0";
|
||||||
|
public static final String RETIRE_YES = "1";
|
||||||
|
|
||||||
|
/** 貸出フラグ */
|
||||||
|
public static final String LENDING_OK = "0"; // 貸出可
|
||||||
|
public static final String LENDING_NG = "1"; // 貸出不可
|
||||||
|
|
||||||
|
/** 貸出ステータス */
|
||||||
|
public static final String STATUS_RETURNED = "0"; // 返却済
|
||||||
|
public static final String STATUS_WAITING = "1"; // 承認待
|
||||||
|
public static final String STATUS_LENDING = "2"; // 貸出中
|
||||||
|
public static final String STATUS_REJECTED = "9"; // 却下
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,31 @@
|
|||||||
package com.example.demo.common;
|
package com.example.demo.common;
|
||||||
|
|
||||||
public class LoginUser {
|
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/** セッションに保持するログイン情報(社員ID・社員名・社員名よみ・メールアドレス・管理者フラグ) */
|
||||||
|
public class LoginUser implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private final Integer idEmployee;
|
||||||
|
private final String nmEmployee;
|
||||||
|
private final String knEmployee;
|
||||||
|
private final String mailAddress;
|
||||||
|
private final String flgAdmin;
|
||||||
|
|
||||||
|
public LoginUser(Integer idEmployee, String nmEmployee, String knEmployee, String mailAddress, String flgAdmin) {
|
||||||
|
this.idEmployee = idEmployee;
|
||||||
|
this.nmEmployee = nmEmployee;
|
||||||
|
this.knEmployee = knEmployee;
|
||||||
|
this.mailAddress = mailAddress;
|
||||||
|
this.flgAdmin = flgAdmin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getIdEmployee() { return idEmployee; }
|
||||||
|
public String getNmEmployee() { return nmEmployee; }
|
||||||
|
public String getKnEmployee() { return knEmployee; }
|
||||||
|
public String getMailAddress() { return mailAddress; }
|
||||||
|
public String getFlgAdmin() { return flgAdmin; }
|
||||||
|
public boolean isAdmin() { return Const.ADMIN_YES.equals(flgAdmin); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,37 @@
|
|||||||
package com.example.demo.config;
|
package com.example.demo.config;
|
||||||
|
|
||||||
public class LoginCheckInterceptor {
|
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import jakarta.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
import org.springframework.web.servlet.HandlerInterceptor;
|
||||||
|
|
||||||
|
import com.example.demo.common.Const;
|
||||||
|
import com.example.demo.common.LoginUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 全業務画面共通のアクセス制御(NFR-02)。
|
||||||
|
* ・未ログイン → ログイン画面へ
|
||||||
|
* ・/admin/** は管理者のみ(画面のボタン非表示だけでなくサーバー側でも確認)
|
||||||
|
*/
|
||||||
|
public class LoginCheckInterceptor implements HandlerInterceptor {
|
||||||
|
@Override
|
||||||
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||||
|
// ブラウザの「戻る」でログアウト後の画面が見えないようにする
|
||||||
|
response.setHeader("Cache-Control", "no-store");
|
||||||
|
|
||||||
|
HttpSession session = request.getSession(false);
|
||||||
|
LoginUser user = session == null ? null : (LoginUser) session.getAttribute(Const.SESSION_LOGIN_USER);
|
||||||
|
if (user == null) {
|
||||||
|
response.sendRedirect(request.getContextPath() + "/login");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
String path = request.getRequestURI().substring(request.getContextPath().length());
|
||||||
|
if (path.startsWith("/admin") && !user.isAdmin()) {
|
||||||
|
response.sendRedirect(request.getContextPath() + "/menu");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,16 @@
|
|||||||
package com.example.demo.config;
|
package com.example.demo.config;
|
||||||
|
|
||||||
public class WebConfig {
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class WebConfig implements WebMvcConfigurer {
|
||||||
|
@Override
|
||||||
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
|
registry.addInterceptor(new LoginCheckInterceptor())
|
||||||
|
.addPathPatterns("/**")
|
||||||
|
.excludePathPatterns("/login", "/css/**", "/js/**", "/error");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,72 @@
|
|||||||
package com.example.demo.dto;
|
package com.example.demo.dto;
|
||||||
|
|
||||||
public class BorrowView {
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
/** 貸出情報+申請者名+書籍情報(一覧・確認画面表示用) */
|
||||||
|
public class BorrowView {
|
||||||
|
private final Integer idRequest;
|
||||||
|
private final String nmApplicant;
|
||||||
|
private final String nmBook;
|
||||||
|
private final LocalDate dateRequest;
|
||||||
|
private final LocalDate dateBorrow;
|
||||||
|
private final LocalDate dateScheduledReturn;
|
||||||
|
private final String isbn;
|
||||||
|
private final String publisher;
|
||||||
|
private final String note;
|
||||||
|
private final String status;
|
||||||
|
|
||||||
|
public BorrowView(Integer idRequest, String nmApplicant, String nmBook, LocalDate dateRequest,
|
||||||
|
LocalDate dateBorrow, LocalDate dateScheduledReturn, String isbn,
|
||||||
|
String publisher, String note, String status) {
|
||||||
|
this.idRequest = idRequest;
|
||||||
|
this.nmApplicant = nmApplicant;
|
||||||
|
this.nmBook = nmBook;
|
||||||
|
this.dateRequest = dateRequest;
|
||||||
|
this.dateBorrow = dateBorrow;
|
||||||
|
this.dateScheduledReturn = dateScheduledReturn;
|
||||||
|
this.isbn = isbn;
|
||||||
|
this.publisher = publisher;
|
||||||
|
this.note = note;
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getIdRequest() {
|
||||||
|
return idRequest;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNmApplicant() {
|
||||||
|
return nmApplicant;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNmBook() {
|
||||||
|
return nmBook;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDate getDateRequest() {
|
||||||
|
return dateRequest;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDate getDateBorrow() {
|
||||||
|
return dateBorrow;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDate getDateScheduledReturn() {
|
||||||
|
return dateScheduledReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIsbn() {
|
||||||
|
return isbn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPublisher() {
|
||||||
|
return publisher;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNote() {
|
||||||
|
return note;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,108 @@
|
|||||||
package com.example.demo.entity;
|
package com.example.demo.entity;
|
||||||
|
|
||||||
public class BookCollection {
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.GeneratedValue;
|
||||||
|
import jakarta.persistence.GenerationType;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
|
/** 蔵書テーブル */
|
||||||
|
@Entity
|
||||||
|
@Table(name = "book_collection")
|
||||||
|
public class BookCollection {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
@Column(name = "id_book")
|
||||||
|
private Integer idBook;
|
||||||
|
@Column(name = "isbn")
|
||||||
|
private String isbn;
|
||||||
|
@Column(name = "nm_book")
|
||||||
|
private String nmBook;
|
||||||
|
@Column(name = "kn_book")
|
||||||
|
private String knBook;
|
||||||
|
@Column(name = "publisher")
|
||||||
|
private String publisher;
|
||||||
|
@Column(name = "note", columnDefinition = "text")
|
||||||
|
private String note;
|
||||||
|
@Column(name = "flg_lending")
|
||||||
|
private String flgLending;
|
||||||
|
@Column(name = "id_update")
|
||||||
|
private Integer idUpdate;
|
||||||
|
@Column(name = "date_update")
|
||||||
|
private LocalDateTime dateUpdate;
|
||||||
|
|
||||||
|
public Integer getIdBook() {
|
||||||
|
return idBook;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIdBook(Integer v) {
|
||||||
|
this.idBook = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIsbn() {
|
||||||
|
return isbn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsbn(String v) {
|
||||||
|
this.isbn = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNmBook() {
|
||||||
|
return nmBook;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNmBook(String v) {
|
||||||
|
this.nmBook = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getKnBook() {
|
||||||
|
return knBook;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKnBook(String v) {
|
||||||
|
this.knBook = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPublisher() {
|
||||||
|
return publisher;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPublisher(String v) {
|
||||||
|
this.publisher = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNote() {
|
||||||
|
return note;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNote(String v) {
|
||||||
|
this.note = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFlgLending() {
|
||||||
|
return flgLending;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFlgLending(String v) {
|
||||||
|
this.flgLending = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getIdUpdate() {
|
||||||
|
return idUpdate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIdUpdate(Integer v) {
|
||||||
|
this.idUpdate = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getDateUpdate() {
|
||||||
|
return dateUpdate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDateUpdate(LocalDateTime v) {
|
||||||
|
this.dateUpdate = v;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,139 @@
|
|||||||
package com.example.demo.entity;
|
package com.example.demo.entity;
|
||||||
|
|
||||||
public class BorrowBook {
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.GeneratedValue;
|
||||||
|
import jakarta.persistence.GenerationType;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
|
/** 貸出テーブル(LOAN-01〜05 で使用) */
|
||||||
|
@Entity
|
||||||
|
@Table(name = "borrow_books")
|
||||||
|
public class BorrowBook {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
@Column(name = "id_request")
|
||||||
|
private Integer idRequest;
|
||||||
|
@Column(name = "id_applicant")
|
||||||
|
private Integer idApplicant;
|
||||||
|
@Column(name = "id_book")
|
||||||
|
private Integer idBook;
|
||||||
|
@Column(name = "date_request")
|
||||||
|
private LocalDate dateRequest;
|
||||||
|
@Column(name = "status")
|
||||||
|
private String status;
|
||||||
|
@Column(name = "id_approval")
|
||||||
|
private Integer idApproval;
|
||||||
|
@Column(name = "date_approval")
|
||||||
|
private LocalDate dateApproval;
|
||||||
|
@Column(name = "date_borrow")
|
||||||
|
private LocalDate dateBorrow;
|
||||||
|
@Column(name = "date_scheduled_return")
|
||||||
|
private LocalDate dateScheduledReturn;
|
||||||
|
@Column(name = "date_return")
|
||||||
|
private LocalDate dateReturn;
|
||||||
|
@Column(name = "id_update")
|
||||||
|
private Integer idUpdate;
|
||||||
|
@Column(name = "date_update")
|
||||||
|
private LocalDateTime dateUpdate;
|
||||||
|
|
||||||
|
public Integer getIdRequest() {
|
||||||
|
return idRequest;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIdRequest(Integer v) {
|
||||||
|
this.idRequest = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getIdApplicant() {
|
||||||
|
return idApplicant;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIdApplicant(Integer v) {
|
||||||
|
this.idApplicant = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getIdBook() {
|
||||||
|
return idBook;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIdBook(Integer v) {
|
||||||
|
this.idBook = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDate getDateRequest() {
|
||||||
|
return dateRequest;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDateRequest(LocalDate v) {
|
||||||
|
this.dateRequest = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(String v) {
|
||||||
|
this.status = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getIdApproval() {
|
||||||
|
return idApproval;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIdApproval(Integer v) {
|
||||||
|
this.idApproval = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDate getDateApproval() {
|
||||||
|
return dateApproval;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDateApproval(LocalDate v) {
|
||||||
|
this.dateApproval = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDate getDateBorrow() {
|
||||||
|
return dateBorrow;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDateBorrow(LocalDate v) {
|
||||||
|
this.dateBorrow = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDate getDateScheduledReturn() {
|
||||||
|
return dateScheduledReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDateScheduledReturn(LocalDate v) {
|
||||||
|
this.dateScheduledReturn = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDate getDateReturn() {
|
||||||
|
return dateReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDateReturn(LocalDate v) {
|
||||||
|
this.dateReturn = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getIdUpdate() {
|
||||||
|
return idUpdate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIdUpdate(Integer v) {
|
||||||
|
this.idUpdate = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getDateUpdate() {
|
||||||
|
return dateUpdate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDateUpdate(LocalDateTime v) {
|
||||||
|
this.dateUpdate = v;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,108 @@
|
|||||||
package com.example.demo.entity;
|
package com.example.demo.entity;
|
||||||
|
|
||||||
public class Employee {
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.GeneratedValue;
|
||||||
|
import jakarta.persistence.GenerationType;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
|
/** 社員マスタ */
|
||||||
|
@Entity
|
||||||
|
@Table(name = "employee")
|
||||||
|
public class Employee {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
@Column(name = "id_employee")
|
||||||
|
private Integer idEmployee;
|
||||||
|
@Column(name = "nm_employee")
|
||||||
|
private String nmEmployee;
|
||||||
|
@Column(name = "kn_employee")
|
||||||
|
private String knEmployee;
|
||||||
|
@Column(name = "mail_address")
|
||||||
|
private String mailAddress;
|
||||||
|
@Column(name = "password")
|
||||||
|
private String password;
|
||||||
|
@Column(name = "flg_admin")
|
||||||
|
private String flgAdmin;
|
||||||
|
@Column(name = "flg_retirement")
|
||||||
|
private String flgRetirement;
|
||||||
|
@Column(name = "id_update")
|
||||||
|
private Integer idUpdate;
|
||||||
|
@Column(name = "date_update")
|
||||||
|
private LocalDateTime dateUpdate;
|
||||||
|
|
||||||
|
public Integer getIdEmployee() {
|
||||||
|
return idEmployee;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIdEmployee(Integer v) {
|
||||||
|
this.idEmployee = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNmEmployee() {
|
||||||
|
return nmEmployee;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNmEmployee(String v) {
|
||||||
|
this.nmEmployee = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getKnEmployee() {
|
||||||
|
return knEmployee;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKnEmployee(String v) {
|
||||||
|
this.knEmployee = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMailAddress() {
|
||||||
|
return mailAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMailAddress(String v) {
|
||||||
|
this.mailAddress = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(String v) {
|
||||||
|
this.password = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFlgAdmin() {
|
||||||
|
return flgAdmin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFlgAdmin(String v) {
|
||||||
|
this.flgAdmin = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFlgRetirement() {
|
||||||
|
return flgRetirement;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFlgRetirement(String v) {
|
||||||
|
this.flgRetirement = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getIdUpdate() {
|
||||||
|
return idUpdate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIdUpdate(Integer v) {
|
||||||
|
this.idUpdate = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getDateUpdate() {
|
||||||
|
return dateUpdate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDateUpdate(LocalDateTime v) {
|
||||||
|
this.dateUpdate = v;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,30 @@
|
|||||||
package com.example.demo.form;
|
package com.example.demo.form;
|
||||||
|
|
||||||
public class BookForm {
|
|
||||||
|
|
||||||
|
/** 書籍登録・編集フォーム */
|
||||||
|
public class BookForm {
|
||||||
|
private Integer idBook;
|
||||||
|
private String isbn = "";
|
||||||
|
private String nmBook = "";
|
||||||
|
private String knBook = "";
|
||||||
|
private String publisher = "";
|
||||||
|
private String note = "";
|
||||||
|
|
||||||
|
public void trim() {
|
||||||
|
isbn = t(isbn); nmBook = t(nmBook); knBook = t(knBook); publisher = t(publisher); note = t(note);
|
||||||
|
}
|
||||||
|
private static String t(String s) { return s == null ? "" : s.trim(); }
|
||||||
|
|
||||||
|
public Integer getIdBook() { return idBook; }
|
||||||
|
public void setIdBook(Integer v) { this.idBook = v; }
|
||||||
|
public String getIsbn() { return isbn; }
|
||||||
|
public void setIsbn(String v) { this.isbn = v; }
|
||||||
|
public String getNmBook() { return nmBook; }
|
||||||
|
public void setNmBook(String v) { this.nmBook = v; }
|
||||||
|
public String getKnBook() { return knBook; }
|
||||||
|
public void setKnBook(String v) { this.knBook = v; }
|
||||||
|
public String getPublisher() { return publisher; }
|
||||||
|
public void setPublisher(String v) { this.publisher = v; }
|
||||||
|
public String getNote() { return note; }
|
||||||
|
public void setNote(String v) { this.note = v; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,33 @@
|
|||||||
package com.example.demo.form;
|
package com.example.demo.form;
|
||||||
|
/** 社員登録・編集フォーム */
|
||||||
public class EmployeeForm {
|
public class EmployeeForm {
|
||||||
|
private Integer idEmployee;
|
||||||
|
private String nmEmployee = "";
|
||||||
|
private String knEmployee = "";
|
||||||
|
private String mailAddress = "";
|
||||||
|
private String password = "";
|
||||||
|
private String flgAdmin = "0";
|
||||||
|
private String flgRetirement = "0";
|
||||||
|
|
||||||
|
public void trim() {
|
||||||
|
nmEmployee = t(nmEmployee); knEmployee = t(knEmployee); mailAddress = t(mailAddress);
|
||||||
|
flgAdmin = t(flgAdmin); flgRetirement = t(flgRetirement);
|
||||||
|
if (password == null) password = "";
|
||||||
|
}
|
||||||
|
private static String t(String s) { return s == null ? "" : s.trim(); }
|
||||||
|
|
||||||
|
public Integer getIdEmployee() { return idEmployee; }
|
||||||
|
public void setIdEmployee(Integer v) { this.idEmployee = v; }
|
||||||
|
public String getNmEmployee() { return nmEmployee; }
|
||||||
|
public void setNmEmployee(String v) { this.nmEmployee = v; }
|
||||||
|
public String getKnEmployee() { return knEmployee; }
|
||||||
|
public void setKnEmployee(String v) { this.knEmployee = v; }
|
||||||
|
public String getMailAddress() { return mailAddress; }
|
||||||
|
public void setMailAddress(String v) { this.mailAddress = v; }
|
||||||
|
public String getPassword() { return password; }
|
||||||
|
public void setPassword(String v) { this.password = v; }
|
||||||
|
public String getFlgAdmin() { return flgAdmin; }
|
||||||
|
public void setFlgAdmin(String v) { this.flgAdmin = v; }
|
||||||
|
public String getFlgRetirement() { return flgRetirement; }
|
||||||
|
public void setFlgRetirement(String v) { this.flgRetirement = v; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,39 @@
|
|||||||
package com.example.demo.repository;
|
package com.example.demo.repository;
|
||||||
|
|
||||||
public class BookCollectionRepository {
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Modifying;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
|
||||||
|
import com.example.demo.entity.BookCollection;
|
||||||
|
|
||||||
|
public interface BookCollectionRepository extends JpaRepository<BookCollection, Integer> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 貸出可の蔵書を部分一致(AND)で検索する。
|
||||||
|
* 空文字の条件は「指定なし」。LIKE の特殊文字は呼び出し側で '!' を使ってエスケープ済み。
|
||||||
|
*/
|
||||||
|
@Query("select b from BookCollection b "
|
||||||
|
+ "where b.flgLending = :lending "
|
||||||
|
+ "and (:nm = '' or b.nmBook like concat('%', :nm, '%') escape '!') "
|
||||||
|
+ "and (:publisher = '' or b.publisher like concat('%', :publisher, '%') escape '!') "
|
||||||
|
+ "and (:note = '' or b.note like concat('%', :note, '%') escape '!') "
|
||||||
|
+ "order by b.idBook")
|
||||||
|
List<BookCollection> search(@Param("lending") String lending,
|
||||||
|
@Param("nm") String nm,
|
||||||
|
@Param("publisher") String publisher,
|
||||||
|
@Param("note") String note);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 貸出フラグを from → to に更新する(現在値が from のときだけ更新)。
|
||||||
|
* 戻り値が0なら、既に他の操作で状態が変わっている(状態不整合)。
|
||||||
|
*/
|
||||||
|
@Modifying(clearAutomatically = true, flushAutomatically = true)
|
||||||
|
@Query("update BookCollection b set b.flgLending = :to, b.idUpdate = :uid, b.dateUpdate = :now "
|
||||||
|
+ "where b.idBook = :id and b.flgLending = :from")
|
||||||
|
int updateLending(@Param("id") Integer id, @Param("from") String from, @Param("to") String to,
|
||||||
|
@Param("uid") Integer uid, @Param("now") LocalDateTime now);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,36 @@
|
|||||||
package com.example.demo.repository;
|
package com.example.demo.repository;
|
||||||
|
|
||||||
public class BorrowBookRepository {
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
}
|
import jakarta.persistence.LockModeType;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Lock;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
|
||||||
|
import com.example.demo.dto.BorrowView;
|
||||||
|
import com.example.demo.entity.BorrowBook;
|
||||||
|
|
||||||
|
public interface BorrowBookRepository extends JpaRepository<BorrowBook, Integer> {
|
||||||
|
|
||||||
|
String VIEW = "select new com.example.demo.dto.BorrowView("
|
||||||
|
+ "r.idRequest, e.nmEmployee, b.nmBook, r.dateRequest, r.dateBorrow, r.dateScheduledReturn, "
|
||||||
|
+ "b.isbn, b.publisher, b.note, r.status) "
|
||||||
|
+ "from BorrowBook r, Employee e, BookCollection b "
|
||||||
|
+ "where r.idApplicant = e.idEmployee and r.idBook = b.idBook ";
|
||||||
|
|
||||||
|
/** LOAN-02 / LOAN-04:ステータス指定の一覧 */
|
||||||
|
@Query(VIEW + "and r.status = :status order by r.idRequest")
|
||||||
|
List<BorrowView> findViewsByStatus(@Param("status") String status);
|
||||||
|
|
||||||
|
/** 確認画面用:申請IDで1件 */
|
||||||
|
@Query(VIEW + "and r.idRequest = :id")
|
||||||
|
List<BorrowView> findViewById(@Param("id") Integer id);
|
||||||
|
|
||||||
|
/** 承認・却下・返却:更新前に行ロックを取って同時操作を防ぐ */
|
||||||
|
@Lock(LockModeType.PESSIMISTIC_WRITE)
|
||||||
|
@Query("select r from BorrowBook r where r.idRequest = :id")
|
||||||
|
Optional<BorrowBook> findForUpdate(@Param("id") Integer id);
|
||||||
|
}
|
||||||
@@ -1,5 +1,13 @@
|
|||||||
package com.example.demo.repository;
|
package com.example.demo.repository;
|
||||||
|
|
||||||
public class EmployeeRepository {
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
import com.example.demo.entity.Employee;
|
||||||
|
|
||||||
|
public interface EmployeeRepository extends JpaRepository<Employee, Integer> {
|
||||||
|
Optional<Employee> findByMailAddressAndFlgRetirement(String mailAddress, String flgRetirement);
|
||||||
|
|
||||||
|
Optional<Employee> findByMailAddress(String mailAddress);
|
||||||
}
|
}
|
||||||
|
|||||||
10
book-rent/src/main/resources/templates/frament/header.html
Normal file
10
book-rent/src/main/resources/templates/frament/header.html
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Insert title here</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -2,35 +2,27 @@
|
|||||||
<html xmlns:th="http://www.thymeleaf.org">
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>メニュー</title>
|
<title>メニュー</title>
|
||||||
|
<!-- <link rel="stylesheet" th:href="@{/css/style.css}">-->
|
||||||
<link rel="stylesheet" th:href="@{/css/all.css}">
|
|
||||||
<link rel="stylesheet" th:href="@{/css/style.css}">
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
<div th:replace="~{fragments/header :: header}"></div>
|
||||||
<h1>メニュー</h1>
|
<main>
|
||||||
|
<h1>メニュー</h1>
|
||||||
<div class="userInfo">
|
<div class="error" th:if="${errorMessage}" th:text="${errorMessage}"></div>
|
||||||
<span>ログインユーザー:</span>
|
<div class="card menu">
|
||||||
<span th:text="${loginUserName}">ユーザー名</span>
|
<a class="btn" th:href="@{/books}">書籍一覧</a>
|
||||||
|
<!-- 管理者のみ(サーバー側でも /admin/** は管理者以外を拒否している) -->
|
||||||
<form th:action="@{/logout}" method="post">
|
<th:block th:if="${session.loginUser.admin}">
|
||||||
<button type="submit">ログアウト</button>
|
<a class="btn" th:href="@{/admin/applications}">書籍貸出申請一覧</a>
|
||||||
</form>
|
<a class="btn" th:href="@{/admin/lendings}">貸出中書籍一覧</a>
|
||||||
</div>
|
<a class="btn" th:href="@{/admin/employees/new}">社員登録</a>
|
||||||
|
</th:block>
|
||||||
<div class="menuArea">
|
<a class="btn" th:href="@{/employees/search}">社員編集</a>
|
||||||
<form th:action="@{/book/list}" method="get">
|
</div>
|
||||||
<button type="submit">書籍一覧</button>
|
</main>
|
||||||
</form>
|
|
||||||
|
|
||||||
<form th:action="@{/book/rent}" method="get">
|
|
||||||
<button type="submit">書籍貸出申請一覧</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
Reference in New Issue
Block a user