|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+# 站内消息 — 技术方案(C 端)
|
|
|
2
|
+
|
|
|
3
|
+> **依据:** 《站内消息功能需求.md》v1.0
|
|
|
4
|
+> **关联:** 平台《商户入驻审核技术方案》v1.1、《商户入驻审核功能需求》v1.1、《会员管理技术方案》v1.3、《关联需求分析.md》v1.6;C 端《我的服务技术方案》v1.0
|
|
|
5
|
+> **范围:** C 端 **`/api/member/message/**`** 未读数、分页列表、详情(含 **打开即已读**);**复用** 既有 `biz_member_message` 与入驻审核 **写入** 链路;**不含** 前端页面、平台消息管理、短信/Push。
|
|
|
6
|
+> **原则:** **不新建表**;写入 **仅** `entry` 模块 `MemberEntryMessageSupport`;本模块 **只读 + 已读更新**;按 `member_id` **严格隔离**。
|
|
|
7
|
+
|
|
|
8
|
+---
|
|
|
9
|
+
|
|
|
10
|
+## 1. 技术架构
|
|
|
11
|
+
|
|
|
12
|
+| 项 | 选型 |
|
|
|
13
|
+|----|------|
|
|
|
14
|
+| 基础框架 | RuoYi **v3.9.2**(`springboot2` 分支) |
|
|
|
15
|
+| 数据库 | **MySQL 5.7.39** |
|
|
|
16
|
+| ORM / 响应 | MyBatis;`AjaxResult`(`code`、`msg`、`data`);列表 **`TableDataInfo`**(`rows`、`total`) |
|
|
|
17
|
+| 鉴权 | **`MemberAuthInterceptor`**(`MemberWebConfig` → `/api/member/**`);**无** `@Anonymous` |
|
|
|
18
|
+| 分页 | **`PageHelper`** + `startPage()`;Query `pageNum`、`pageSize` |
|
|
|
19
|
+| 缓存 | **本期不做** Redis |
|
|
|
20
|
+
|
|
|
21
|
+### 1.1 模块落位
|
|
|
22
|
+
|
|
|
23
|
+```text
|
|
|
24
|
+baqing-shop/src/main/java/com/ruoyi/web/modules/message/ # 新建 · C 端读
|
|
|
25
|
+├── controller/MemberMessageAppController.java # /api/member/message/**
|
|
|
26
|
+├── service/IMemberMessageAppService.java
|
|
|
27
|
+├── service/impl/MemberMessageAppServiceImpl.java
|
|
|
28
|
+├── vo/
|
|
|
29
|
+│ ├── MemberMessageListItemVO.java # 列表行
|
|
|
30
|
+│ ├── MemberMessageDetailVO.java # 详情
|
|
|
31
|
+│ └── MemberMessageUnreadVO.java # 未读数
|
|
|
32
|
+└── constant/MemberMessageConstants.java # 文案/ bizType 常量(读侧)
|
|
|
33
|
+
|
|
|
34
|
+entry/(已有 · 写入 · 协作)
|
|
|
35
|
+├── domain/BizMemberMessage.java
|
|
|
36
|
+├── mapper/BizMemberMessageMapper.java # 扩展 select/count/updateRead
|
|
|
37
|
+├── support/MemberEntryMessageSupport.java # approve/reject/complete 写消息
|
|
|
38
|
+└── constant/MerchantEntryApplyConstants.java # BIZ_TYPE_ENTRY_AUDIT、标题常量
|
|
|
39
|
+
|
|
|
40
|
+account/(已有 · 鉴权)
|
|
|
41
|
+├── config/MemberWebConfig.java # /api/member/** 已覆盖 message
|
|
|
42
|
+└── support/MemberContext.java、MemberAuthInterceptor.java
|
|
|
43
|
+
|
|
|
44
|
+resources/mapper/entry/BizMemberMessageMapper.xml # 扩展 SQL
|
|
|
45
|
+sql/biz_member_message.sql # 权威 DDL(已存在)
|
|
|
46
|
+```
|
|
|
47
|
+
|
|
|
48
|
+### 1.2 协作链
|
|
|
49
|
+
|
|
|
50
|
+```text
|
|
|
51
|
+【写入 · 平台入驻审核 · 已实现】
|
|
|
52
|
+ PUT /agri/merchantEntryApply/approve/{applyId}
|
|
|
53
|
+ → MemberEntryMessageSupport.sendPublicity(...)
|
|
|
54
|
+ PUT /agri/merchantEntryApply/completePublicity/{applyId}
|
|
|
55
|
+ 或 MerchantEntryPublicityTask.processExpiredPublicity()
|
|
|
56
|
+ → MemberEntryMessageSupport.sendPass(...)
|
|
|
57
|
+ PUT /agri/merchantEntryApply/reject
|
|
|
58
|
+ → MemberEntryMessageSupport.sendReject(...)
|
|
|
59
|
+
|
|
|
60
|
+【本模块 · C 端读】
|
|
|
61
|
+ GET /api/member/message/unread-count → 红点/角标
|
|
|
62
|
+ GET /api/member/message/list → 分页列表
|
|
|
63
|
+ GET /api/member/message/{messageId} → 详情 + 标记已读
|
|
|
64
|
+
|
|
|
65
|
+【前端跳转 · 协作】
|
|
|
66
|
+ biz_type=ENTRY_AUDIT & biz_id=applyId
|
|
|
67
|
+ → 我的入驻 GET /api/merchant/entry/my(按 applyId 定位详情页)
|
|
|
68
|
+```
|
|
|
69
|
+
|
|
|
70
|
+| 关联模块 | 协作 |
|
|
|
71
|
+|----------|------|
|
|
|
72
|
+| **平台 · 商户入驻审核** | **唯一写入方**(EA14);三类消息标题/正文与 `MemberEntryMessageSupport` **一致** |
|
|
|
73
|
+| **平台 · 会员管理** | 禁用会员 **无法登录** → 本模块不可用 |
|
|
|
74
|
+| **C 端 · 我的服务 / 入驻** | 消息详情 **跳转** 至 `/api/merchant/entry/my` 对应申请 |
|
|
|
75
|
+| **C 端 · 订单/关注** | 订单/开业提醒类消息 **非本期**;`biz_type` 预留扩展 |
|
|
|
76
|
+
|
|
|
77
|
+### 1.3 职责边界
|
|
|
78
|
+
|
|
|
79
|
+| 层 | 职责 |
|
|
|
80
|
+|----|------|
|
|
|
81
|
+| `MemberEntryMessageSupport` | **insert** 消息;**不** 提供 C 端 API |
|
|
|
82
|
+| `MemberMessageAppService` | 按 `member_id` **查询**、**未读计数**、**详情并 markRead** |
|
|
|
83
|
+| C 端 Controller | **无** 创建/删除/编辑消息接口(MM8) |
|
|
|
84
|
+
|
|
|
85
|
+---
|
|
|
86
|
+
|
|
|
87
|
+## 2. 数据库设计
|
|
|
88
|
+
|
|
|
89
|
+### 2.1 复用 · 会员站内消息 `biz_member_message`
|
|
|
90
|
+
|
|
|
91
|
+> DDL 见 [`sql/biz_member_message.sql`](../../../../sql/biz_member_message.sql);**本期不 ALTER**。
|
|
|
92
|
+
|
|
|
93
|
+| 字段 | 类型 | 说明 |
|
|
|
94
|
+|------|------|------|
|
|
|
95
|
+| message_id | bigint PK | 自增 |
|
|
|
96
|
+| member_id | bigint | 收件会员;**列表/详情 WHERE 必带** |
|
|
|
97
|
+| biz_type | varchar(32) | 业务类型;本期 **`ENTRY_AUDIT`** |
|
|
|
98
|
+| biz_id | bigint | 业务主键;入驻类 = **`apply_id`** |
|
|
|
99
|
+| title | varchar(128) | 标题 |
|
|
|
100
|
+| content | varchar(1000) | 正文(含驳回原因、公示时间等) |
|
|
|
101
|
+| read_flag | char(1) | **`0`** 未读 / **`1`** 已读;默认 `0` |
|
|
|
102
|
+| create_time | datetime | 投递时间;列表 **降序** |
|
|
|
103
|
+
|
|
|
104
|
+**索引(已有):**
|
|
|
105
|
+
|
|
|
106
|
+| 索引 | 用途 |
|
|
|
107
|
+|------|------|
|
|
|
108
|
+| `idx_member_time` (member_id, create_time) | 分页列表 |
|
|
|
109
|
+| PK (message_id) | 详情 |
|
|
|
110
|
+
|
|
|
111
|
+**可选优化(非本期必做):** `idx_member_read` (member_id, read_flag) — 未读数大时加速 `COUNT`。
|
|
|
112
|
+
|
|
|
113
|
+### 2.2 业务类型枚举(本期)
|
|
|
114
|
+
|
|
|
115
|
+| biz_type | 含义 | biz_id | 写入时机 |
|
|
|
116
|
+|----------|------|--------|----------|
|
|
|
117
|
+| `ENTRY_AUDIT` | 商户入驻审核 | `apply_id` | 公示中 / 入驻完成 / 审核驳回 |
|
|
|
118
|
+
|
|
|
119
|
+**标题常量(与 `MerchantEntryApplyConstants` 对齐):**
|
|
|
120
|
+
|
|
|
121
|
+| 场景 | title |
|
|
|
122
|
+|------|-------|
|
|
|
123
|
+| 审核通过→公示 | 入驻审核通过,公示中 |
|
|
|
124
|
+| 完成公示 | 入驻完成 |
|
|
|
125
|
+| 审核驳回 | 入驻审核未通过 |
|
|
|
126
|
+
|
|
|
127
|
+### 2.3 与关联表
|
|
|
128
|
+
|
|
|
129
|
+| 表 | 关系 |
|
|
|
130
|
+|----|------|
|
|
|
131
|
+| `biz_merchant_entry_apply` | `biz_id` → `apply_id`;跳转前 **可选** 校验申请是否存在 |
|
|
|
132
|
+| `biz_member` | `member_id` → 收件人;与登录态 **一致** |
|
|
|
133
|
+
|
|
|
134
|
+---
|
|
|
135
|
+
|
|
|
136
|
+## 3. C 端接口设计
|
|
|
137
|
+
|
|
|
138
|
+**基路径:** `/api/member/message`
|
|
|
139
|
+**鉴权:** 全部须 **`Authorization: Bearer {token}`**;未登录 → **401**「请先登录」
|
|
|
140
|
+**MemberWebConfig:** `/api/member/**` **已拦截**,**无需追加** path。
|
|
|
141
|
+
|
|
|
142
|
+### 3.1 接口一览
|
|
|
143
|
+
|
|
|
144
|
+| 方法 | 路径 | 说明 |
|
|
|
145
|
+|------|------|------|
|
|
|
146
|
+| GET | `/api/member/message/unread-count` | 未读条数(红点) |
|
|
|
147
|
+| GET | `/api/member/message/list` | 消息分页列表 |
|
|
|
148
|
+| GET | `/api/member/message/{messageId}` | 消息详情 + **标记已读** |
|
|
|
149
|
+
|
|
|
150
|
+**本期不提供:**
|
|
|
151
|
+
|
|
|
152
|
+| 项 | 说明 |
|
|
|
153
|
+|----|------|
|
|
|
154
|
+| POST/PUT/DELETE 消息 | C 端 **不可** 创建/编辑/删除(MM8) |
|
|
|
155
|
+| 分类 Tab / 搜索 / 批量已读 | 需求 **非本期** |
|
|
|
156
|
+| 平台 B 端查会员信箱 | **无** |
|
|
|
157
|
+
|
|
|
158
|
+### 3.2 未读数 `GET /api/member/message/unread-count`
|
|
|
159
|
+
|
|
|
160
|
+| 项 | 说明 |
|
|
|
161
|
+|----|------|
|
|
|
162
|
+| 数据范围 | `member_id = MemberContext.getMemberId()` 且 `read_flag='0'` |
|
|
|
163
|
+| 响应 | `AjaxResult` → `data` |
|
|
|
164
|
+
|
|
|
165
|
+**`data` → `MemberMessageUnreadVO`:**
|
|
|
166
|
+
|
|
|
167
|
+| 字段 | 类型 | 说明 |
|
|
|
168
|
+|------|------|------|
|
|
|
169
|
+| unreadCount | int | 未读条数;**0** 时前端 **隐藏** 红点 |
|
|
|
170
|
+
|
|
|
171
|
+**SQL 要点:** `SELECT COUNT(1) FROM biz_member_message WHERE member_id=? AND read_flag='0'`
|
|
|
172
|
+
|
|
|
173
|
+### 3.3 消息列表 `GET /api/member/message/list`
|
|
|
174
|
+
|
|
|
175
|
+| 项 | 说明 |
|
|
|
176
|
+|----|------|
|
|
|
177
|
+| Query | `pageNum`、`pageSize`(RuoYi 默认) |
|
|
|
178
|
+| 排序 | `create_time DESC` |
|
|
|
179
|
+| 响应 | **`TableDataInfo`** |
|
|
|
180
|
+
|
|
|
181
|
+**`rows[]` → `MemberMessageListItemVO`:**
|
|
|
182
|
+
|
|
|
183
|
+| 字段 | 类型 | 说明 |
|
|
|
184
|
+|------|------|------|
|
|
|
185
|
+| messageId | long | |
|
|
|
186
|
+| title | string | |
|
|
|
187
|
+| summary | string | `content` **截断**(建议 ≤80 字,Service 层 `StringUtils.abbreviate`) |
|
|
|
188
|
+| readFlag | string | `0` / `1` |
|
|
|
189
|
+| createTime | string | `yyyy-MM-dd HH:mm:ss` |
|
|
|
190
|
+| bizType | string | 如 `ENTRY_AUDIT` |
|
|
|
191
|
+| bizId | long | 如 `applyId` |
|
|
|
192
|
+
|
|
|
193
|
+**空列表:** `rows=[]`,`total=0`;**非异常**。
|
|
|
194
|
+
|
|
|
195
|
+### 3.4 消息详情 `GET /api/member/message/{messageId}`
|
|
|
196
|
+
|
|
|
197
|
+| 项 | 说明 |
|
|
|
198
|
+|----|------|
|
|
|
199
|
+| 数据范围 | `message_id=? AND member_id=当前会员` |
|
|
|
200
|
+| 副作用 | 若 `read_flag='0'` → **更新为 `1`**(MM2);已读 **幂等** |
|
|
|
201
|
+| 事务 | `@Transactional`:查询 + 条件更新 **同一事务** |
|
|
|
202
|
+
|
|
|
203
|
+**不存在或非本人:** `ServiceException`「消息不存在」(**404** 或业务码,与项目统一)。
|
|
|
204
|
+
|
|
|
205
|
+**`data` → `MemberMessageDetailVO`:**
|
|
|
206
|
+
|
|
|
207
|
+| 字段 | 类型 | 说明 |
|
|
|
208
|
+|------|------|------|
|
|
|
209
|
+| messageId | long | |
|
|
|
210
|
+| title | string | 完整标题 |
|
|
|
211
|
+| content | string | 完整正文 |
|
|
|
212
|
+| readFlag | string | 返回 **`1`**(本次打开后) |
|
|
|
213
|
+| createTime | string | |
|
|
|
214
|
+| bizType | string | |
|
|
|
215
|
+| bizId | long | |
|
|
|
216
|
+| linkType | string | 跳转类型;`ENTRY_AUDIT` → **`MERCHANT_ENTRY`** |
|
|
|
217
|
+| linkAvailable | boolean | 关联 `apply_id` **是否存在**;`false` 时前端 **仅展示正文** |
|
|
|
218
|
+
|
|
|
219
|
+**跳转约定(前端):**
|
|
|
220
|
+
|
|
|
221
|
+| linkType | 行为 |
|
|
|
222
|
+|----------|------|
|
|
|
223
|
+| `MERCHANT_ENTRY` | 跳转 **我的入驻** 页,携带 `applyId=bizId`;数据来自 **`GET /api/merchant/entry/my`** |
|
|
|
224
|
+
|
|
|
225
|
+### 3.5 错误与响应格式
|
|
|
226
|
+
|
|
|
227
|
+| 场景 | code | msg(示例) |
|
|
|
228
|
+|------|------|-------------|
|
|
|
229
|
+| 未登录 | 401 | 请先登录 |
|
|
|
230
|
+| 消息不存在 | 404 或 500 | 消息不存在 |
|
|
|
231
|
+| 成功 | 200 | 操作成功 |
|
|
|
232
|
+
|
|
|
233
|
+统一 **`AjaxResult` / `TableDataInfo`**,与 C 端其它模块一致。
|
|
|
234
|
+
|
|
|
235
|
+---
|
|
|
236
|
+
|
|
|
237
|
+## 4. Service 要点
|
|
|
238
|
+
|
|
|
239
|
+### 4.1 `getUnreadCount(memberId)`
|
|
|
240
|
+
|
|
|
241
|
+```text
|
|
|
242
|
+return mapper.countUnreadByMemberId(memberId)
|
|
|
243
|
+```
|
|
|
244
|
+
|
|
|
245
|
+### 4.2 `listMessages(memberId)`(Controller 内 `startPage()`)
|
|
|
246
|
+
|
|
|
247
|
+```text
|
|
|
248
|
+return mapper.selectListByMemberId(memberId) # ORDER BY create_time DESC
|
|
|
249
|
+→ 每行 content → summary 截断
|
|
|
250
|
+```
|
|
|
251
|
+
|
|
|
252
|
+### 4.3 `getDetailAndMarkRead(memberId, messageId)`(@Transactional)
|
|
|
253
|
+
|
|
|
254
|
+```text
|
|
|
255
|
+msg = mapper.selectByIdAndMemberId(messageId, memberId)
|
|
|
256
|
+if msg == null → throw「消息不存在」
|
|
|
257
|
+if read_flag == '0' → mapper.updateReadFlag(messageId, memberId, '1')
|
|
|
258
|
+if biz_type == ENTRY_AUDIT → linkAvailable = applyMapper.selectById(bizId) != null
|
|
|
259
|
+assemble MemberMessageDetailVO
|
|
|
260
|
+```
|
|
|
261
|
+
|
|
|
262
|
+### 4.4 Mapper 扩展(`BizMemberMessageMapper`)
|
|
|
263
|
+
|
|
|
264
|
+| 方法 | 说明 |
|
|
|
265
|
+|------|------|
|
|
|
266
|
+| `insert` | **已有** · 写入 |
|
|
|
267
|
+| `countUnreadByMemberId(Long memberId)` | 未读数 |
|
|
|
268
|
+| `selectListByMemberId(Long memberId)` | 列表(PageHelper 分页) |
|
|
|
269
|
+| `selectByIdAndMemberId(messageId, memberId)` | 详情 + 隔离 |
|
|
|
270
|
+| `updateReadFlag(messageId, memberId, readFlag)` | `WHERE message_id AND member_id` |
|
|
|
271
|
+
|
|
|
272
|
+---
|
|
|
273
|
+
|
|
|
274
|
+## 5. 与平台入驻审核写入对齐
|
|
|
275
|
+
|
|
|
276
|
+| 平台操作 | 消息方法 | title | content 要点 |
|
|
|
277
|
+|----------|----------|-------|--------------|
|
|
|
278
|
+| approve | `sendPublicity` | 入驻审核通过,公示中 | 申请编号 + 公示结束时间 |
|
|
|
279
|
+| completePublicity | `sendPass` | 入驻完成 | 申请编号 + 经营账号登录指引 |
|
|
|
280
|
+| reject | `sendReject` | 入驻审核未通过 | 申请编号 + **驳回原因** |
|
|
|
281
|
+
|
|
|
282
|
+> **本模块不修改** 上述写入逻辑;联调时核对 **标题/正文** 与《站内消息功能需求》§7 **一致** 即可。
|
|
|
283
|
+
|
|
|
284
|
+---
|
|
|
285
|
+
|
|
|
286
|
+## 6. 业务规则映射(MM)
|
|
|
287
|
+
|
|
|
288
|
+| 编号 | 实现要点 |
|
|
|
289
|
+|------|----------|
|
|
|
290
|
+| MM0 | `MemberWebConfig` + `MemberContext` |
|
|
|
291
|
+| MM1 | `unread-count` → `COUNT read_flag=0` |
|
|
|
292
|
+| MM2 | 详情接口 **同事务** 更新 `read_flag=1` |
|
|
|
293
|
+| MM3 | 写入在 **entry**;本模块 **只读** |
|
|
|
294
|
+| MM4 | content 与 `MemberEntryMessageSupport` **同源** |
|
|
|
295
|
+| MM5 | 所有 SQL **带 member_id** |
|
|
|
296
|
+| MM6 | 列表 `create_time DESC` + PageHelper |
|
|
|
297
|
+| MM7 | 详情返回 `linkType` + `bizId` |
|
|
|
298
|
+| MM8 | **无** 写/删 API |
|
|
|
299
|
+| MM9 | 代录入 **无** insert → 本模块 **无** 此类消息 |
|
|
|
300
|
+| MM10 | 仅处理已写入的 `ENTRY_AUDIT` |
|
|
|
301
|
+
|
|
|
302
|
+---
|
|
|
303
|
+
|
|
|
304
|
+## 7. 测试要点
|
|
|
305
|
+
|
|
|
306
|
+| 用例 | 预期 |
|
|
|
307
|
+|------|------|
|
|
|
308
|
+| 未登录调 list | 401 |
|
|
|
309
|
+| 会员 A 读会员 B 的 messageId | 「消息不存在」 |
|
|
|
310
|
+| 未读详情后再调 unread-count | 计数 **-1** |
|
|
|
311
|
+| 已读详情再次打开 | `read_flag` 仍为 1 |
|
|
|
312
|
+| approve 后 list | 新行 `read_flag=0`,title=公示中 |
|
|
|
313
|
+| reject 后 detail | content **含** rejectReason |
|
|
|
314
|
+| 空信箱 list | rows=[], total=0 |
|
|
|
315
|
+
|
|
|
316
|
+**建议测试类:** `MemberMessageAppServiceTest`、`MemberMessageAppControllerTest`(MockMvc + Token)。
|
|
|
317
|
+
|
|
|
318
|
+---
|
|
|
319
|
+
|
|
|
320
|
+## 8. 非本期 / 扩展
|
|
|
321
|
+
|
|
|
322
|
+| 项 | 说明 |
|
|
|
323
|
+|----|------|
|
|
|
324
|
+| 订单类 `biz_type=ORDER_*` | 订单模块建设时 **扩展** insert + linkType |
|
|
|
325
|
+| 店铺开业 `SHOP_OPEN` | 关注模块 **另册** |
|
|
|
326
|
+| `PUT .../read-all` 全部已读 | 可迭代 |
|
|
|
327
|
+| Redis 缓存未读数 | 量大时再考虑 |
|
|
|
328
|
+| 平台消息管理后台 | **无** |
|
|
|
329
|
+
|
|
|
330
|
+---
|
|
|
331
|
+
|
|
|
332
|
+## 9. 修订记录
|
|
|
333
|
+
|
|
|
334
|
+| 版本 | 说明 |
|
|
|
335
|
+|------|------|
|
|
|
336
|
+| **v1.0** | 首版:复用 `biz_member_message`;`/api/member/message` 三接口;与入驻审核写入链协作 |
|
|
|
337
|
+
|
|
|
338
|
+---
|
|
|
339
|
+
|
|
|
340
|
+*文档版本:v1.0 · 关联《站内消息功能需求.md》v1.0、《商户入驻审核技术方案.md》v1.1、《会员管理技术方案》v1.3 · 草稿保持不变。*
|