Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
1309 commits
Select commit Hold shift + click to select a range
74a4a98
@Cacheable
itwanger Nov 5, 2024
d2de8ec
feat: 调整内容截取
liuyueyi Nov 5, 2024
34b8d80
fix: 解决重名问题
liuyueyi Nov 5, 2024
e8b7a54
Create Solution05101.java
itwanger Nov 8, 2024
d67c4a4
N皇后
itwanger Nov 8, 2024
18c8bc5
ul ➡️ li a 标签
itwanger Nov 16, 2024
c01742d
Create PathsDemo.java
itwanger Nov 17, 2024
37d35c9
LeetCode 的 54 题
itwanger Nov 20, 2024
0364ae7
feat: 调整邮件通知模板样式
liuyueyi Nov 25, 2024
021f643
feat: 付费阅读标记
liuyueyi Nov 26, 2024
ef60d70
LeetCode 题解
itwanger Nov 27, 2024
809af51
feat: 完成消息通知的长连接
liuyueyi Nov 27, 2024
e3543bc
feat: 添加全局广播消息通知
liuyueyi Nov 27, 2024
14d9857
Merge pull request #87 from itwanger/241127/ws_notice
liuyueyi Nov 27, 2024
c855a16
fix: ws依赖
liuyueyi Nov 27, 2024
def17d8
fix #82 修复关注/取消的活跃度通知问题
liuyueyi Nov 27, 2024
486a52c
feat: #68 点赞计数异常问题处理 & 修复评论点赞的通知显示问题
liuyueyi Nov 27, 2024
ecb2247
feat: #76 update groovy version to 3.0.23
liuyueyi Nov 28, 2024
08ca10e
feat: 添加用于h5支付审核的中间页
liuyueyi Nov 28, 2024
e1e2bc8
理想汽车面经代码示例
itwanger Nov 28, 2024
a363f03
vue3+spring boot3 版本
itwanger Nov 30, 2024
be5de04
Update README.md
itwanger Dec 3, 2024
6062099
feat: 添加微信支付
liuyueyi Dec 3, 2024
3c5a47e
feat: 添加回调地址
liuyueyi Dec 3, 2024
3f30572
Merge pull request #88 from itwanger/feature/241203/h5_pay
liuyueyi Dec 3, 2024
da8444b
feat: native 支付
liuyueyi Dec 4, 2024
6a08e97
feat: 完成native支付集成
liuyueyi Dec 5, 2024
4aaa12b
Merge pull request #89 from itwanger/feature/241203/h5_pay
liuyueyi Dec 5, 2024
d9839f6
线上配置调整
liuyueyi Dec 5, 2024
d68e86b
fix: 解决测试问题
liuyueyi Dec 5, 2024
97aee35
feat: 优化收款码展示体验
liuyueyi Dec 5, 2024
1fecb6e
feat: 支付相关实现调整
liuyueyi Dec 6, 2024
93b530d
feat: 重构
liuyueyi Dec 6, 2024
1625f49
feat: 策略模式改写微信/个人收款码支付对接
liuyueyi Dec 8, 2024
d80cb09
feat: 抽离支付服务
liuyueyi Dec 9, 2024
48fa277
fix: 调整支付配置注入
liuyueyi Dec 9, 2024
42843c4
feat: 支付相关消息通知优化
liuyueyi Dec 9, 2024
4a44f0f
Merge pull request #91 from itwanger/feature/241206/pay_reconsitution
liuyueyi Dec 9, 2024
9cc0496
feat: 结构调整
liuyueyi Dec 10, 2024
f2d9f1a
Merge pull request #92 from itwanger/feature/241206/pay_reconsitution
liuyueyi Dec 10, 2024
46055fa
Update README.md
itwanger Dec 11, 2024
2a09535
feat: 恢复测试支付的回调通知
liuyueyi Dec 11, 2024
f65f357
增加快级高亮显示。
itwanger Dec 12, 2024
bd4dff3
fix
liuyueyi Dec 13, 2024
b49a1d3
admin 端的部署指引
itwanger Dec 17, 2024
8968626
fastexcel
itwanger Dec 18, 2024
ae4f492
feat: 专栏文章分组
liuyueyi Dec 18, 2024
e1bbc25
Update .gitignore
itwanger Dec 19, 2024
3ae35a4
500万条数据导出到 Excel
itwanger Dec 21, 2024
1235727
fix: 动态配置初始化加载并刷新
liuyueyi Jan 6, 2025
95d8005
fix: 应用启动时初始化@Value配置兼容默认配置值场景
liuyueyi Jan 8, 2025
1afe3d9
增加一些面渣逆袭的 demo
itwanger Jan 26, 2025
de80b6e
合并区间和插入区间
itwanger Feb 1, 2025
1614b95
feat: 大模型接入深度
liuyueyi Feb 6, 2025
dfcf53e
feat: 添加deepseek配置
liuyueyi Feb 6, 2025
f842532
ThreadLocal
itwanger Feb 6, 2025
78cedd1
Update index.html
itwanger Feb 6, 2025
2a6c1fc
feat: 过滤开头返回的空行内容
liuyueyi Feb 6, 2025
dfd0563
feat: 添加一些注释 优化部分实现细节
liuyueyi Feb 6, 2025
2d9eaee
feat: 派聪明支持多轮对话
liuyueyi Feb 7, 2025
4c148d2
feat: 完成前端对话历史展示与切换
liuyueyi Feb 8, 2025
1f79a5e
feat: 完成提示词功能集成
liuyueyi Feb 8, 2025
215b746
feat: 添加提示词示例说明
liuyueyi Feb 8, 2025
3924259
Adds DoubaoTest for AI integration.
betasecond Feb 8, 2025
8dfc3cc
feat:Adds Doubao AI integration and support.
betasecond Feb 8, 2025
eca12a8
feat:Adds Doubao API key configuration to AI settings.
betasecond Feb 8, 2025
6216dee
Removes dev database password and reduces log level.
betasecond Feb 8, 2025
fd9fd2a
Merge pull request #97 from itwanger/feature/250207/multi_chat
liuyueyi Feb 10, 2025
1a3288e
Merge branch 'itwanger:main' into llm-doubao-support
betasecond Feb 10, 2025
9327f2e
Refactors Doubao AI service to handle prompts and user messages.
betasecond Feb 10, 2025
ab0c3fa
feat: Adds handling for end of stream in Doubao AI response
betasecond Feb 10, 2025
83169a8
feat: Updates DoubaoTest to use a test API key and removes decryption…
betasecond Feb 10, 2025
ea8ba0d
feat: Adds apiHost configuration for Doubao integration and updates s…
betasecond Feb 10, 2025
729e18a
fix: 解决ws未成功建立连接,选中会话导致会话历史无法获取的问题
liuyueyi Feb 10, 2025
8869cb6
fix: 修复历史会话同步问题
liuyueyi Feb 10, 2025
cb118be
feat: Simplifies message handling in Doubao AI service by removing re…
betasecond Feb 10, 2025
fa6c1c3
feat: Implements asynchronous handling for chat completion responses …
betasecond Feb 10, 2025
0e7775b
Adds PaiAI and DouBaoAI as fallback AI sources.
betasecond Feb 10, 2025
994f877
Refactors DoubaoTest to use TestSubscriber for stream assertions.
betasecond Feb 10, 2025
5eb7135
feat: Enhances asynchronous error handling in Doubao AI service with …
betasecond Feb 10, 2025
c4ce13f
feat: Adds Doubao configuration and integration for enhanced AI servi…
betasecond Feb 10, 2025
049f0ec
feat: Adds endpoint configuration to DoubaoTest for improved API inte…
betasecond Feb 10, 2025
64b95df
Merge pull request #98 from betasecond/llm-doubao-support
liuyueyi Feb 11, 2025
ec1a2cf
synchronized 关键字的使用 demo
itwanger Feb 11, 2025
0a9659f
上传/转存图像功能缓存文件名变更为缓存文件摘要
EvenTiming Feb 11, 2025
d0800ba
上传/转存图像功能缓存文件名变更为缓存文件摘要
EvenTiming Feb 11, 2025
034fa80
修复InputStream无法使用的问题
EvenTiming Feb 11, 2025
55f9f5b
重新调整一下派聪明 AI 聊天的 CSS
itwanger Feb 12, 2025
16861b4
feat: Introduces ShortLink functionality with controller, service, an…
betasecond Feb 12, 2025
376f554
feat: Adds ShortLink functionality with database schema, request, and…
betasecond Feb 12, 2025
562ee56
feat: Implements ShortLink data access layer with DAO and Mapper classes
betasecond Feb 12, 2025
e979929
feat: Adds ShortLinkDao implementation with CRUD methods
betasecond Feb 12, 2025
a85caf2
feat: Adds ShortLinkDao implementation with CRUD methods
betasecond Feb 12, 2025
bf1de30
feat: Introduces short link functionality with DTOs, database objects…
betasecond Feb 13, 2025
4e36d1d
feat: Implement short link generation and management with database in…
betasecond Feb 13, 2025
2713157
ABA 问题 demo
itwanger Feb 14, 2025
09d05b5
feat: Enhance short link service with Redis caching and improved erro…
betasecond Feb 14, 2025
3f57e81
feat: Refactor short link service to use interface and implement serv…
betasecond Feb 14, 2025
78bdda4
feat: Update short link schema and implement source detection logic
betasecond Feb 14, 2025
0766476
Merge branch 'shortURL-dev' into shortURL-demo
betasecond Feb 14, 2025
719e37c
Merge branch 'itwanger:main' into shortURL
betasecond Feb 14, 2025
ba00195
feat: Update short link schema to use timestamp for create and update…
betasecond Feb 14, 2025
370fb9d
feat: Add documentation comments and improve code formatting in short…
betasecond Feb 14, 2025
bbc055f
feat: Add share icon and functionality to action tool bar in article …
betasecond Feb 14, 2025
989d4b7
feat: Implement article sharing functionality with QR code generation…
betasecond Feb 14, 2025
035b69e
feat: Refactor short link database schema and update related queries
betasecond Feb 14, 2025
85c2163
Merge pull request #99 from EvenTiming/main
liuyueyi Feb 17, 2025
f961d2c
feat: Replace HashSet with Guava Cache for short code uniqueness check
betasecond Feb 17, 2025
d6dd5bd
feat: Add short link database schema with unique short code constraint
betasecond Feb 17, 2025
a4744f2
Implements short link generation with domain whitelisting.
betasecond Feb 17, 2025
ff2b868
feat: Update short link whitelist to include localhost and 127.0.0.1
betasecond Feb 17, 2025
106e784
修复mdImgReplace中的异步错误问题
EvenTiming Feb 17, 2025
a00d2bf
feat: Add index on short_code for short link and record tables
betasecond Feb 18, 2025
afb1fd9
feat: Update short link whitelist to support port numbers and improve…
betasecond Feb 18, 2025
8327d6d
Merge pull request #101 from betasecond/shortURL
liuyueyi Feb 18, 2025
1e08a51
修改CompletableFutureBridge初始化时markOver的设置
EvenTiming Feb 18, 2025
e925b1e
feat: 调整短链包结构路径,尽量保证项目的风格统一
liuyueyi Feb 18, 2025
6459138
Merge pull request #103 from EvenTiming/main
liuyueyi Feb 18, 2025
a61b089
并发编程面渣篇的 demo
itwanger Feb 22, 2025
076e891
feat: 添加评论互怼@杠精机器人
liuyueyi Feb 24, 2025
6e8b62a
feat: 添加注释说明
liuyueyi Feb 24, 2025
65bc134
feat: 机器人提问时不进行敏感词校验
liuyueyi Feb 24, 2025
2eea4fd
feat: 调整链接
liuyueyi Mar 18, 2025
18ebe13
fix:修复FastExcel导出Excel不是技术派.xlsx的问题
hleidev Mar 23, 2025
cee990a
Update RabbitmqServiceImpl.java
Yuan-9 Mar 23, 2025
b10da97
Merge pull request #109 from harryleiyyds/harrylei
liuyueyi Mar 23, 2025
02279e8
算法笔记的源码保存
itwanger Mar 24, 2025
e2ec8f2
fix:修复了一个错误
hleidev Mar 25, 2025
ef9babc
弹球大师
itwanger Mar 26, 2025
2550b95
Merge branch 'main' into harrylei
hleidev Mar 27, 2025
680e93b
fix(wx-callback): 修复扫描带参数二维码时可能触发空指针的问题
hleidev Mar 27, 2025
06d68b1
Merge pull request #111 from hleidev/harrylei
liuyueyi Apr 14, 2025
0931ce0
fix: swagger-ui访问404问题
liuyueyi Apr 17, 2025
35894b0
feat: 集成prometheus
liuyueyi Apr 17, 2025
9a658f4
feat: 调整actuactor访问策略,避免安全问题
liuyueyi Apr 18, 2025
014a40e
推理模型
itwanger Apr 20, 2025
24024ee
Merge branch 'main' of https://github.com/itwanger/paicoding
itwanger Apr 20, 2025
b0ba2ac
Create bytedaceai.svg
itwanger Apr 20, 2025
6a83804
Merge pull request #110 from Yuan-9/main
liuyueyi Jun 9, 2025
4fa67f0
这里写反了,修正一下
itwanger Jun 9, 2025
657a913
Delete ShortLinkMapper.xml
itwanger Jun 11, 2025
7aebec5
Revert "Delete ShortLinkMapper.xml"
itwanger Jun 11, 2025
60364d4
删除ShortLinkMapper.xml文件解决MyBatis映射冲突
itwanger Jun 11, 2025
8b90ccb
Update Convert2OssFromHtml.java
itwanger Jun 11, 2025
566e255
加一些注释
itwanger Jun 24, 2025
f955269
Merge remote-tracking branch 'origin/main' into feature/1217/column_g…
liuyueyi Jul 30, 2025
e3beaf0
Remove unused imports from article controllers
itwanger Jul 30, 2025
9f2fbe1
feat: 专栏支持教程分组
liuyueyi Jul 31, 2025
4eac209
feat: 新增教程拖拽排序接口
liuyueyi Aug 1, 2025
1c33a0f
feat: update version
liuyueyi Aug 1, 2025
1c416f6
Merge pull request #121 from itwanger/feature/1217/column_group
liuyueyi Aug 1, 2025
e716573
fix dbname
liuyueyi Aug 1, 2025
a205614
fix: 修复专栏教程顺序重排
liuyueyi Aug 2, 2025
dc0ee0f
fix: 修复专栏教程顺序重排
liuyueyi Aug 2, 2025
e84c436
feat: 专栏教程新增短链分享
liuyueyi Aug 2, 2025
f205c77
Update configs and UI styles for dev environment
itwanger Aug 16, 2025
1f93ac1
Enhance column detail view with group toggling
itwanger Aug 16, 2025
540c6ef
Refactor and enhance article/column TOC navigation
itwanger Aug 17, 2025
30675fe
目录超出高度时,能够滚动显示
itwanger Aug 18, 2025
63fc173
Update column-detail.css
itwanger Aug 18, 2025
a4f5ca2
Update page title to include article name
itwanger Aug 19, 2025
f7aaa3d
feat: 集成知识星球登录
liuyueyi Aug 19, 2025
cc4fc27
feat: 调整登录有效期
liuyueyi Aug 19, 2025
b0a8fa3
feat: 调整日志打印级别
liuyueyi Aug 19, 2025
77bbdc8
Add ZSXQ login type and support third-party login
itwanger Aug 24, 2025
41202e6
Standardize star number formatting across login flow
itwanger Aug 24, 2025
85f889d
Prefix zsxq usernames and update init data
itwanger Aug 24, 2025
286fc18
Move UserAIStat expired entry to new SQL file
itwanger Aug 24, 2025
75a8231
Update ZsxqLoginController.java
itwanger Sep 11, 2025
22085ad
feat: 支持外部授权登录
liuyueyi Sep 15, 2025
3854340
Refine user AI status and expiration handling
itwanger Sep 19, 2025
3ffe743
Add expireDays config and update AI user expiry logic
itwanger Sep 22, 2025
2e92aeb
Update UserServiceImpl.java
itwanger Sep 22, 2025
2e0167c
feat: 支持校招派的公众号登录转发 & 静默登录
liuyueyi Sep 24, 2025
18e13f7
fix 登录cookie作用域
liuyueyi Sep 24, 2025
2e6fbd1
feat: 修复npe
liuyueyi Sep 24, 2025
6830dee
fix: 调整host获取方式
liuyueyi Sep 24, 2025
ff7206d
feat: 获取真实请求来源
liuyueyi Sep 24, 2025
a231c52
fix: 修复公众号登录问题
liuyueyi Sep 24, 2025
305d1ff
feat: 修复等出时,cookie未删除问题
liuyueyi Sep 25, 2025
4886d30
feat: 统一cookie生成策略
liuyueyi Sep 25, 2025
93ece6b
fix: 解决cookie与jwt过期时间不一致的问题
liuyueyi Sep 25, 2025
6b6867a
Improve mobile navigation for column detail page
itwanger Sep 25, 2025
5caa922
feat: 修复filter拦截失败问题
liuyueyi Sep 25, 2025
e941852
json格式返回无权信息
liuyueyi Sep 25, 2025
e1c14dd
Update star info logic and remove devtools scope
itwanger Sep 25, 2025
dd6346c
Enhance Zsxq signature verification logic
itwanger Sep 27, 2025
17d3739
Update UserServiceImpl.java
itwanger Sep 27, 2025
dcdc237
feat: 移除无效的token,兼容同名key、不同作用域的场景
liuyueyi Sep 28, 2025
147ce96
Update Zsxq bind link and default parameter handling
itwanger Sep 28, 2025
1cd762b
feat: 服务号登录
liuyueyi Sep 28, 2025
9b2da36
fix 适配服务号回调场景
liuyueyi Sep 29, 2025
1f78c35
Merge pull request #123 from itwanger/feat/250928/service_qr_login
liuyueyi Sep 29, 2025
79a84a4
feat: 新增账号迁移
liuyueyi Sep 29, 2025
f875cde
Update image.md
itwanger Sep 29, 2025
b8238fb
Update banner.txt
itwanger Sep 29, 2025
0ed97bd
Enhance user account binding and migration features
itwanger Sep 30, 2025
e0643b1
add login qrcode
liuyueyi Sep 30, 2025
49c6ac9
移除测试日志
liuyueyi Sep 30, 2025
31990fd
Update transfer.html
itwanger Sep 30, 2025
5ed29f7
feat: 服务号登录支持转发校招派
liuyueyi Oct 15, 2025
3e16b63
Add mobile login status check for WeChat login
itwanger Oct 16, 2025
2dcde7a
Improve user null checks and enhance login message
itwanger Oct 16, 2025
69518fc
Add SweetAlert2 and enhance code generation logic
itwanger Oct 16, 2025
4021ee4
Enhance navbar dropdown with arrow and styling
itwanger Oct 16, 2025
02962f7
Add state update for valid starExpireTime in whitelist service
itwanger Oct 16, 2025
ce70af7
Add responsive styles for user page
itwanger Oct 16, 2025
ce95c64
Update WxLoginQrGenIntegration.java
itwanger Oct 16, 2025
5c05302
Add image caption support to markdown rendering
itwanger Oct 20, 2025
3fe88f5
Style images in article content figures
itwanger Oct 20, 2025
1a4fe44
Enhance article images with adaptive width support
itwanger Oct 20, 2025
508435d
Integrate Fancybox for enhanced image viewing
itwanger Oct 20, 2025
f946d31
Improve image width adaptation for mobile devices
itwanger Oct 20, 2025
7f34d04
Update image-adaptive.js
itwanger Oct 20, 2025
c14b90f
Refactor image adaptive width logic to external JS
itwanger Oct 20, 2025
f77c923
Enhance sidebar subscribe section with dynamic content
itwanger Oct 24, 2025
309f806
Add cache refresh endpoint and update side column styles
itwanger Oct 24, 2025
53ac4e3
Update subscribe section styles and image handling
itwanger Oct 24, 2025
6bcc949
Refactor side notice layout for better alignment
itwanger Oct 24, 2025
f9f1b82
Add video embed support to article editor and viewer
itwanger Oct 29, 2025
ca42052
Enhance PDF sidebar with floating and close features
itwanger Nov 3, 2025
bb283ea
Update forum.js
itwanger Nov 3, 2025
19643cc
feat: 划线高亮评论
liuyueyi Nov 3, 2025
1ad1bb6
feat: 完成页面划线评论的基本功能
liuyueyi Nov 4, 2025
23b7546
feat: 完成专栏划词评论
liuyueyi Nov 4, 2025
a81ccc8
Refactor widget and TOC container styles
itwanger Nov 4, 2025
28e191f
feat: 完成移动端划词评论交互
liuyueyi Nov 4, 2025
f95ad75
feat: 调整AI机器人,新增派聪明QA机器人,支持文章内容问答
liuyueyi Nov 4, 2025
53da6b0
Optimize TOC layout and fix double scrollbar issue
itwanger Nov 4, 2025
3b2237e
feat: 评论时,支持选择机器人
liuyueyi Nov 5, 2025
18ce11a
feat: 优化评论交互方式,支持机器人选择; 修复文章截取bug
liuyueyi Nov 5, 2025
50341b7
Merge remote-tracking branch 'origin/feature/251103/underline_comment'
itwanger Nov 5, 2025
3123960
fix: loadmore.js 加载下一页兼容未传入triggerThreshold的场景
liuyueyi Nov 5, 2025
0dcc77b
Update highlight styles and comment placeholder
itwanger Nov 5, 2025
af61828
Rename 杠精机器人 to 杠精派 and enhance notify API
itwanger Nov 5, 2025
66e943a
Add commentId to notification for direct comment linking
itwanger Nov 5, 2025
c05adf3
Add Markdown rendering support for comments
itwanger Nov 5, 2025
06bf5e3
Update AiBotService.java
itwanger Nov 6, 2025
12da056
Add floating comment button with badge and UI enhancements
itwanger Nov 6, 2025
d98cda8
Update highlightcomment.js
itwanger Nov 6, 2025
f029300
Refactor comment styles and add markdown support
itwanger Nov 7, 2025
d7e6c7f
Remove unnecessary z-index from detail page styles
itwanger Nov 7, 2025
469b441
Implement SEO-friendly article URL slugs and migration
itwanger Nov 10, 2025
3e47608
Add project overview and setup instructions in GEMINI.md
itwanger Nov 10, 2025
1149447
Update sitemap URL logic and improve article detail UI
itwanger Nov 28, 2025
84e8594
Update AI bot avatar paths and ensure avatar sync
itwanger Dec 2, 2025
b74718e
Add AI-powered slug generation for articles
itwanger Dec 3, 2025
0f29041
Handle star number binding and add login link in navbar
itwanger Dec 3, 2025
50eed80
Update StatusEnum.java
itwanger Dec 3, 2025
c8133ed
fix: add articleId validation to avoid potential NPE in detail API
Yummyyh Dec 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
429 changes: 429 additions & 0 deletions .claude/ADMIN_URL_SLUG_BACKEND_UPDATE.md

Large diffs are not rendered by default.

353 changes: 353 additions & 0 deletions .claude/ARTICLE_PUBLISH_REDIRECT_FIX.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,353 @@
# 文章发布后重定向URL修复

## 🐛 问题描述

前端发布文章后,重定向到旧的URL格式:
```
/article/detail/123
```

而不是SEO友好的新格式:
```
/article/detail/123/spring-boot-tutorial
```

## 🔍 问题分析

### 问题1: 后端只返回articleId

**位置**: `ArticleRestController.java` line 210

**原始代码**:
```java
@PostMapping(path = "post")
public ResVo<Long> post(@RequestBody ArticlePostReq req, HttpServletResponse response) {
Long id = articleWriteService.saveArticle(req, ...);
return ResVo.ok(id); // ❌ 只返回ID
}
```

**问题**: 前端无法知道文章的urlSlug,无法构建SEO友好的URL。

### 问题2: 前端直接使用articleId重定向

**位置**: `article-edit/index.html` line 933-935

**原始代码**:
```javascript
post("/article/api/post", params, function (data) {
console.log("返回结果:", data)
window.location.href = "/article/detail/" + data // ❌ 只用ID
})
```

**问题**: 直接跳转到 `/article/detail/{id}`,没有使用slug。

### 问题3: slug生成逻辑有问题

**位置**: `ArticleConverter.java` line 43-46

**原始代码**:
```java
// 总是自动生成,覆盖用户输入
String titleForSlug = StringUtils.isNotBlank(req.getShortTitle()) ?
req.getShortTitle() : req.getTitle();
article.setUrlSlug(UrlSlugUtil.generateSlug(titleForSlug));
```

**问题**: 即使用户(admin后台)指定了urlSlug,也会被自动生成的覆盖。

## ✅ 解决方案

### 修复1: 后端返回完整信息

**文件**: `ArticleRestController.java`

**修改后**:
```java
@PostMapping(path = "post")
public ResVo<Map<String, Object>> post(@RequestBody ArticlePostReq req, HttpServletResponse response) {
Long id = articleWriteService.saveArticle(req, ReqInfoContext.getReqInfo().getUserId());

// 查询文章信息以获取urlSlug
ArticleDTO article = articleReadService.queryBasicArticle(id);

Map<String, Object> result = new java.util.HashMap<>();
result.put("articleId", id);
result.put("urlSlug", article.getUrlSlug());

// 返回articleId和urlSlug
return ResVo.ok(result);
}
```

**改进**:
- ✅ 返回类型从 `ResVo<Long>` 改为 `ResVo<Map<String, Object>>`
- ✅ 发布后查询文章获取urlSlug
- ✅ 返回包含articleId和urlSlug的Map

### 修复2: 前端使用slug构建URL

**文件**: `article-edit/index.html`

**修改后**:
```javascript
post("/article/api/post", params, function (data) {
console.log("返回结果:", data)
// data现在是一个对象,包含articleId和urlSlug
if (data.urlSlug && data.urlSlug.length > 0) {
// 使用新的SEO友好URL
window.location.href = "/article/detail/" + data.articleId + "/" + data.urlSlug
} else {
// 兼容没有slug的情况(理论上不应该发生)
window.location.href = "/article/detail/" + data.articleId
}
})
```

**改进**:
- ✅ 检查返回的urlSlug
- ✅ 有slug时使用新格式 `/article/detail/{id}/{slug}`
- ✅ 无slug时fallback到旧格式 `/article/detail/{id}`

### 修复3: slug生成逻辑优化

**文件**: `ArticleConverter.java`

**修改后**:
```java
// 生成URL友好的slug用于SEO优化
if (StringUtils.isNotBlank(req.getUrlSlug())) {
// 如果用户指定了urlSlug(如从admin后台),则使用用户指定的
article.setUrlSlug(req.getUrlSlug());
} else {
// 否则自动生成: 优先使用shortTitle,其次使用title
String titleForSlug = StringUtils.isNotBlank(req.getShortTitle()) ?
req.getShortTitle() : req.getTitle();
article.setUrlSlug(UrlSlugUtil.generateSlug(titleForSlug));
}
```

**改进**:
- ✅ 优先使用用户指定的urlSlug
- ✅ 用户未指定时才自动生成
- ✅ 支持admin后台自定义slug

## 📊 完整流程

### 新文章发布流程

```
1. 用户在编辑器输入标题: "Spring Boot 教程"
2. 用户点击"发布"按钮
3. 前端调用: POST /article/api/post
请求体: { title: "Spring Boot 教程", content: "...", ... }
4. 后端 ArticleRestController.post()
├─ 调用 ArticleWriteService.saveArticle()
│ └─ ArticleConverter.toArticleDo()
│ └─ 检查 req.urlSlug
│ ├─ 有值: 使用用户指定的
│ └─ 无值: 自动生成 "spring-boot-jiao-cheng"
├─ 保存到数据库
├─ 查询刚保存的文章获取完整信息
└─ 返回: { articleId: 123, urlSlug: "spring-boot-jiao-cheng" }
5. 前端接收返回值
├─ 检查 data.urlSlug
├─ 有slug: 跳转到 /article/detail/123/spring-boot-jiao-cheng
└─ 无slug: 跳转到 /article/detail/123 (fallback)
6. 用户看到文章详情页,URL是SEO友好的
```

### Admin后台自定义slug流程

```
1. Admin在后台编辑器输入:
- 标题: "Spring Boot 教程"
- 语义URL: "spring-boot-tutorial" (手动指定)
2. 点击"发布"
3. POST /admin/article/save
请求体: {
title: "Spring Boot 教程",
urlSlug: "spring-boot-tutorial", // 用户指定
...
}
4. 后端 ArticleConverter.toArticleDo()
├─ 检查 req.urlSlug = "spring-boot-tutorial"
└─ 有值: 使用 "spring-boot-tutorial" ✅
(不会自动生成,尊重用户选择)
5. 保存到数据库: url_slug = "spring-boot-tutorial"
6. 前端重定向: /article/detail/123/spring-boot-tutorial
```

## 🧪 测试验证

### 测试1: 前端发布新文章

```bash
# 1. 在编辑器输入标题
标题: "Spring Boot 入门教程"
内容: "这是一篇教程..."

# 2. 点击"发布"

# 3. 观察浏览器URL
期望: http://localhost:8080/article/detail/123/spring-boot-ru-men-jiao-cheng
实际: ✅

# 4. 检查数据库
SELECT id, title, url_slug FROM article WHERE id = 123;
期望: url_slug = "spring-boot-ru-men-jiao-cheng"
实际: ✅
```

### 测试2: 英文标题

```bash
# 标题: "Getting Started with Redis"
# 点击发布

# 期望URL: /article/detail/456/getting-started-with-redis
# 实际: ✅
```

### 测试3: 特殊字符处理

```bash
# 标题: "MyBatis-Plus 3.x 最佳实践"
# 点击发布

# 期望slug: "mybatis-plus-3-x-zui-jia-shi-jian"
# 期望URL: /article/detail/789/mybatis-plus-3-x-zui-jia-shi-jian
# 实际: ✅
```

### 测试4: Admin自定义slug

```bash
# 1. 在admin后台创建文章
标题: "Spring Boot 教程"
语义URL: "my-custom-slug" (手动指定)

# 2. 点击发布

# 3. 期望slug: "my-custom-slug" (不是自动生成的)
# 4. 期望URL: /article/detail/999/my-custom-slug
# 实际: ✅
```

## 📝 API变更说明

### 重要变更: 返回值改变

**接口**: `POST /article/api/post`

**修改前**:
```json
{
"status": { "code": 0, "msg": "ok" },
"result": 123 // Long: 只返回文章ID
}
```

**修改后**:
```json
{
"status": { "code": 0, "msg": "ok" },
"result": {
"articleId": 123,
"urlSlug": "spring-boot-tutorial"
}
}
```

**影响范围**:
- ✅ 前端已同步修改,兼容新格式
- ⚠️ 如果有其他客户端调用此接口,需要适配新格式

## ⚠️ 注意事项

### 1. 向后兼容性

虽然返回格式改变了,但前端代码做了兼容处理:
```javascript
if (data.urlSlug && data.urlSlug.length > 0) {
// 新格式: 使用slug
window.location.href = "/article/detail/" + data.articleId + "/" + data.urlSlug
} else {
// 旧格式: 只用ID (fallback)
window.location.href = "/article/detail/" + data.articleId
}
```

### 2. 性能影响

发布文章后多了一次数据库查询:
```java
ArticleDTO article = articleReadService.queryBasicArticle(id);
```

**影响**: 极小
- 查询操作是根据主键ID查询,有索引,速度很快
- 只在发布文章时执行一次,不是高频操作

### 3. 数据一致性

如果发布成功但查询失败,会抛出异常:
```java
Long id = articleWriteService.saveArticle(...); // 成功
ArticleDTO article = articleReadService.queryBasicArticle(id); // 如果失败?
```

**解决**:
- MyBatis-Plus的事务已经提交,文章已保存
- 查询失败会抛出异常,前端会收到错误提示
- 用户可以刷新页面或从文章列表进入

## 🎉 总结

### 修改的文件 (共3个)

1. **`ArticleRestController.java`** - 返回articleId和urlSlug
2. **`article-edit/index.html`** - 使用slug构建重定向URL
3. **`ArticleConverter.java`** - 优先使用用户指定的slug

### 解决的问题

- ✅ 前端发布文章后自动跳转到SEO友好URL
- ✅ Admin后台可以自定义slug
- ✅ 自动生成slug依然有效
- ✅ 保持向后兼容性

### 用户体验提升

**修改前**:
```
用户发布文章 → 跳转到 /article/detail/123 → URL不友好
```

**修改后**:
```
用户发布文章 → 跳转到 /article/detail/123/spring-boot-tutorial → URL友好 ✨
```

---

**修复时间**: 2025-11-10
**问题发现**: 用户测试发现发布文章后URL没有slug
**修复完成**: 3个文件修改,完全解决
Loading