Files
springboot-demo/src/main/resources/static/index.html

409 lines
18 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
2026-03-18 16:43:04 +08:00
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
2026-03-19 13:53:49 +08:00
<title>Spring Boot Learning Cockpit</title>
<style>
2026-03-18 16:43:04 +08:00
:root {
2026-03-19 13:53:49 +08:00
--bg: #eef5ff;
--panel: rgba(255, 255, 255, 0.94);
--line: #d8e4f0;
--text: #122033;
--muted: #5d7288;
--brand: #177245;
--accent: #0f67b5;
--warm: #f08c2b;
--shadow: 0 22px 54px rgba(18, 32, 51, 0.12);
2026-03-18 16:43:04 +08:00
}
* { box-sizing: border-box; }
body {
margin: 0;
color: var(--text);
2026-03-19 13:53:49 +08:00
font-family: "Aptos", "Segoe UI", "Microsoft YaHei", sans-serif;
background:
radial-gradient(circle at top left, rgba(23, 114, 69, 0.14), transparent 28%),
radial-gradient(circle at bottom right, rgba(15, 103, 181, 0.14), transparent 26%),
var(--bg);
2026-03-18 16:43:04 +08:00
}
2026-03-19 13:53:49 +08:00
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
.page { max-width: 1380px; margin: 0 auto; padding: 24px; }
.hero, .card {
background: var(--panel);
border: 1px solid var(--line);
2026-03-18 16:43:04 +08:00
border-radius: 28px;
box-shadow: var(--shadow);
2026-03-19 13:53:49 +08:00
backdrop-filter: blur(10px);
2026-03-18 16:43:04 +08:00
}
2026-03-19 13:53:49 +08:00
.hero { padding: 28px; margin-bottom: 18px; }
2026-03-18 16:43:04 +08:00
.eyebrow {
display: inline-flex;
2026-03-19 13:53:49 +08:00
padding: 7px 12px;
2026-03-18 16:43:04 +08:00
border-radius: 999px;
2026-03-19 13:53:49 +08:00
background: rgba(23, 114, 69, 0.1);
color: var(--brand);
2026-03-18 16:43:04 +08:00
font-size: 12px;
2026-03-19 13:53:49 +08:00
font-weight: 800;
letter-spacing: 0.1em;
2026-03-18 16:43:04 +08:00
text-transform: uppercase;
}
2026-03-19 13:53:49 +08:00
h1, h2, h3 { margin: 10px 0 12px; }
p { margin: 0; color: var(--muted); line-height: 1.8; }
.hero-grid, .workspace, .triple {
display: grid;
gap: 18px;
2026-03-18 16:43:04 +08:00
}
2026-03-19 13:53:49 +08:00
.hero-grid {
grid-template-columns: 1.3fr 0.9fr;
align-items: start;
2026-03-18 16:43:04 +08:00
}
2026-03-19 13:53:49 +08:00
.actions, .chip-list, .toolbar, .demo-links {
2026-03-18 16:43:04 +08:00
display: flex;
2026-03-19 13:53:49 +08:00
gap: 10px;
2026-03-18 16:43:04 +08:00
flex-wrap: wrap;
}
2026-03-19 13:53:49 +08:00
.btn, .btn-soft {
2026-03-18 16:43:04 +08:00
display: inline-flex;
align-items: center;
justify-content: center;
2026-03-19 13:53:49 +08:00
border: 0;
border-radius: 999px;
2026-03-18 16:43:04 +08:00
padding: 12px 18px;
2026-03-19 13:53:49 +08:00
cursor: pointer;
2026-03-18 16:43:04 +08:00
font-weight: 700;
}
2026-03-19 13:53:49 +08:00
.btn {
color: #fff;
background: linear-gradient(135deg, var(--brand), #35a465);
}
.btn-soft {
color: var(--accent);
background: #eaf3ff;
}
.card { padding: 22px; }
.stats {
2026-03-18 16:43:04 +08:00
display: grid;
2026-03-19 13:53:49 +08:00
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 12px;
margin-top: 18px;
2026-03-18 16:43:04 +08:00
}
2026-03-19 13:53:49 +08:00
.stat {
padding: 16px;
border-radius: 18px;
border: 1px solid var(--line);
background: rgba(255,255,255,0.5);
2026-03-18 16:43:04 +08:00
}
2026-03-19 13:53:49 +08:00
.stat span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.stat strong { font-size: 28px; }
.workspace {
grid-template-columns: 380px minmax(0, 1fr);
align-items: start;
2026-03-18 16:43:04 +08:00
}
2026-03-19 13:53:49 +08:00
.triple {
grid-template-columns: repeat(3, minmax(0, 1fr));
2026-03-18 16:43:04 +08:00
}
2026-03-19 13:53:49 +08:00
.flow {
2026-03-18 16:43:04 +08:00
display: grid;
2026-03-19 13:53:49 +08:00
grid-template-columns: repeat(6, minmax(0, 1fr));
gap: 12px;
margin-top: 14px;
}
.step, .lab, .note, .code-card {
border: 1px solid var(--line);
border-radius: 20px;
padding: 16px;
background: rgba(255,255,255,0.45);
}
.step strong, .lab strong, .code-card strong { display: block; margin-bottom: 8px; }
.lab small, .step small, .note small { color: var(--muted); display: block; line-height: 1.7; }
.field {
display: flex;
flex-direction: column;
gap: 8px;
2026-03-18 16:43:04 +08:00
margin-top: 12px;
}
2026-03-19 13:53:49 +08:00
label { font-size: 13px; font-weight: 700; color: #21384f; }
input, select {
width: 100%;
border: 1px solid var(--line);
border-radius: 14px;
padding: 12px 14px;
background: transparent;
2026-03-18 16:43:04 +08:00
color: var(--text);
2026-03-19 13:53:49 +08:00
outline: none;
}
.console {
margin-top: 14px;
border-radius: 18px;
overflow: hidden;
border: 1px solid #d6e2ef;
background: #0e1723;
}
.console-head {
padding: 12px 14px;
border-bottom: 1px solid rgba(216, 228, 240, 0.14);
color: #bdd2ea;
font-weight: 700;
}
pre {
margin: 0;
min-height: 240px;
padding: 16px;
color: #dceaff;
white-space: pre-wrap;
font-family: Consolas, "Courier New", monospace;
overflow: auto;
}
.pill {
display: inline-flex;
padding: 6px 10px;
border-radius: 999px;
background: rgba(15, 103, 181, 0.08);
color: var(--accent);
font-size: 12px;
font-weight: 700;
}
.list {
display: flex;
flex-direction: column;
gap: 10px;
margin-top: 14px;
}
.list-item {
padding: 14px;
border-radius: 18px;
2026-03-18 16:43:04 +08:00
border: 1px solid var(--line);
2026-03-19 13:53:49 +08:00
background: rgba(255,255,255,0.45);
}
.list-item p { margin-top: 8px; }
@media (max-width: 1180px) {
.hero-grid, .workspace, .triple, .flow, .stats { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 780px) {
.page { padding: 14px; }
.hero-grid, .workspace, .triple, .flow, .stats { grid-template-columns: 1fr; }
2026-03-18 16:43:04 +08:00
}
</style>
</head>
<body>
2026-03-18 16:43:04 +08:00
<div class="page">
<section class="hero">
2026-03-19 13:53:49 +08:00
<div class="hero-grid">
<div>
<div class="eyebrow">Spring Boot Learning Cockpit</div>
<h1>Use one workspace to understand MVC, validation, security, AOP, and application events.</h1>
<p>
This homepage is now a guided study cockpit. Instead of only linking to pages, it explains the request
path, suggests experiment sequences, and lets you call real endpoints to observe how the demo behaves.
</p>
<div class="actions" style="margin-top:18px;">
<a class="btn" href="/users.html">Open user lab</a>
<a class="btn-soft" href="/aop.html">Open AOP lab</a>
<a class="btn-soft" href="/events.html">Open event lab</a>
<a class="btn-soft" href="/learn">Open MVC learn API</a>
</div>
<div class="stats">
<div class="stat"><span>Core labs</span><strong>4</strong></div>
<div class="stat"><span>Major layers</span><strong>6</strong></div>
<div class="stat"><span>Interactive pages</span><strong>4</strong></div>
<div class="stat"><span>Tested backend paths</span><strong>2+</strong></div>
</div>
</div>
<div class="card" style="padding:0;">
<div class="card" style="box-shadow:none; border:none; border-radius:28px;">
<div class="eyebrow">Start Here</div>
<h2>Recommended study order</h2>
<div class="list">
<div class="list-item">
<strong>1. Learn endpoint binding</strong>
<p>Hit the live API explorer below and compare query, path, header, cookie, and JSON body patterns.</p>
</div>
<div class="list-item">
<strong>2. Study users and validation</strong>
<p>Open the user lab to inspect CRUD, duplicate email handling, and aggregate stats.</p>
</div>
<div class="list-item">
<strong>3. Watch cross-cutting behavior</strong>
<p>Move to AOP and events to see timing, rate limiting, and listener history.</p>
</div>
</div>
</div>
</div>
</div>
2026-03-18 16:43:04 +08:00
</section>
2026-03-19 13:53:49 +08:00
<section class="card" style="margin-bottom:18px;">
<div class="eyebrow">Architecture</div>
<h2>How one request travels through the demo</h2>
<div class="flow">
<div class="step"><strong>Browser</strong><small>Form submit or fetch call starts the request.</small></div>
<div class="step"><strong>Security</strong><small>JWT demo routes decide whether the request is public or protected.</small></div>
<div class="step"><strong>Controller</strong><small>Spring binds params, body, headers, and cookies into method arguments.</small></div>
<div class="step"><strong>Service</strong><small>Business rules run, such as duplicate email checks or stats calculation.</small></div>
<div class="step"><strong>AOP / Events</strong><small>Cross-cutting timing or event listeners react without cluttering core logic.</small></div>
<div class="step"><strong>Response</strong><small>Structured JSON or HTML returns to the page and becomes visible feedback.</small></div>
</div>
2026-03-18 16:43:04 +08:00
</section>
2026-03-19 13:53:49 +08:00
<div class="workspace">
<aside class="card">
<div class="eyebrow">Lab Tracks</div>
<h2>What to practice in each area</h2>
<div class="list">
<div class="lab">
<strong>User management</strong>
<small>Create a user, trigger duplicate email protection, search records, and compare stats before and after changes.</small>
</div>
<div class="lab">
<strong>MVC parameter binding</strong>
<small>Use `/learn` routes to compare `@RequestParam`, `@PathVariable`, `@RequestBody`, `@RequestHeader`, and `@CookieValue`.</small>
</div>
<div class="lab">
<strong>AOP tracing</strong>
<small>Trigger `/api/users` and `/api/users/stats`, then inspect `/aop/aop/stats` to see which methods were counted.</small>
</div>
<div class="lab">
<strong>Application events</strong>
<small>Publish LOGIN or CREATED events and refresh event history to understand publisher-listener decoupling.</small>
</div>
</div>
<div class="eyebrow" style="margin-top:20px;">Code Reading Map</div>
<h2>Files worth reading next</h2>
<div class="list">
<div class="code-card">
<strong>UserController -> UserService</strong>
<small>Shows validation, CRUD orchestration, search, and stats aggregation.</small>
</div>
<div class="code-card">
<strong>LearningSecurityConfig + LearningJwtFilter</strong>
<small>Explains why most labs stay public while `/api/secure/**` stays protected.</small>
</div>
<div class="code-card">
<strong>PerformanceAspect + UserEventPublisher + UserEventListener</strong>
<small>Shows the two cleanest examples of cross-cutting and event-driven behavior.</small>
</div>
</div>
</aside>
<main class="triple">
<section class="card" style="grid-column: 1 / -1;">
<div class="eyebrow">Live Explorer</div>
<h2>Call real endpoints without leaving the page</h2>
<p>Use these controls to inspect real JSON responses while you read the code. This makes the project easier to connect to concrete behavior.</p>
<div class="toolbar" style="margin-top:14px;">
<button class="btn" type="button" onclick="loadEndpoint('/actuator/health')">Health</button>
<button class="btn-soft" type="button" onclick="loadEndpoint('/api/users/stats')">User stats</button>
<button class="btn-soft" type="button" onclick="loadEndpoint('/learn')">Learn overview</button>
<button class="btn-soft" type="button" onclick="loadEndpoint('/aop/aop/stats')">AOP stats</button>
<button class="btn-soft" type="button" onclick="loadEndpoint('/aop/event/history')">Event history</button>
</div>
<div class="triple" style="margin-top:16px;">
<div class="card" style="padding:0; box-shadow:none; background:transparent; border:none;">
<div class="field">
<label for="eventType">Publish demo event</label>
<select id="eventType">
<option value="LOGIN">LOGIN</option>
<option value="CREATED">CREATED</option>
<option value="UPDATED">UPDATED</option>
<option value="DELETED">DELETED</option>
</select>
</div>
</div>
<div class="card" style="padding:0; box-shadow:none; background:transparent; border:none;">
<div class="field">
<label for="eventUserId">User id</label>
<input id="eventUserId" value="99">
</div>
</div>
<div class="card" style="padding:0; box-shadow:none; background:transparent; border:none;">
<div class="field">
<label for="eventUserName">User name</label>
<input id="eventUserName" value="learning-user">
</div>
</div>
</div>
<div class="toolbar" style="margin-top:14px;">
<button class="btn" type="button" onclick="publishEvent()">Publish event</button>
<button class="btn-soft" type="button" onclick="loadEndpoint('/api/users')">Load users</button>
</div>
<div class="console">
<div class="console-head">Endpoint output</div>
<pre id="consoleOutput">Select an experiment above to load live output.</pre>
</div>
</section>
<section class="card">
<div class="eyebrow">Experiment 1</div>
<h2>Trace validation</h2>
<p>Open the user lab, create a user, then repeat with the same email. Compare the frontend error with `DuplicateEmailException` and the global exception handler.</p>
<div class="chip-list" style="margin-top:12px;">
<span class="pill">UserController</span>
<span class="pill">UserService</span>
<span class="pill">GlobalExceptionHandler</span>
</div>
</section>
<section class="card">
<div class="eyebrow">Experiment 2</div>
<h2>Trace AOP timing</h2>
<p>Load users and stats several times, then call `/aop/aop/stats`. Watch how controller and service methods accumulate timing and call count data.</p>
<div class="chip-list" style="margin-top:12px;">
<span class="pill">PerformanceAspect</span>
<span class="pill">@Around</span>
<span class="pill">Cross-cutting</span>
</div>
</section>
<section class="card">
<div class="eyebrow">Experiment 3</div>
<h2>Trace event decoupling</h2>
<p>Publish CREATED and LOGIN events, then reload event history. This shows how the request can finish while listeners keep handling side effects.</p>
<div class="chip-list" style="margin-top:12px;">
<span class="pill">Publisher</span>
<span class="pill">Listener</span>
<span class="pill">@Async</span>
</div>
</section>
</main>
</div>
2026-03-18 16:43:04 +08:00
</div>
2026-03-19 13:53:49 +08:00
<script>
async function loadEndpoint(path, options = {}) {
const output = document.getElementById('consoleOutput');
output.textContent = 'Loading ' + path + ' ...';
try {
const response = await fetch(path, options);
const contentType = response.headers.get('content-type') || '';
if (contentType.includes('application/json')) {
const json = await response.json();
output.textContent = JSON.stringify(json, null, 2);
} else {
output.textContent = await response.text();
}
} catch (error) {
output.textContent = 'Request failed: ' + error.message;
}
}
async function publishEvent() {
const type = document.getElementById('eventType').value;
const userId = document.getElementById('eventUserId').value.trim() || '99';
const userName = document.getElementById('eventUserName').value.trim() || 'learning-user';
const params = new URLSearchParams({
userId,
userName,
eventType: type
});
await loadEndpoint('/aop/event/publish?' + params.toString(), { method: 'POST' });
}
</script>
</body>
2026-03-18 16:43:04 +08:00
</html>