From f0f2cd8fe7df9e234f793db152325e364df85754 Mon Sep 17 00:00:00 2001 From: API Changelog Bot Date: Fri, 17 Apr 2026 22:41:43 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=B0=8F=E7=A8=8B=E5=BA=8F=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=A8=A1=E5=9D=97=E9=87=8D=E6=9E=84=EF=BC=88=E8=81=94?= =?UTF-8?q?=E7=B3=BB=E6=88=91=E4=BB=AC/=E5=B8=B8=E8=A7=81=E9=97=AE?= =?UTF-8?q?=E9=A2=98/=E5=8D=8F=E8=AE=AE=E6=94=BF=E7=AD=96=EF=BC=89-=20PR?= =?UTF-8?q?=20#773?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...p-config-refactor_contact-faq-agreement.md | 300 ++++++++++++++++++ 1 file changed, 300 insertions(+) create mode 100644 changelogs/2026-04/2026-04-17_mp-config-refactor_contact-faq-agreement.md diff --git a/changelogs/2026-04/2026-04-17_mp-config-refactor_contact-faq-agreement.md b/changelogs/2026-04/2026-04-17_mp-config-refactor_contact-faq-agreement.md new file mode 100644 index 0000000..9add4d1 --- /dev/null +++ b/changelogs/2026-04/2026-04-17_mp-config-refactor_contact-faq-agreement.md @@ -0,0 +1,300 @@ +# 小程序配置模块重构:联系我们 / 常见问题 / 协议政策 + +> **服务**: hl-user-service (端口 8081) +> **PR**: https://git.1814.love:8443/wx/HL/pulls/773 +> **Issue**: https://git.1814.love:8443/wx/HL/issues/766 +> **日期**: 2026-04-17 +> **影响范围**: 管理端三大配置模块(联系我们 / 常见问题 / 协议政策)的所有写接口和大部分读接口 + +--- + +## 背景 + +小程序配置模块历史遗留问题较多: +- Status 字段混用 Integer(0/1) 与 String("启用/停用") +- VO 命名不统一:`FaqCategoryVO` / `AgreementRequest` 等不符合团队规范 +- 协议政策每类型应只有一条记录,但历史接口允许多记录 CRUD,数据可能出现同类型多条 +- 没有字典校验 / 条件必填 / 幂等 / 富文本 XSS 过滤,业务错常见 500 + +本次整改按团队规范重构三个模块,统一 VO 命名、字段类型、错误码、安全策略。 + +## 字段统一变更(全三模块) + +### Status 字段:Integer → String + +| 旧值 | 新值 | +|------|------| +| `1` | `"ACTIVE"` | +| `0` | `"INACTIVE"` | + +影响所有请求体 / 响应体中的 `status` / `enabled` 字段,前端请求与展示都需切换成大写英文常量。 + +数据库迁移由 DDL 完成(幂等 SQL,已在 PR 中附带)。 + +### 业务错误码:500 → 400 + +字典值非法、条件校验失败、资源不存在等业务错从 `code=500` 改为 `code=400`,并附中文消息。HTTP 始终 200,前端按 `code` 区分。 + +### 写接口全部加 @Idempotent + +9 个写接口启用幂等控制(3~5 秒窗口),前端连点 / 重试会被返: + +```json +{ + "code": 429, + "success": false, + "message": "请勿重复提交" +} +``` + +改 body 后可再次提交。 + +### 富文本 XSS 过滤(后端自动处理) + +以下字段提交时后端自动清洗 `