This commit is contained in:
2026-09-24 16:14:16 +09:00
20 changed files with 878 additions and 58 deletions

View File

@@ -0,0 +1,13 @@
package com.example.demo.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class ApprovalReceive {
@GetMapping("/approvalReceive")
public String approvalReceive() {
return "approvalReceive";
}
}

View File

@@ -1,14 +1,15 @@
package com.example.demo.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@Controller
public class BookController {
@GetMapping("/book")
@PostMapping("/book")
public String book() {
return "book";
}
}

View File

@@ -0,0 +1,13 @@
package com.example.demo.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
@Controller
public class BookUpdateConfirmController {
@PostMapping("/updateconfirm")
public String updateConfirm() {
return "updateconfirm";
}
}

View File

@@ -0,0 +1,19 @@
package com.example.demo.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
@Controller
public class BookUpdateController {
@PostMapping("/update")
public String update() {
return "update";
}
@PostMapping("/bookUpdate")
public String bookUpdate() {
return "book";
}
}

View File

@@ -0,0 +1,13 @@
package com.example.demo.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class LendListController {
@GetMapping("/lendList")
public String lendList() {
return "lendList";
}
}

View File

@@ -1,22 +1,77 @@
package com.example.demo.controller;
import jakarta.servlet.http.HttpSession;
import jakarta.validation.Valid;
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 com.example.demo.entity.AccountEntity;
import com.example.demo.form.LoginForm;
import com.example.demo.service.LoginService;
import lombok.RequiredArgsConstructor;
@Controller
@RequiredArgsConstructor
public class LoginController {
@GetMapping("/login")
public String showLogin() {
return "login";
private final LoginService loginService;
// Boot起動直後にログイン画面に移動する用のメソッド
@GetMapping("/")
public String index(HttpSession session) {
if (session.getAttribute("loginEmployee") != null) {
return "redirect:/topmenu";
}
return "redirect:/login";
}
@PostMapping("/doLogin")
public String doLogin() {
@GetMapping("/login")
public String loginForm(Model model, HttpSession session) {
if (session.getAttribute("loginEmployee") != null) {
return "redirect:/topmenu";
}
model.addAttribute("loginForm", new LoginForm());
return "login";
}
// 実際のログイン処理
@PostMapping("/login")
public String doLogin(
@Valid @ModelAttribute LoginForm loginForm,
BindingResult bindingResult,
Model model,
HttpSession session) {
if (bindingResult.hasErrors()) {
return "login";
}
AccountEntity accountEntity = loginService.login(loginForm);
if (accountEntity == null) {
model.addAttribute("loginError",
"ログインIDまたはパスワードが正しくありません");
return "login";
}
session.setAttribute("loginEmployee", accountEntity);
return "redirect:/topmenu";
}
// ログアウト処理
@GetMapping("/logout")
public String logout(HttpSession session) {
session.invalidate();
return "redirect:/login";
}
// 各画面からトップメニューへの遷移用
@GetMapping("/topmenu")
public String showTopMenu() {
return "topmenu";

View File

@@ -0,0 +1,14 @@
package com.example.demo.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class PasswordChangeController {
@GetMapping("/passwordChange")
public String showPasswordChange() {
return "passwordChange";
}
}

View File

@@ -0,0 +1,40 @@
package com.example.demo.entity;
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 lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
/*
* accountテーブル用のEntityクラス
* ログイン時やセッションでの管理者判別に使う
*/
@Entity
@Table(name = "account")
@Getter
@Setter
@NoArgsConstructor
public class AccountEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name="login_info_id")
private Integer loginInfoId;
@Column(name="employee_id")
private Integer employeeId;
@Column(name="password_hash")
private String passwordHash;
@Column(name="admin_flag")
private int adminFlag;
}

View File

@@ -0,0 +1,17 @@
package com.example.demo.form;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
@Data
public class LoginForm {
@NotNull(message = "社員IDを入力してください")
private Integer employeeId;
@NotBlank(message = "パスワードを入力してください")
private String passwordHash;
}

View File

@@ -0,0 +1,11 @@
package com.example.demo.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import com.example.demo.entity.AccountEntity;
public interface AccountRepository extends JpaRepository<AccountEntity,Integer>{
AccountEntity findByEmployeeId (Integer employeeId);
}

View File

@@ -0,0 +1,31 @@
package com.example.demo.service;
import org.springframework.stereotype.Service;
import com.example.demo.entity.AccountEntity;
import com.example.demo.form.LoginForm;
import com.example.demo.repository.AccountRepository;
import lombok.RequiredArgsConstructor;
@Service
@RequiredArgsConstructor
public class LoginService {
private final AccountRepository accountRepository;
public AccountEntity login(LoginForm form) {
AccountEntity accountEntity =
accountRepository.findByEmployeeId(form.getEmployeeId());
if(accountEntity == null) {
return null;
}
if(!accountEntity.getPasswordHash().equals(form.getPasswordHash()))
return null;
return accountEntity;
}
}

View File

@@ -0,0 +1,62 @@
function togglePassword(id) {
const input = document.getElementById(id);
if (input === null) {
return;
}
if (input.type === "password") {
input.type = "text";
} else {
input.type = "password";
}
}
function clearForm() {
const form = document.getElementById("pwForm");
if (form === null) {
return;
}
form.reset();
}
function showCompletedPopup() {
const completedDialog = document.getElementById("completedDialog");
if (completedDialog === null) {
return;
}
completedDialog.showModal();
}
function goTopMenu() {
const topMenuUrl = document.body.dataset.topmenuUrl;
if (topMenuUrl) {
window.location.href = topMenuUrl;
return;
}
window.location.href = "/topmenu";
}
function goLogin(){
const loginUrl = document.body.dataset.loginUrl;
if (loginUrl){
window.location.href = loginUrl;
return;
}
window.location.href="/login"
}

View File

@@ -1,10 +1,34 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>寄贈申請 受信BOX</title>
</head>
<body>
<h1>寄贈申請 受信BOX</h1>
<!-- action先要修正 -->
<form action="/approvalReceive" method="GET">
<input type="submit" value="承認" class="btn">
</form>
<!-- action先要修正 -->
<form action="/approvalReceive" method="GET">
<input type="submit" value="却下" class="btn">
</form>
<!-- 新規登録画面へ遷移 -->
<form action="/bookInsert" method="GET">
<input type="submit" value="登録" class="btn">
</form>
<!-- action先要修正 -->
<form action="/approvalReceive" method="GET">
<input type="submit" value="戻る" class="btn">
</form>
</body>
</html>

View File

@@ -14,5 +14,12 @@
</button>
</form>
<form method="post" action="update">
<button type="submit" class="btn-login">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4"/><polyline points="10 17 15 12 10 7"/><line x1="15" y1="12" x2="3" y2="12"/></svg>
更新
</button>
</form>
</body>
</html>

View File

@@ -0,0 +1,48 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>貸出中図書一覧</title>
</head>
<body>
<h1>貸出中図書一覧</h1>
<!-- action先要修正 -->
<form action="/lendList" method="GET">
<input type="submit" value="返却" class="btn">
</form>
<!-- 以下ポップアップ -->
<div id="registerModal" class="modal-overlay">
<div class="modal">
<div class="modal-message">
返却処理が完了しました!
</div>
<div class="modal-buttons">
<!-- OK -->
<form method="get" action="/lendList">
<button type="submit" class="modal-btn">
OK
</button>
</form>
</div>
</div>
</div>
</body>
</html>

View File

@@ -1,29 +1,35 @@
<!DOCTYPE html>
<html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<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>
<p class="message message-error" th:if="${loginError}" th:text="${loginError}">
</p>
<form th:action="@{/login}" th:object="${loginForm}" method="post">
<div class="form-group">
<label for="employeeId">社員ID</label>
<input id="employeeId" type="text" th:field="*{employeeId}">
<p class="field-error" th:errors="*{employeeId}"></p>
</div>
<table>
<tr>
<td class="btnArea" colspan="2">
<input type="submit" value="ログイン"/>
<button onclick="clearInput()">リセット</button>
</td>
</tr>
</table>
<div class="form-group">
<label for="passwordHash">パスワード</label>
<input id="passwordHash" type="password" th:field="*{passwordHash}">
<p class="field-error" th:errors="*{passwordHash}"></p>
</div>
<input type="submit" value="ログイン">
<input type="reset" value="リセット">
</form>
</body>
</html>

View File

@@ -0,0 +1,377 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="ja">
<head>
<meta charset="UTF-8">
<title>ShareBooks|パスワード変更</title>
</head>
<body th:data-topmenu-url="@{/topmenu}">
<!-- ヘッダー -->
<div class="header-bar">
<div class="header-left">
ShareBooks
</div>
<div class="header-right">
<span class="bell">
🔔
<span class="badge">3</span>
</span>
<span class="user">
テストユーザー(一般)
</span>
<button type="button" class="logout">
ログアウト
</button>
</div>
</div>
<div class="layout">
<!-- サイドバー -->
<div class="sidebar">
<div class="section-label">
共通画面
</div>
<a class="side-menu" th:href="@{/topmenu}">
トップメニュー
</a>
<div class="active">
パスワード再設定
</div>
</div>
<!-- メイン -->
<div class="main-area">
<!-- パンくずリスト -->
<div class="breadcrumb">
<a th:href="@{/topmenu}">
トップメニュー
</a>
&gt; パスワード再設定
</div>
<h1 class="page-title">
パスワード再設定
</h1>
<p class="page-desc">
現在のパスワードと新しいパスワードを入力し、
「確定」ボタンを押してください。
</p>
<p class="required-note">
(※)は必須項目です。
</p>
<div class="content-columns">
<!-- 左カラム -->
<div class="left-column">
<div class="form-card">
<h2>
パスワード再設定入力
</h2>
<!--
簡易実装のため、フォーム送信は行いません。
-->
<form id="pwForm" onsubmit="return false;">
<!-- 現在のパスワード -->
<div class="form-group">
<label for="currentPassword">
現在のパスワード
<span class="req">(※)</span>
</label>
<div class="input-with-icon">
<input
type="password"
id="currentPassword"
name="currentPassword"
autocomplete="current-password"
placeholder="現在のパスワードを入力してください">
<button
type="button"
class="toggle-password"
aria-label="現在のパスワードの表示を切り替える"
onclick="togglePassword('currentPassword')">
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round">
<path
d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z">
</path>
<circle
cx="12"
cy="12"
r="3">
</circle>
</svg>
</button>
</div>
</div>
<!-- 新しいパスワード -->
<div class="form-group">
<label for="newPassword">
新しいパスワード
<span class="req">(※)</span>
</label>
<div class="input-with-icon">
<input
type="password"
id="newPassword"
name="newPassword"
autocomplete="new-password"
placeholder="新しいパスワードを入力してください">
<button
type="button"
class="toggle-password"
aria-label="新しいパスワードの表示を切り替える"
onclick="togglePassword('newPassword')">
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round">
<path
d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z">
</path>
<circle
cx="12"
cy="12"
r="3">
</circle>
</svg>
</button>
</div>
<p class="field-hint">
※ 半角英数字・記号を含む8文字以上16文字以下で入力してください。
</p>
</div>
<!-- 確認用パスワード -->
<div class="form-group">
<label for="confirmPassword">
新しいパスワードの確認
<span class="req">(※)</span>
</label>
<div class="input-with-icon">
<input
type="password"
id="confirmPassword"
name="confirmPassword"
autocomplete="new-password"
placeholder="新しいパスワードをもう一度入力してください">
<button
type="button"
class="toggle-password"
aria-label="確認用パスワードの表示を切り替える"
onclick="togglePassword('confirmPassword')">
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round">
<path
d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z">
</path>
<circle
cx="12"
cy="12"
r="3">
</circle>
</svg>
</button>
</div>
<p class="field-hint">
※ 確認のため、もう一度新しいパスワードを入力してください。
</p>
</div>
</form>
</div>
<!-- 注意事項 -->
<div class="notice-box">
<div class="notice-title">
注意事項
</div>
</div>
<!-- 操作ボタン -->
<div class="button-row">
<button
type="button"
class="btn btn-secondary"
onclick="goTopMenu()">
トップメニューへ戻る
</button>
<div class="btn-group-right">
<button
type="button"
class="btn btn-secondary"
onclick="clearForm()">
クリア
</button>
<!-- ダイアログを表示 -->
<button
type="button"
class="btn btn-primary"
onclick="showCompletedPopup()">
確定
</button>
</div>
</div>
</div>
<!-- 右カラム -->
<div class="right-column">
<div class="constraint-panel">
<div class="panel-title">
パスワードの制約
</div>
<div class="group-label">
使用可能文字
</div>
<div class="chars-value">
半角英数字・記号
</div>
<hr>
<div class="group-label">
制約
</div>
<ul class="constraint-list">
<li>✓ 8文字以上16文字以下</li>
<li>✓ 1つ以上の小文字を使用</li>
<li>✓ 1つ以上の大文字を使用</li>
<li>✓ 1つ以上の数字を使用</li>
<li>✓ 1つ以上の記号を使用</li>
</ul>
<div class="example-box">
<div class="example-label">
設定例
</div>
<div class="example-value">
Abcdef12!
</div>
<div class="example-note">
(9文字、英字大小・数字・記号を含む)
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="footer">
© 2026 ShareBooks
</div>
<dialog id="completedDialog">
<h2>
変更完了
</h2>
<p>
パスワードの変更が完了しました。
</p>
<button
type="button"
onclick="goLogin()">
完了
</button>
</dialog>
<script th:src="@{/js/passwordChange.js}"></script>
</body>
</html>

View File

@@ -1,29 +1,56 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>トップメニュー</title>
</head>
<body>
<div class="header-bar">
<div class="header-left">
ShareBooks
</div>
<div class="header-right">
<span class="user">
テストユーザー(一般)
</span>
<a class="button-link" th:href="@{/logout}">
ログアウト
</a>
</div>
</div>
<h1>
メインメニュー
</h1>
<!-- ===== 共通:社内図書一覧 ===== -->
<a class="card" href="${pageContext.request.contextPath}/BookServlet">
<form method="post" name="社内図書一覧" action="book">
<a href="javascript:form1.submit()">リンク名</a>
<button type="submit" class="btn-book">
<h3>社内図書一覧</h3>
<p>
登録されている図書の<br> 一覧を表示します。
</p>
</a>
</button>
</form>
<hr> <!--区切り線-->
<!-- ===== 共通:寄贈申請 ===== -->
<a class="card" href="${pageContext.request.contextPath}/employee">
<a class="card" href="/bookApproval">
<h3>寄贈申請</h3>
@@ -48,7 +75,7 @@
<hr>
<a class="card" href="${pageContext.request.contextPath}/lendList">
<a class="card" href="/lendList">
<h3>貸出中図書一覧</h3>
@@ -59,7 +86,7 @@
<hr>
<a class="card" href="${pageContext.request.contextPath}/bookApproval-list">
<a class="card" href="/approvalReceive">
<h3>寄贈申請受信BOX</h3>
@@ -68,5 +95,16 @@
</p>
</a>
<hr>
<a class="card" href="/passwordChange">
<h3>パスワード変更</h3>
<p>
初期パスワードを<br> 変更します。
</p>
</a>
</body>
</html>

View File

@@ -5,6 +5,13 @@
<title>図書情報更新入力</title>
</head>
<body>
更新入力画面
<form method="post" action="updateconfirm">
<button type="submit" class="btn-login">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4"/><polyline points="10 17 15 12 10 7"/><line x1="15" y1="12" x2="3" y2="12"/></svg>
更新内容確認
</button>
</form>
</body>
</html>

View File

@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>更新内容確認</title>
</head>
<body>
更新内容確認画面
<form method="post" action="update">
<button type="submit" class="btn-login">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4"/><polyline points="10 17 15 12 10 7"/><line x1="15" y1="12" x2="3" y2="12"/></svg>
戻る
</button>
</form>
<form method="post" action="bookUpdate">
<button type="submit" class="btn-login">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4"/><polyline points="10 17 15 12 10 7"/><line x1="15" y1="12" x2="3" y2="12"/></svg>
更新完了
</button>
</form>
</body>
</html>