Initial commit

This commit is contained in:
Zzzz
2026-04-27 18:40:30 +08:00
commit 2120774b05
112 changed files with 12308 additions and 0 deletions
@@ -0,0 +1,49 @@
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Login - MZH Library</title>
<link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/app.css">
</head>
<body class="auth-page">
<%@ include file="/WEB-INF/jsp/common/header.jspf" %>
<main class="auth-shell">
<section class="login-panel" aria-labelledby="login-title">
<div>
<p class="eyebrow">Library Management</p>
<h1 id="login-title">Sign in</h1>
</div>
<c:if test="${not empty errorMessage}">
<div class="message message-error" role="alert">
<c:out value="${errorMessage}" />
</div>
</c:if>
<form class="login-form" action="${pageContext.request.contextPath}/login" method="post" novalidate>
<input type="hidden" name="redirect" value="${fn:escapeXml(redirect)}">
<label for="username">Username</label>
<input id="username"
name="username"
type="text"
value="${fn:escapeXml(username)}"
autocomplete="username"
required>
<label for="password">Password</label>
<input id="password"
name="password"
type="password"
autocomplete="current-password"
required>
<button class="button button-primary" type="submit">Sign in</button>
</form>
</section>
</main>
</body>
</html>
@@ -0,0 +1,28 @@
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Unauthorized - MZH Library</title>
<link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/app.css">
</head>
<body>
<%@ include file="/WEB-INF/jsp/common/header.jspf" %>
<main class="page-shell">
<section class="notice-panel" aria-labelledby="unauthorized-title">
<h1 id="unauthorized-title">Access denied</h1>
<p>
<c:choose>
<c:when test="${not empty errorMessage}">
<c:out value="${errorMessage}" />
</c:when>
<c:otherwise>You do not have permission to access this page.</c:otherwise>
</c:choose>
</p>
<a class="button button-primary" href="${pageContext.request.contextPath}/dashboard">Back to dashboard</a>
</section>
</main>
</body>
</html>
@@ -0,0 +1,20 @@
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<header class="app-header">
<a class="brand" href="${pageContext.request.contextPath}/dashboard">MZH Library</a>
<c:if test="${not empty sessionScope.authenticatedUser}">
<nav class="top-nav" aria-label="Primary">
<a href="${pageContext.request.contextPath}/dashboard">Dashboard</a>
<c:if test="${sessionScope.userRole == 'administrator'}">
<a href="${pageContext.request.contextPath}/admin/home">Admin</a>
</c:if>
<c:if test="${sessionScope.userRole == 'administrator' or sessionScope.userRole == 'librarian'}">
<a href="${pageContext.request.contextPath}/librarian/home">Librarian</a>
</c:if>
<a href="${pageContext.request.contextPath}/reader/home">Reader</a>
<span class="user-pill">
<c:out value="${sessionScope.authenticatedUser.displayName}" />
</span>
<a class="button button-secondary" href="${pageContext.request.contextPath}/logout">Logout</a>
</nav>
</c:if>
</header>
+47
View File
@@ -0,0 +1,47 @@
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Dashboard - MZH Library</title>
<link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/app.css">
</head>
<body>
<%@ include file="/WEB-INF/jsp/common/header.jspf" %>
<main class="page-shell">
<section class="dashboard-hero" aria-labelledby="dashboard-title">
<p class="eyebrow">
<c:out value="${sessionScope.authenticatedUser.role.displayName}" />
</p>
<h1 id="dashboard-title">Dashboard</h1>
<p>Signed in as <strong><c:out value="${sessionScope.authenticatedUser.displayName}" /></strong>.</p>
</section>
<section class="card-grid" aria-label="Role workspaces">
<c:if test="${sessionScope.userRole == 'administrator'}">
<article class="workspace-card">
<h2>Administration</h2>
<p>Account, role, permission, and system-maintenance entry point.</p>
<a class="button button-secondary" href="${pageContext.request.contextPath}/admin/home">Open</a>
</article>
</c:if>
<c:if test="${sessionScope.userRole == 'administrator' or sessionScope.userRole == 'librarian'}">
<article class="workspace-card">
<h2>Librarian Workspace</h2>
<p>Book, reader, borrowing, return, renewal, and overdue entry point.</p>
<a class="button button-secondary" href="${pageContext.request.contextPath}/librarian/home">Open</a>
</article>
</c:if>
<article class="workspace-card">
<h2>Reader Center</h2>
<p>Catalog search and reader self-service entry point.</p>
<a class="button button-secondary" href="${pageContext.request.contextPath}/reader/home">Open</a>
</article>
</section>
</main>
</body>
</html>
+24
View File
@@ -0,0 +1,24 @@
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><c:out value="${areaName}" /> - MZH Library</title>
<link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/app.css">
</head>
<body>
<%@ include file="/WEB-INF/jsp/common/header.jspf" %>
<main class="page-shell">
<section class="notice-panel" aria-labelledby="area-title">
<p class="eyebrow">
<c:out value="${sessionScope.authenticatedUser.role.displayName}" />
</p>
<h1 id="area-title"><c:out value="${areaName}" /></h1>
<p><c:out value="${areaSummary}" /></p>
<a class="button button-primary" href="${pageContext.request.contextPath}/dashboard">Back to dashboard</a>
</section>
</main>
</body>
</html>
+90
View File
@@ -0,0 +1,90 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
<display-name>MZH Library Management</display-name>
<filter>
<filter-name>CharacterEncodingFilter</filter-name>
<filter-class>com.mzh.library.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>AuthenticationFilter</filter-name>
<filter-class>com.mzh.library.filter.AuthenticationFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>AuthenticationFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>AuthorizationFilter</filter-name>
<filter-class>com.mzh.library.filter.AuthorizationFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>AuthorizationFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>LoginServlet</servlet-name>
<servlet-class>com.mzh.library.controller.LoginServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>LoginServlet</servlet-name>
<url-pattern>/login</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>LogoutServlet</servlet-name>
<servlet-class>com.mzh.library.controller.LogoutServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>LogoutServlet</servlet-name>
<url-pattern>/logout</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>DashboardServlet</servlet-name>
<servlet-class>com.mzh.library.controller.DashboardServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>DashboardServlet</servlet-name>
<url-pattern>/dashboard</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>RoleAreaServlet</servlet-name>
<servlet-class>com.mzh.library.controller.RoleAreaServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>RoleAreaServlet</servlet-name>
<url-pattern>/admin/home</url-pattern>
<url-pattern>/librarian/home</url-pattern>
<url-pattern>/reader/home</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>UnauthorizedServlet</servlet-name>
<servlet-class>com.mzh.library.controller.UnauthorizedServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>UnauthorizedServlet</servlet-name>
<url-pattern>/unauthorized</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
+3
View File
@@ -0,0 +1,3 @@
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:redirect url="/login" />
+263
View File
@@ -0,0 +1,263 @@
:root {
color-scheme: light;
--color-ink: #202124;
--color-muted: #5f6368;
--color-border: #d9dde3;
--color-panel: #ffffff;
--color-page: #f5f7fb;
--color-primary: #256f6c;
--color-primary-strong: #1b5654;
--color-accent: #b54238;
--shadow-panel: 0 18px 45px rgba(28, 39, 49, 0.12);
}
* {
box-sizing: border-box;
}
body {
margin: 0;
min-height: 100vh;
color: var(--color-ink);
background: var(--color-page);
font-family: Arial, "Microsoft YaHei", sans-serif;
line-height: 1.5;
}
a {
color: inherit;
}
.app-header {
min-height: 64px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 24px;
padding: 0 32px;
border-bottom: 1px solid var(--color-border);
background: rgba(255, 255, 255, 0.96);
}
.brand {
color: var(--color-primary-strong);
font-weight: 700;
text-decoration: none;
}
.top-nav {
display: flex;
align-items: center;
gap: 14px;
flex-wrap: wrap;
color: var(--color-muted);
font-size: 14px;
}
.top-nav a {
text-decoration: none;
}
.user-pill {
max-width: 220px;
padding: 6px 10px;
overflow: hidden;
color: var(--color-ink);
border: 1px solid var(--color-border);
border-radius: 6px;
text-overflow: ellipsis;
white-space: nowrap;
}
.auth-page {
background:
linear-gradient(rgba(245, 247, 251, 0.86), rgba(245, 247, 251, 0.92)),
url("../images/library-login.svg") center / cover no-repeat;
}
.auth-shell,
.page-shell {
width: min(1120px, calc(100% - 32px));
margin: 0 auto;
}
.auth-shell {
min-height: calc(100vh - 64px);
display: grid;
align-items: center;
padding: 48px 0;
}
.login-panel,
.notice-panel,
.dashboard-hero,
.workspace-card {
border: 1px solid var(--color-border);
border-radius: 8px;
background: var(--color-panel);
box-shadow: var(--shadow-panel);
}
.login-panel {
width: min(420px, 100%);
padding: 32px;
}
.eyebrow {
margin: 0 0 6px;
color: var(--color-primary);
font-size: 13px;
font-weight: 700;
letter-spacing: 0;
text-transform: uppercase;
}
h1,
h2,
p {
margin-top: 0;
}
h1 {
margin-bottom: 18px;
font-size: 32px;
line-height: 1.15;
}
h2 {
margin-bottom: 10px;
font-size: 20px;
}
.login-form {
display: grid;
gap: 10px;
}
.login-form label {
color: var(--color-muted);
font-size: 14px;
font-weight: 700;
}
.login-form input {
width: 100%;
min-height: 44px;
padding: 10px 12px;
border: 1px solid var(--color-border);
border-radius: 6px;
font: inherit;
}
.login-form input:focus {
outline: 3px solid rgba(37, 111, 108, 0.18);
border-color: var(--color-primary);
}
.button {
display: inline-flex;
min-height: 40px;
align-items: center;
justify-content: center;
padding: 9px 14px;
border: 1px solid transparent;
border-radius: 6px;
font: inherit;
font-weight: 700;
text-decoration: none;
cursor: pointer;
}
.button-primary {
margin-top: 12px;
color: #ffffff;
background: var(--color-primary);
}
.button-primary:hover {
background: var(--color-primary-strong);
}
.button-secondary {
color: var(--color-primary-strong);
border-color: rgba(37, 111, 108, 0.35);
background: #ffffff;
}
.message {
margin-bottom: 16px;
padding: 10px 12px;
border-radius: 6px;
font-size: 14px;
}
.message-error {
color: #7a211a;
border: 1px solid rgba(181, 66, 56, 0.3);
background: #fff0ee;
}
.page-shell {
padding: 36px 0 56px;
}
.dashboard-hero {
padding: 28px;
margin-bottom: 24px;
}
.dashboard-hero p:last-child,
.workspace-card p:last-child,
.notice-panel p:last-child {
margin-bottom: 0;
}
.card-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
gap: 18px;
}
.workspace-card {
min-height: 190px;
display: flex;
flex-direction: column;
align-items: flex-start;
padding: 24px;
}
.workspace-card p {
color: var(--color-muted);
}
.workspace-card .button {
margin-top: auto;
}
.notice-panel {
max-width: 680px;
padding: 28px;
}
@media (max-width: 720px) {
.app-header {
align-items: flex-start;
flex-direction: column;
padding: 16px;
}
.top-nav {
width: 100%;
}
h1 {
font-size: 28px;
}
.login-panel,
.notice-panel,
.dashboard-hero,
.workspace-card {
box-shadow: none;
}
}
@@ -0,0 +1,21 @@
<svg xmlns="http://www.w3.org/2000/svg" width="1440" height="960" viewBox="0 0 1440 960" role="img" aria-label="Library shelves">
<rect width="1440" height="960" fill="#e8edf1"/>
<rect x="0" y="705" width="1440" height="255" fill="#d4ddd8"/>
<g opacity="0.92">
<rect x="760" y="145" width="390" height="560" rx="8" fill="#f9fbfc" stroke="#bfcbc9" stroke-width="8"/>
<rect x="800" y="205" width="310" height="28" fill="#256f6c"/>
<rect x="800" y="270" width="310" height="28" fill="#b54238"/>
<rect x="800" y="335" width="310" height="28" fill="#4b6572"/>
<rect x="800" y="400" width="310" height="28" fill="#d7a441"/>
<rect x="800" y="465" width="310" height="28" fill="#256f6c"/>
<rect x="800" y="530" width="310" height="28" fill="#7f8d95"/>
<rect x="800" y="595" width="310" height="28" fill="#b54238"/>
</g>
<g opacity="0.84">
<rect x="1210" y="245" width="92" height="460" rx="8" fill="#ffffff" stroke="#bfcbc9" stroke-width="7"/>
<rect x="1232" y="282" width="48" height="385" fill="#256f6c"/>
<rect x="1232" y="282" width="48" height="65" fill="#d7a441"/>
</g>
<circle cx="1095" cy="128" r="36" fill="#d7a441" opacity="0.75"/>
<rect x="0" y="730" width="1440" height="8" fill="#bfcbc9"/>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB