feat: finish bilingual learning auth cockpit
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
@@ -192,41 +192,39 @@
|
||||
<section class="hero">
|
||||
<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="eyebrow" data-i18n="heroBadge"></div>
|
||||
<h1 data-i18n="heroTitle"></h1>
|
||||
<p data-i18n="heroText"></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>
|
||||
<a class="btn-soft" href="/access.html" data-i18n="loginLabLink"></a>
|
||||
<a class="btn" href="/users.html" data-i18n="userLabLink"></a>
|
||||
<a class="btn-soft" href="/aop.html" data-i18n="aopLabLink"></a>
|
||||
<a class="btn-soft" href="/events.html" data-i18n="eventLabLink"></a>
|
||||
<a class="btn-soft" href="/learn" data-i18n="learnApiLink"></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 class="stat"><span data-i18n="statLabs"></span><strong>5</strong></div>
|
||||
<div class="stat"><span data-i18n="statLayers"></span><strong>6</strong></div>
|
||||
<div class="stat"><span data-i18n="statPages"></span><strong>4</strong></div>
|
||||
<div class="stat"><span data-i18n="statPaths"></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="eyebrow" data-i18n="startBadge"></div>
|
||||
<h2 data-i18n="startTitle"></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>
|
||||
<strong data-i18n="startStep1Title"></strong>
|
||||
<p data-i18n="startStep1Text"></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>
|
||||
<strong data-i18n="startStep2Title"></strong>
|
||||
<p data-i18n="startStep2Text"></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>
|
||||
<strong data-i18n="startStep3Title"></strong>
|
||||
<p data-i18n="startStep3Text"></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -235,77 +233,88 @@
|
||||
</section>
|
||||
|
||||
<section class="card" style="margin-bottom:18px;">
|
||||
<div class="eyebrow">Architecture</div>
|
||||
<h2>How one request travels through the demo</h2>
|
||||
<div class="eyebrow" data-i18n="archBadge"></div>
|
||||
<h2 data-i18n="archTitle"></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 class="step"><strong data-i18n="flow1Title"></strong><small data-i18n="flow1Text"></small></div>
|
||||
<div class="step"><strong data-i18n="flow2Title"></strong><small data-i18n="flow2Text"></small></div>
|
||||
<div class="step"><strong data-i18n="flow3Title"></strong><small data-i18n="flow3Text"></small></div>
|
||||
<div class="step"><strong data-i18n="flow4Title"></strong><small data-i18n="flow4Text"></small></div>
|
||||
<div class="step"><strong data-i18n="flow5Title"></strong><small data-i18n="flow5Text"></small></div>
|
||||
<div class="step"><strong data-i18n="flow6Title"></strong><small data-i18n="flow6Text"></small></div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="workspace">
|
||||
<aside class="card">
|
||||
<div class="eyebrow">Lab Tracks</div>
|
||||
<h2>What to practice in each area</h2>
|
||||
<div class="eyebrow" data-i18n="tracksBadge"></div>
|
||||
<h2 data-i18n="tracksTitle"></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>
|
||||
<strong data-i18n="track1Title"></strong>
|
||||
<small data-i18n="track1Text"></small>
|
||||
</div>
|
||||
<div class="lab">
|
||||
<strong>MVC parameter binding</strong>
|
||||
<small>Use `/learn` routes to compare `@RequestParam`, `@PathVariable`, `@RequestBody`, `@RequestHeader`, and `@CookieValue`.</small>
|
||||
<strong data-i18n="track2Title"></strong>
|
||||
<small data-i18n="track2Text"></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>
|
||||
<strong data-i18n="track3Title"></strong>
|
||||
<small data-i18n="track3Text"></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>
|
||||
<strong data-i18n="track4Title"></strong>
|
||||
<small data-i18n="track4Text"></small>
|
||||
</div>
|
||||
<div class="lab">
|
||||
<strong data-i18n="track5Title"></strong>
|
||||
<small data-i18n="track5Text"></small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="eyebrow" style="margin-top:20px;">Code Reading Map</div>
|
||||
<h2>Files worth reading next</h2>
|
||||
<div class="eyebrow" style="margin-top:20px;" data-i18n="readingBadge"></div>
|
||||
<h2 data-i18n="readingTitle"></h2>
|
||||
<div class="list">
|
||||
<div class="code-card">
|
||||
<strong>UserController -> UserService</strong>
|
||||
<small>Shows validation, CRUD orchestration, search, and stats aggregation.</small>
|
||||
<strong data-i18n="reading1Title"></strong>
|
||||
<small data-i18n="reading1Text"></small>
|
||||
</div>
|
||||
<div class="code-card">
|
||||
<strong>LearningSecurityConfig + LearningJwtFilter</strong>
|
||||
<small>Explains why most labs stay public while `/api/secure/**` stays protected.</small>
|
||||
<strong data-i18n="reading2Title"></strong>
|
||||
<small data-i18n="reading2Text"></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>
|
||||
<strong data-i18n="reading3Title"></strong>
|
||||
<small data-i18n="reading3Text"></small>
|
||||
</div>
|
||||
<div class="code-card">
|
||||
<strong data-i18n="reading4Title"></strong>
|
||||
<small data-i18n="reading4Text"></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="eyebrow" data-i18n="explorerBadge"></div>
|
||||
<h2 data-i18n="explorerTitle"></h2>
|
||||
<p data-i18n="explorerText"></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>
|
||||
<button class="btn" type="button" onclick="loadEndpoint('/actuator/health')" data-i18n="healthButton"></button>
|
||||
<button class="btn-soft" type="button" onclick="loadEndpoint('/api/users/stats')" data-i18n="userStatsButton"></button>
|
||||
<button class="btn-soft" type="button" onclick="loadEndpoint('/learn')" data-i18n="learnButton"></button>
|
||||
<button class="btn-soft" type="button" onclick="loadEndpoint('/aop/aop/stats')" data-i18n="aopStatsButton"></button>
|
||||
<button class="btn-soft" type="button" onclick="loadEndpoint('/aop/event/history')" data-i18n="eventHistoryButton"></button>
|
||||
<button class="btn-soft" type="button" onclick="loadEndpoint('/api/lab/reflection/routes')" data-i18n="reflectionButton"></button>
|
||||
<button class="btn-soft" type="button" onclick="loadEndpoint('/api/lab/concurrency/simulate?tasks=8&poolSize=4')" data-i18n="concurrencyButton"></button>
|
||||
</div>
|
||||
<p style="margin-top:12px;" data-i18n="protectedHint"></p>
|
||||
|
||||
<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>
|
||||
<label for="eventType" data-i18n="eventTypeLabel"></label>
|
||||
<select id="eventType">
|
||||
<option value="LOGIN">LOGIN</option>
|
||||
<option value="CREATED">CREATED</option>
|
||||
@@ -316,32 +325,32 @@
|
||||
</div>
|
||||
<div class="card" style="padding:0; box-shadow:none; background:transparent; border:none;">
|
||||
<div class="field">
|
||||
<label for="eventUserId">User id</label>
|
||||
<label for="eventUserId" data-i18n="eventUserIdLabel"></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>
|
||||
<label for="eventUserName" data-i18n="eventUserNameLabel"></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>
|
||||
<button class="btn" type="button" onclick="publishEvent()" data-i18n="publishButton"></button>
|
||||
<button class="btn-soft" type="button" onclick="loadEndpoint('/api/users')" data-i18n="loadUsersButton"></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 class="console-head" data-i18n="consoleTitle"></div>
|
||||
<pre id="consoleOutput"></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="eyebrow" data-i18n="exp1Badge"></div>
|
||||
<h2 data-i18n="exp1Title"></h2>
|
||||
<p data-i18n="exp1Text"></p>
|
||||
<div class="chip-list" style="margin-top:12px;">
|
||||
<span class="pill">UserController</span>
|
||||
<span class="pill">UserService</span>
|
||||
@@ -350,9 +359,9 @@
|
||||
</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="eyebrow" data-i18n="exp2Badge"></div>
|
||||
<h2 data-i18n="exp2Title"></h2>
|
||||
<p data-i18n="exp2Text"></p>
|
||||
<div class="chip-list" style="margin-top:12px;">
|
||||
<span class="pill">PerformanceAspect</span>
|
||||
<span class="pill">@Around</span>
|
||||
@@ -361,9 +370,9 @@
|
||||
</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="eyebrow" data-i18n="exp3Badge"></div>
|
||||
<h2 data-i18n="exp3Title"></h2>
|
||||
<p data-i18n="exp3Text"></p>
|
||||
<div class="chip-list" style="margin-top:12px;">
|
||||
<span class="pill">Publisher</span>
|
||||
<span class="pill">Listener</span>
|
||||
@@ -374,35 +383,263 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/learning-shell.js"></script>
|
||||
<script>
|
||||
async function loadEndpoint(path, options = {}) {
|
||||
const output = document.getElementById('consoleOutput');
|
||||
output.textContent = 'Loading ' + path + ' ...';
|
||||
const I18N = {
|
||||
zh: {
|
||||
title: "Spring Boot 学习总控台",
|
||||
heroBadge: "Spring Boot 学习总控台",
|
||||
heroTitle: "用一个工作台串起 MVC、校验、安全、AOP 和应用事件。",
|
||||
heroText: "首页现在不只是导航页,而是一个带实验顺序、请求路径说明和实时接口调用能力的学习驾驶舱,帮助你把代码结构和真实行为对应起来。",
|
||||
loginLabLink: "打开登录实验",
|
||||
userLabLink: "打开用户实验",
|
||||
aopLabLink: "打开 AOP 实验",
|
||||
eventLabLink: "打开事件实验",
|
||||
learnApiLink: "打开 MVC Learn API",
|
||||
statLabs: "核心实验",
|
||||
statLayers: "关键层次",
|
||||
statPages: "交互页面",
|
||||
statPaths: "已验证后端路径",
|
||||
startBadge: "从这里开始",
|
||||
startTitle: "推荐学习顺序",
|
||||
startStep1Title: "1. 先看参数绑定",
|
||||
startStep1Text: "先用下面的实时接口区观察 query、path、header、cookie 和 JSON body 的绑定方式,再对照控制器代码。",
|
||||
startStep2Title: "2. 再学用户和校验",
|
||||
startStep2Text: "进入用户实验页,验证 CRUD、重复邮箱保护、聚合统计和错误回传。",
|
||||
startStep3Title: "3. 最后看横切与事件",
|
||||
startStep3Text: "切到 AOP 与事件页,理解计时、限流、发布订阅和监听器历史。",
|
||||
archBadge: "架构路径",
|
||||
archTitle: "一个请求如何穿过整个 Demo",
|
||||
flow1Title: "浏览器",
|
||||
flow1Text: "表单提交或 fetch 调用发起请求。",
|
||||
flow2Title: "安全层",
|
||||
flow2Text: "JWT 学习路由判断请求是公开还是受保护。",
|
||||
flow3Title: "控制器",
|
||||
flow3Text: "Spring 把参数、请求体、请求头和 Cookie 绑定到方法参数。",
|
||||
flow4Title: "服务层",
|
||||
flow4Text: "这里运行重复邮箱校验、统计计算等业务规则。",
|
||||
flow5Title: "AOP / 事件",
|
||||
flow5Text: "横切逻辑和监听器在不污染主流程的前提下响应请求。",
|
||||
flow6Title: "响应",
|
||||
flow6Text: "最终以结构化 JSON 或 HTML 的形式回到页面。",
|
||||
tracksBadge: "实验赛道",
|
||||
tracksTitle: "每个区域该练什么",
|
||||
track1Title: "用户管理",
|
||||
track1Text: "创建用户、触发重复邮箱保护、搜索记录,并比较变更前后的统计数据。",
|
||||
track2Title: "MVC 参数绑定",
|
||||
track2Text: "使用 /learn 路由对比 @RequestParam、@PathVariable、@RequestBody、@RequestHeader 和 @CookieValue。",
|
||||
track3Title: "AOP 追踪",
|
||||
track3Text: "触发 /api/users 与 /api/users/stats,再查看 /aop/aop/stats 里哪些方法被统计了。",
|
||||
track4Title: "应用事件",
|
||||
track4Text: "发布 LOGIN 或 CREATED 事件后刷新历史,理解发布者与监听器的解耦。",
|
||||
track5Title: "高级实验",
|
||||
track5Text: "直接调用 /api/lab 下的反射、并发和 JWT claims 实验接口,把高级知识点和当前 Demo 串起来。",
|
||||
readingBadge: "代码阅读地图",
|
||||
readingTitle: "接下来值得重点看的文件",
|
||||
reading1Title: "UserController -> UserService",
|
||||
reading1Text: "展示校验、CRUD 编排、搜索以及统计聚合。",
|
||||
reading2Title: "LearningSecurityConfig + LearningJwtFilter",
|
||||
reading2Text: "解释为什么大部分实验页保持公开,而 /api/secure/** 仍然受保护。",
|
||||
reading3Title: "PerformanceAspect + UserEventPublisher + UserEventListener",
|
||||
reading3Text: "这是横切逻辑与事件驱动最直观的两组示例。",
|
||||
reading4Title: "AdvancedLabController + LearningJwtUtil",
|
||||
reading4Text: "用反射、并发和 JWT claims 解析,把高级 Java 和安全实验纳入同一个学习工作台。",
|
||||
explorerBadge: "实时接口区",
|
||||
explorerTitle: "不离开页面,直接调用真实接口",
|
||||
explorerText: "一边读代码,一边在这里看真实返回结果,会更容易把项目结构和运行行为建立联系。",
|
||||
healthButton: "健康检查",
|
||||
userStatsButton: "用户统计",
|
||||
learnButton: "Learn 总览",
|
||||
aopStatsButton: "AOP 统计",
|
||||
eventHistoryButton: "事件历史",
|
||||
reflectionButton: "反射路由图",
|
||||
concurrencyButton: "并发实验",
|
||||
protectedHint: "受保护接口已经接入前端令牌持久化。如果你还没登录,请先进入登录实验页。",
|
||||
eventTypeLabel: "发布演示事件",
|
||||
eventUserIdLabel: "用户 ID",
|
||||
eventUserNameLabel: "用户名",
|
||||
publishButton: "发布事件",
|
||||
loadUsersButton: "加载用户",
|
||||
consoleTitle: "接口输出",
|
||||
consolePlaceholder: "请选择上方一个实验动作来加载实时输出。",
|
||||
loadingPrefix: "正在加载 ",
|
||||
requestFailedPrefix: "请求失败:",
|
||||
exp1Badge: "实验 1",
|
||||
exp1Title: "追踪校验链路",
|
||||
exp1Text: "打开用户实验,先创建一个用户,再用同样邮箱重复创建。对比前端错误提示、DuplicateEmailException 和全局异常处理器。",
|
||||
exp2Badge: "实验 2",
|
||||
exp2Title: "追踪 AOP 计时",
|
||||
exp2Text: "多次加载用户列表和统计,再调用 /aop/aop/stats,观察控制器与服务方法如何累计耗时与调用次数。",
|
||||
exp3Badge: "实验 3",
|
||||
exp3Title: "追踪事件解耦",
|
||||
exp3Text: "连续发布 CREATED 和 LOGIN 事件,再刷新历史,体会请求结束后监听器仍在处理副作用。"
|
||||
},
|
||||
en: {
|
||||
title: "Spring Boot Learning Cockpit",
|
||||
heroBadge: "Spring Boot Learning Cockpit",
|
||||
heroTitle: "Use one workspace to understand MVC, validation, security, AOP, and application events.",
|
||||
heroText: "This homepage is now a guided study cockpit. Instead of only linking to pages, it explains request paths, suggests experiment sequences, and lets you call real endpoints to observe behavior.",
|
||||
loginLabLink: "Open login lab",
|
||||
userLabLink: "Open user lab",
|
||||
aopLabLink: "Open AOP lab",
|
||||
eventLabLink: "Open event lab",
|
||||
learnApiLink: "Open MVC Learn API",
|
||||
statLabs: "Core labs",
|
||||
statLayers: "Major layers",
|
||||
statPages: "Interactive pages",
|
||||
statPaths: "Tested backend paths",
|
||||
startBadge: "Start Here",
|
||||
startTitle: "Recommended study order",
|
||||
startStep1Title: "1. Learn endpoint binding",
|
||||
startStep1Text: "Use the live explorer below and compare query, path, header, cookie, and JSON body patterns before reading controller code.",
|
||||
startStep2Title: "2. Study users and validation",
|
||||
startStep2Text: "Open the user lab to inspect CRUD, duplicate email handling, aggregate stats, and error responses.",
|
||||
startStep3Title: "3. Watch cross-cutting behavior",
|
||||
startStep3Text: "Move to AOP and events to understand timing, rate limiting, publishing, and listener history.",
|
||||
archBadge: "Architecture",
|
||||
archTitle: "How one request travels through the demo",
|
||||
flow1Title: "Browser",
|
||||
flow1Text: "A form submit or fetch call starts the request.",
|
||||
flow2Title: "Security",
|
||||
flow2Text: "JWT learning routes decide whether the request is public or protected.",
|
||||
flow3Title: "Controller",
|
||||
flow3Text: "Spring binds params, body, headers, and cookies into method arguments.",
|
||||
flow4Title: "Service",
|
||||
flow4Text: "Business rules run here, such as duplicate email checks and stats calculation.",
|
||||
flow5Title: "AOP / Events",
|
||||
flow5Text: "Cross-cutting logic and listeners react without cluttering the core flow.",
|
||||
flow6Title: "Response",
|
||||
flow6Text: "The result returns to the page as structured JSON or HTML feedback.",
|
||||
tracksBadge: "Lab Tracks",
|
||||
tracksTitle: "What to practice in each area",
|
||||
track1Title: "User management",
|
||||
track1Text: "Create a user, trigger duplicate email protection, search records, and compare stats before and after changes.",
|
||||
track2Title: "MVC parameter binding",
|
||||
track2Text: "Use /learn routes to compare @RequestParam, @PathVariable, @RequestBody, @RequestHeader, and @CookieValue.",
|
||||
track3Title: "AOP tracing",
|
||||
track3Text: "Trigger /api/users and /api/users/stats, then inspect /aop/aop/stats to see which methods were counted.",
|
||||
track4Title: "Application events",
|
||||
track4Text: "Publish LOGIN or CREATED events and refresh history to understand publisher-listener decoupling.",
|
||||
track5Title: "Advanced labs",
|
||||
track5Text: "Call the reflection, concurrency, and JWT claims labs under /api/lab to connect advanced topics back to this demo.",
|
||||
readingBadge: "Code Reading Map",
|
||||
readingTitle: "Files worth reading next",
|
||||
reading1Title: "UserController -> UserService",
|
||||
reading1Text: "Shows validation, CRUD orchestration, search, and stats aggregation.",
|
||||
reading2Title: "LearningSecurityConfig + LearningJwtFilter",
|
||||
reading2Text: "Explains why most labs stay public while /api/secure/** remains protected.",
|
||||
reading3Title: "PerformanceAspect + UserEventPublisher + UserEventListener",
|
||||
reading3Text: "These are the clearest examples of cross-cutting and event-driven behavior.",
|
||||
reading4Title: "AdvancedLabController + LearningJwtUtil",
|
||||
reading4Text: "Use reflection, concurrency, and JWT claim parsing to fold advanced Java and security experiments into the same workspace.",
|
||||
explorerBadge: "Live Explorer",
|
||||
explorerTitle: "Call real endpoints without leaving the page",
|
||||
explorerText: "Inspect real responses while you read the code so the project is easier to connect to concrete runtime behavior.",
|
||||
healthButton: "Health",
|
||||
userStatsButton: "User stats",
|
||||
learnButton: "Learn overview",
|
||||
aopStatsButton: "AOP stats",
|
||||
eventHistoryButton: "Event history",
|
||||
reflectionButton: "Reflection routes",
|
||||
concurrencyButton: "Concurrency lab",
|
||||
protectedHint: "Protected endpoints now support frontend token persistence. If you are not logged in yet, open the login lab first.",
|
||||
eventTypeLabel: "Publish demo event",
|
||||
eventUserIdLabel: "User id",
|
||||
eventUserNameLabel: "User name",
|
||||
publishButton: "Publish event",
|
||||
loadUsersButton: "Load users",
|
||||
consoleTitle: "Endpoint output",
|
||||
consolePlaceholder: "Select one experiment above to load live output.",
|
||||
loadingPrefix: "Loading ",
|
||||
requestFailedPrefix: "Request failed: ",
|
||||
exp1Badge: "Experiment 1",
|
||||
exp1Title: "Trace validation",
|
||||
exp1Text: "Open the user lab, create a user, then repeat with the same email. Compare the frontend error with DuplicateEmailException and the global exception handler.",
|
||||
exp2Badge: "Experiment 2",
|
||||
exp2Title: "Trace AOP timing",
|
||||
exp2Text: "Load users and stats several times, then call /aop/aop/stats. Watch how controller and service methods accumulate timing and call count data.",
|
||||
exp3Badge: "Experiment 3",
|
||||
exp3Title: "Trace event decoupling",
|
||||
exp3Text: "Publish CREATED and LOGIN events, then reload event history to see how listeners keep handling follow-up work."
|
||||
}
|
||||
};
|
||||
|
||||
function pageText() {
|
||||
return I18N[window.learningShell.getLanguage()] || I18N.zh;
|
||||
}
|
||||
|
||||
function applyTranslations(text) {
|
||||
document.title = text.title;
|
||||
document.querySelectorAll("[data-i18n]").forEach(function (element) {
|
||||
const key = element.getAttribute("data-i18n");
|
||||
if (Object.prototype.hasOwnProperty.call(text, key)) {
|
||||
element.textContent = text[key];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function renderLanguage() {
|
||||
const text = pageText();
|
||||
applyTranslations(text);
|
||||
|
||||
const output = document.getElementById("consoleOutput");
|
||||
if (!output.dataset.state || output.dataset.state === "idle") {
|
||||
output.textContent = text.consolePlaceholder;
|
||||
output.dataset.state = "idle";
|
||||
}
|
||||
}
|
||||
|
||||
async function loadEndpoint(path, options) {
|
||||
const output = document.getElementById("consoleOutput");
|
||||
const text = pageText();
|
||||
output.textContent = text.loadingPrefix + path + " ...";
|
||||
output.dataset.state = "loading";
|
||||
|
||||
try {
|
||||
const response = await fetch(path, options);
|
||||
const contentType = response.headers.get('content-type') || '';
|
||||
if (contentType.includes('application/json')) {
|
||||
const response = await window.learningShell.fetchWithAuth(path, options || {});
|
||||
const contentType = response.headers.get("content-type") || "";
|
||||
|
||||
if (!response.ok) {
|
||||
const failedContent = contentType.includes("application/json")
|
||||
? await response.json()
|
||||
: await response.text();
|
||||
|
||||
throw {
|
||||
status: response.status,
|
||||
message: typeof failedContent === "object" && failedContent && failedContent.message
|
||||
? failedContent.message
|
||||
: window.learningShell.describeError({ status: response.status }),
|
||||
payload: failedContent
|
||||
};
|
||||
}
|
||||
|
||||
if (contentType.includes("application/json")) {
|
||||
const json = await response.json();
|
||||
output.textContent = JSON.stringify(json, null, 2);
|
||||
} else {
|
||||
output.textContent = await response.text();
|
||||
}
|
||||
output.dataset.state = "live";
|
||||
} catch (error) {
|
||||
output.textContent = 'Request failed: ' + error.message;
|
||||
output.textContent = text.requestFailedPrefix + window.learningShell.describeError(error);
|
||||
output.dataset.state = "live";
|
||||
}
|
||||
}
|
||||
|
||||
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 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,
|
||||
userId: userId,
|
||||
userName: userName,
|
||||
eventType: type
|
||||
});
|
||||
await loadEndpoint('/aop/event/publish?' + params.toString(), { method: 'POST' });
|
||||
await loadEndpoint("/aop/event/publish?" + params.toString(), { method: "POST" });
|
||||
}
|
||||
|
||||
window.learningShell.mountShell({ onLanguageChange: renderLanguage });
|
||||
renderLanguage();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user