6aspec 2.0.0-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.6aspec/rules/biz/api_rule.md +578 -0
- package/.6aspec/rules/biz/background_job_rule.md +719 -0
- package/.6aspec/rules/biz/c_user_system_rule.md +240 -0
- package/.6aspec/rules/biz/code.md +39 -0
- package/.6aspec/rules/biz/event_subscriber_rule.md +529 -0
- package/.6aspec/rules/biz/project-structure.md +90 -0
- package/.6aspec/rules/biz/scheduled_job_rule.md +850 -0
- package/.6aspec/rules/brown/brown_archive_sop.md +132 -0
- package/.6aspec/rules/brown/brown_constitution.md +20 -0
- package/.6aspec/rules/brown/brown_continue_sop.md +97 -0
- package/.6aspec/rules/brown/brown_design_sop.md +155 -0
- package/.6aspec/rules/brown/brown_ff_sop.md +194 -0
- package/.6aspec/rules/brown/brown_impact_sop.md +296 -0
- package/.6aspec/rules/brown/brown_implement_sop.md +133 -0
- package/.6aspec/rules/brown/brown_list_sop.md +69 -0
- package/.6aspec/rules/brown/brown_new_sop.md +257 -0
- package/.6aspec/rules/brown/brown_proposal_sop.md +160 -0
- package/.6aspec/rules/brown/brown_quick_sop.md +134 -0
- package/.6aspec/rules/brown/brown_review_sop.md +270 -0
- package/.6aspec/rules/brown/brown_rollback_sop.md +188 -0
- package/.6aspec/rules/brown/brown_specs_sop.md +227 -0
- package/.6aspec/rules/brown/brown_status_sop.md +135 -0
- package/.6aspec/rules/brown/brown_tasks_sop.md +202 -0
- package/.6aspec/rules/brown/brown_understand_sop.md +211 -0
- package/.6aspec/rules/brown/brown_verify_sop.md +360 -0
- package/.6aspec/rules/green/6A_archive_sop.md +301 -0
- package/.6aspec/rules/green/6A_clarify_sop.md +238 -0
- package/.6aspec/rules/green/6A_code_implementation_sop.md +110 -0
- package/.6aspec/rules/green/6A_constitution.md +52 -0
- package/.6aspec/rules/green/6A_continue_sop.md +186 -0
- package/.6aspec/rules/green/6A_design_sop.md +228 -0
- package/.6aspec/rules/green/6A_import_model_table_sop.md +120 -0
- package/.6aspec/rules/green/6A_init_event_list_sop.md +62 -0
- package/.6aspec/rules/green/6A_init_map_sop.md +79 -0
- package/.6aspec/rules/green/6A_model_sop.md +210 -0
- package/.6aspec/rules/green/6A_new_sop.md +319 -0
- package/.6aspec/rules/green/6A_rollback_sop.md +198 -0
- package/.6aspec/rules/green/6A_status_sop.md +275 -0
- package/.6aspec/rules/green/6A_tasks_sop.md +181 -0
- package/.6aspec/rules/green/6A_visual_logic_sop.md +121 -0
- package/.6aspec/rules/green/green_status_schema.md +293 -0
- package/.6aspec/script/create_entities_from_markdown.py +688 -0
- package/.claude/commands/6aspec/brown/archive.md +11 -0
- package/.claude/commands/6aspec/brown/continue.md +11 -0
- package/.claude/commands/6aspec/brown/design.md +11 -0
- package/.claude/commands/6aspec/brown/ff.md +11 -0
- package/.claude/commands/6aspec/brown/impact.md +11 -0
- package/.claude/commands/6aspec/brown/implement.md +11 -0
- package/.claude/commands/6aspec/brown/list.md +11 -0
- package/.claude/commands/6aspec/brown/new.md +11 -0
- package/.claude/commands/6aspec/brown/proposal.md +11 -0
- package/.claude/commands/6aspec/brown/quick.md +11 -0
- package/.claude/commands/6aspec/brown/review.md +11 -0
- package/.claude/commands/6aspec/brown/rollback.md +11 -0
- package/.claude/commands/6aspec/brown/specs.md +11 -0
- package/.claude/commands/6aspec/brown/status.md +11 -0
- package/.claude/commands/6aspec/brown/tasks.md +11 -0
- package/.claude/commands/6aspec/brown/understand.md +11 -0
- package/.claude/commands/6aspec/brown/verify.md +11 -0
- package/.claude/commands/6aspec/green/archive.md +8 -0
- package/.claude/commands/6aspec/green/clarify.md +13 -0
- package/.claude/commands/6aspec/green/continue.md +8 -0
- package/.claude/commands/6aspec/green/design.md +8 -0
- package/.claude/commands/6aspec/green/execute-task.md +20 -0
- package/.claude/commands/6aspec/green/import-model-table.md +8 -0
- package/.claude/commands/6aspec/green/init.md +14 -0
- package/.claude/commands/6aspec/green/model.md +12 -0
- package/.claude/commands/6aspec/green/new.md +13 -0
- package/.claude/commands/6aspec/green/rollback.md +8 -0
- package/.claude/commands/6aspec/green/status.md +8 -0
- package/.claude/commands/6aspec/green/tasks.md +8 -0
- package/.claude/commands/6aspec/green/visual-logic.md +9 -0
- package/.claude/settings.local.json +8 -0
- package/.cursor/commands/6aspec/brown/archive.md +9 -0
- package/.cursor/commands/6aspec/brown/continue.md +9 -0
- package/.cursor/commands/6aspec/brown/design.md +9 -0
- package/.cursor/commands/6aspec/brown/ff.md +9 -0
- package/.cursor/commands/6aspec/brown/impact.md +9 -0
- package/.cursor/commands/6aspec/brown/implement.md +9 -0
- package/.cursor/commands/6aspec/brown/list.md +9 -0
- package/.cursor/commands/6aspec/brown/new.md +9 -0
- package/.cursor/commands/6aspec/brown/proposal.md +9 -0
- package/.cursor/commands/6aspec/brown/quick.md +9 -0
- package/.cursor/commands/6aspec/brown/review.md +9 -0
- package/.cursor/commands/6aspec/brown/rollback.md +9 -0
- package/.cursor/commands/6aspec/brown/specs.md +9 -0
- package/.cursor/commands/6aspec/brown/status.md +9 -0
- package/.cursor/commands/6aspec/brown/tasks.md +9 -0
- package/.cursor/commands/6aspec/brown/understand.md +9 -0
- package/.cursor/commands/6aspec/brown/verify.md +9 -0
- package/.cursor/commands/6aspec/green/archive.md +9 -0
- package/.cursor/commands/6aspec/green/clarify.md +14 -0
- package/.cursor/commands/6aspec/green/continue.md +9 -0
- package/.cursor/commands/6aspec/green/design.md +9 -0
- package/.cursor/commands/6aspec/green/execute-task.md +21 -0
- package/.cursor/commands/6aspec/green/import-model-table.md +9 -0
- package/.cursor/commands/6aspec/green/init.md +15 -0
- package/.cursor/commands/6aspec/green/model.md +13 -0
- package/.cursor/commands/6aspec/green/new.md +14 -0
- package/.cursor/commands/6aspec/green/rollback.md +9 -0
- package/.cursor/commands/6aspec/green/status.md +9 -0
- package/.cursor/commands/6aspec/green/tasks.md +9 -0
- package/.cursor/commands/6aspec/green/visual-logic.md +10 -0
- package/README.en.md +36 -0
- package/README.md +146 -0
- package/bin/6a-spec-install +54 -0
- package/bin/6aspec +48 -0
- package/lib/cli.js +318 -0
- package/lib/installer.js +333 -0
- package/package.json +62 -0
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: C端用户体系规范
|
|
3
|
+
alwaysApply: false
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# C端用户体系规范
|
|
7
|
+
|
|
8
|
+
## 概述
|
|
9
|
+
|
|
10
|
+
本规范定义了系统中C端用户体系的设计标准,包括用户表结构、认证机制、身份类型、数据关联规范等。
|
|
11
|
+
|
|
12
|
+
**适用范围**:所有面向C端用户的门户应用,主要依赖微信小程序。
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## 一、核心表结构
|
|
17
|
+
|
|
18
|
+
### 1.1 C端用户中心表(mdm_mycuser)
|
|
19
|
+
|
|
20
|
+
**表说明**:C端用户中心的核心表,存储所有C端用户的基础信息。
|
|
21
|
+
|
|
22
|
+
**使用场景**:
|
|
23
|
+
- 用户在小程序登录后会自动生成一条用户记录
|
|
24
|
+
- 存储用户基础信息和手机号
|
|
25
|
+
- 未认证用户的业务关联直接使用此表
|
|
26
|
+
|
|
27
|
+
**关键字段**:
|
|
28
|
+
- 用户ID(主键)
|
|
29
|
+
- 手机号:用户授权后的实名认证手机号
|
|
30
|
+
- 创建时间:用户首次登录时间
|
|
31
|
+
- 其他用户基础信息字段
|
|
32
|
+
|
|
33
|
+
**使用原则**:
|
|
34
|
+
- ✅ 查询所有C端用户(包括未认证用户)
|
|
35
|
+
- ✅ 未认证用户的业务数据关联
|
|
36
|
+
- ✅ 用户基础信息的存储和查询
|
|
37
|
+
- ❌ 不应直接在此表存储业务相关字段
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
### 1.2 门户用户表(nr_tocuser)
|
|
42
|
+
|
|
43
|
+
**表说明**:门户管理应用中的用户表,与 `mdm_mycuser` 一一对应(历史遗留原因)。
|
|
44
|
+
|
|
45
|
+
**使用场景**:
|
|
46
|
+
- 经过认证的用户业务关联
|
|
47
|
+
- 门户业务相关的用户扩展信息
|
|
48
|
+
- 用户身份信息的存储
|
|
49
|
+
|
|
50
|
+
**关键字段**:
|
|
51
|
+
- 用户ID(主键)
|
|
52
|
+
- 关联的 mdm_mycuser 用户ID(外键)
|
|
53
|
+
- 身份类型
|
|
54
|
+
- 认证状态
|
|
55
|
+
- 其他门户业务相关字段
|
|
56
|
+
|
|
57
|
+
**使用原则**:
|
|
58
|
+
- ✅ 已认证用户的业务数据关联(推荐使用此表)
|
|
59
|
+
- ✅ 门户业务相关的用户扩展信息
|
|
60
|
+
- ✅ 用户身份和权限相关的查询
|
|
61
|
+
- ❌ 不应用于未认证用户的关联
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
### 1.3 表关系说明
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
┌─────────────────┐ 一对一关系 ┌─────────────────┐
|
|
69
|
+
│ mdm_mycuser │ ─────────────────────────> │ nr_tocuser │
|
|
70
|
+
│ (C端用户中心) │ │ (门户用户) │
|
|
71
|
+
└─────────────────┘ └─────────────────┘
|
|
72
|
+
↑ ↑
|
|
73
|
+
│ │
|
|
74
|
+
│ │
|
|
75
|
+
未认证用户关联 已认证用户关联
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
**说明**:
|
|
79
|
+
1. 每个 `nr_tocuser` 记录对应一个 `mdm_mycuser` 记录
|
|
80
|
+
2. `mdm_mycuser` 记录不一定有对应的 `nr_tocuser` 记录(未认证用户)
|
|
81
|
+
3. 这是历史遗留的表结构设计,需要理解并正确使用
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## 二、用户身份体系
|
|
86
|
+
|
|
87
|
+
### 2.1 身份类型
|
|
88
|
+
|
|
89
|
+
系统支持以下四种C端用户身份类型:
|
|
90
|
+
|
|
91
|
+
| 身份类型 | 认证状态 | 说明 | 使用场景 |
|
|
92
|
+
|---------|---------|------|---------|
|
|
93
|
+
| **游客** | 未认证 | 仅登录小程序,未进行手机号认证 | 浏览公开信息、查看基础内容 |
|
|
94
|
+
| **管理员** | 已认证 | 通过手机号认证,匹配为管理员身份 | 管理功能、审批操作 |
|
|
95
|
+
| **业务代理人** | 已认证 | 通过手机号认证,匹配为业务代理人身份 | 代理业务操作、客户服务 |
|
|
96
|
+
| **企业员工** | 已认证 | 通过手机号认证,匹配为企业员工身份 | 企业内部业务操作 |
|
|
97
|
+
|
|
98
|
+
### 2.2 身份识别流程
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
用户登录小程序
|
|
102
|
+
↓
|
|
103
|
+
创建 mdm_mycuser 记录
|
|
104
|
+
↓
|
|
105
|
+
授权手机号?
|
|
106
|
+
├─ 否 → 游客身份(只有 mdm_mycuser 记录)
|
|
107
|
+
└─ 是 → 手机号实名认证
|
|
108
|
+
↓
|
|
109
|
+
手机号匹配系统基础数据
|
|
110
|
+
↓
|
|
111
|
+
创建 nr_tocuser 记录
|
|
112
|
+
↓
|
|
113
|
+
分配对应身份(管理员/业务代理人/企业员工)
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### 2.3 认证机制
|
|
117
|
+
|
|
118
|
+
**认证方式**:
|
|
119
|
+
- 用户授权手机号
|
|
120
|
+
- 手机号与系统基础数据的客户进行匹配
|
|
121
|
+
- 匹配逻辑由认证服务统一处理(具体匹配规则由业务层定义)
|
|
122
|
+
|
|
123
|
+
**认证状态判断**:
|
|
124
|
+
```java
|
|
125
|
+
// 判断用户是否已认证
|
|
126
|
+
boolean isAuthenticated = nr_tocuser 记录存在;
|
|
127
|
+
|
|
128
|
+
// 判断用户身份类型
|
|
129
|
+
if (nr_tocuser.身份类型 == "管理员") {
|
|
130
|
+
// 管理员权限
|
|
131
|
+
} else if (nr_tocuser.身份类型 == "业务代理人") {
|
|
132
|
+
// 业务代理人权限
|
|
133
|
+
} else if (nr_tocuser.身份类型 == "企业员工") {
|
|
134
|
+
// 企业员工权限
|
|
135
|
+
} else {
|
|
136
|
+
// 游客权限(仅有 mdm_mycuser 记录)
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## 三、数据关联规范
|
|
143
|
+
|
|
144
|
+
### 3.1 选择关联表的原则
|
|
145
|
+
|
|
146
|
+
根据用户的认证状态选择合适的表进行业务数据关联:
|
|
147
|
+
|
|
148
|
+
#### 规则一:已认证用户 → 使用 nr_tocuser
|
|
149
|
+
|
|
150
|
+
**适用场景**:
|
|
151
|
+
- 需要身份验证的业务操作
|
|
152
|
+
- 需要权限控制的功能
|
|
153
|
+
- 门户业务数据的用户关联
|
|
154
|
+
|
|
155
|
+
#### 规则二:未认证用户 → 使用 mdm_mycuser
|
|
156
|
+
|
|
157
|
+
**适用场景**:
|
|
158
|
+
- 游客可访问的功能
|
|
159
|
+
- 不需要身份验证的业务场景
|
|
160
|
+
- 用户行为追踪
|
|
161
|
+
|
|
162
|
+
#### 规则三:混合场景 → 同时支持两种关联
|
|
163
|
+
|
|
164
|
+
**适用场景**:
|
|
165
|
+
- 业务数据需要支持游客和已认证用户
|
|
166
|
+
- 用户从游客升级为认证用户后,数据需要保持连续性
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
### 3.2 实体字段命名规范
|
|
171
|
+
|
|
172
|
+
**关联字段命名**:
|
|
173
|
+
|
|
174
|
+
| 关联表 | 字段名称 | 字段类型 | 说明 |
|
|
175
|
+
|-------|---------------|---------|------|
|
|
176
|
+
| `mdm_mycuser` | `cuserId` | UUID(唯一标识) | 关联C端用户中心用户ID |
|
|
177
|
+
| `mdm_mycuser` | `cuserName` | String(单行文本,长度128) | 冗余字段:用户名称 |
|
|
178
|
+
| `nr_tocuser` | `tocuserId` | UUID(唯一标识) | 关联门户用户ID |
|
|
179
|
+
| `nr_tocuser` | `tocuserName` | String(单行文本,长度128) | 冗余字段:用户名称 |
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## 四、常见问题
|
|
184
|
+
|
|
185
|
+
### Q1: 什么时候使用 mdm_mycuser,什么时候使用 nr_tocuser?
|
|
186
|
+
|
|
187
|
+
**回答**:
|
|
188
|
+
- **mdm_mycuser**:
|
|
189
|
+
- 未认证用户(游客)的业务关联
|
|
190
|
+
- 需要追踪所有用户(包括游客)的场景
|
|
191
|
+
- 用户基础信息的存储
|
|
192
|
+
|
|
193
|
+
- **nr_tocuser**:
|
|
194
|
+
- 已认证用户的业务关联(推荐)
|
|
195
|
+
- 需要身份验证的业务场景
|
|
196
|
+
- 需要权限控制的功能
|
|
197
|
+
|
|
198
|
+
**判断标准**:看业务是否需要用户认证,需要认证就用 nr_tocuser,不需要认证就用 mdm_mycuser。
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
### Q2: 为什么有两个用户表?
|
|
203
|
+
|
|
204
|
+
**回答**:
|
|
205
|
+
这是历史遗留原因造成的设计。最初系统只有 `mdm_mycuser`(C端用户中心),后来门户系统独立发展,创建了 `nr_tocuser` 来存储门户业务相关的用户信息。虽然存在冗余,但两者有明确的职责划分:
|
|
206
|
+
- `mdm_mycuser`:用户中心的核心表,存储用户基础信息
|
|
207
|
+
- `nr_tocuser`:门户业务的扩展表,存储认证和身份信息
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
### Q5: C端用户的身份是如何匹配的?
|
|
211
|
+
|
|
212
|
+
**回答**:
|
|
213
|
+
用户通过手机号授权后,系统会执行以下匹配逻辑:
|
|
214
|
+
1. 获取用户授权的手机号
|
|
215
|
+
2. 将手机号与系统基础数据中的客户信息进行匹配
|
|
216
|
+
3. 根据匹配结果分配相应的身份类型(管理员/业务代理人/企业员工)
|
|
217
|
+
4. 创建 `nr_tocuser` 记录,存储身份信息
|
|
218
|
+
|
|
219
|
+
**注意**:具体的匹配规则由业务层定义,不同的业务系统可能有不同的匹配逻辑。本规范只说明匹配机制的存在,不涉及具体匹配规则的实现细节。
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## 五、检查清单
|
|
224
|
+
|
|
225
|
+
在开发涉及C端用户的功能时,请确认:
|
|
226
|
+
|
|
227
|
+
- [ ] 明确业务场景是否需要用户认证
|
|
228
|
+
- [ ] 选择了正确的用户表进行关联(mdm_mycuser 或 nr_tocuser)
|
|
229
|
+
- [ ] 实体字段命名符合规范(cuserId / tocuserId)
|
|
230
|
+
- [ ] API 添加了正确的权限注解(@IdentityUserPermission())
|
|
231
|
+
- [ ] 添加了用户认证状态的判断逻辑
|
|
232
|
+
- [ ] 考虑了不同身份类型的权限差异
|
|
233
|
+
- [ ] 添加了必要的日志记录
|
|
234
|
+
- [ ] 处理了用户不存在或未认证的异常情况
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
**文档版本**:v1.0
|
|
238
|
+
**最后更新**:2026-02-05
|
|
239
|
+
**维护人**:开发团队
|
|
240
|
+
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
description:
|
|
3
|
+
globs:
|
|
4
|
+
alwaysApply: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 代码质量
|
|
8
|
+
- **单一职责**:每个类和方法只负责一个功能
|
|
9
|
+
- **开闭原则**:对扩展开放,对修改关闭
|
|
10
|
+
- **依赖倒置**:依赖抽象而不是具体实现
|
|
11
|
+
- **接口隔离**:使用小而专一的接口
|
|
12
|
+
- **代码复用**:提取公共逻辑,避免重复代码
|
|
13
|
+
|
|
14
|
+
## 性能优化
|
|
15
|
+
- **算法复杂度**:选择合适的算法和数据结构
|
|
16
|
+
- **缓存策略**:合理使用缓存减少重复计算
|
|
17
|
+
- **懒加载**:对于昂贵的操作使用懒加载
|
|
18
|
+
- **批量处理**:批量处理数据库操作和网络请求
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## 编码规范
|
|
22
|
+
- **命名规范**:类名、方法名、变量名清晰表达意图
|
|
23
|
+
- **代码结构**:合理的包结构和类层次
|
|
24
|
+
- **注释规范**:必要的类和方法注释
|
|
25
|
+
- **代码复用**:避免重复代码,提取公共方法
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
## 设计原则
|
|
29
|
+
- **SOLID 原则**:单一职责、开闭原则等
|
|
30
|
+
- **DRY 原则**:不重复自己
|
|
31
|
+
- **KISS 原则**:保持简单
|
|
32
|
+
- **YAGNI 原则**:你不会需要它
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
## 重构策略
|
|
36
|
+
- **持续重构**:小步快跑,持续改进
|
|
37
|
+
- **测试保护**:重构前确保测试覆盖
|
|
38
|
+
- **重构时机**:新功能开发时同步重构
|
|
39
|
+
- **技术债务**:定期评估和偿还技术债务
|