|
|
@@ -14,30 +14,45 @@ Draft
|
|
|
3. 后端API支持邮箱为空
|
|
|
|
|
|
## Tasks / Subtasks
|
|
|
-- [ ] 修复平台管理前端表单默认值问题 (AC: 1, 2)
|
|
|
- - [ ] 修改allin-packages/platform-management-ui/src/components/PlatformManagement.tsx中的表单配置
|
|
|
- - [ ] 将contactEmail字段的默认值从`''`改为`undefined`
|
|
|
- - [ ] 验证contactEmail字段的FormLabel没有红色星号标记(非必填)
|
|
|
+- [x] 修复平台管理前端表单默认值问题 (AC: 1, 2)
|
|
|
+ - [x] 修改allin-packages/platform-management-ui/src/components/PlatformManagement.tsx中的表单配置
|
|
|
+ - [x] 将contactEmail字段的默认值从`''`改为`undefined`
|
|
|
+ - [x] 验证contactEmail字段的FormLabel没有红色星号标记(非必填)
|
|
|
- [ ] 测试表单提交时邮箱字段可为空(不填写)
|
|
|
- [ ] 测试表单提交时邮箱字段可为有效邮箱格式
|
|
|
- [ ] 测试表单提交时邮箱字段为无效格式应显示验证错误
|
|
|
-- [ ] 修改平台模块后端schema验证 (AC: 2, 3)
|
|
|
- - [ ] 修改allin-packages/platform-module/src/schemas/platform.schema.ts中的CreatePlatformSchema
|
|
|
- - [ ] 将contactEmail字段改为:`.optional().or(z.literal('')).transform(val => val === '' ? undefined : val)`
|
|
|
- - [ ] 保留.email()验证(如果填写,必须是有效邮箱格式)
|
|
|
- - [ ] 同样修改UpdatePlatformSchema中的contactEmail字段验证规则
|
|
|
- - [ ] 确保.openapi()描述保持不变
|
|
|
-- [ ] 验证数据库兼容性 (AC: 3)
|
|
|
- - [ ] 检查allin-packages/platform-module/src/entities/platform.entity.ts中contactEmail字段为nullable: true
|
|
|
+- [x] 修改平台模块后端schema验证 (AC: 2, 3)
|
|
|
+ - [x] 修改allin-packages/platform-module/src/schemas/platform.schema.ts中的CreatePlatformSchema
|
|
|
+ - [x] 将contactEmail字段改为包含中文错误提示和空字符串处理:
|
|
|
+ ```typescript
|
|
|
+ contactEmail: z.string({
|
|
|
+ error: '请输入联系邮箱'
|
|
|
+ }).email({
|
|
|
+ message: '请输入有效的邮箱地址'
|
|
|
+ }).max(100, {
|
|
|
+ message: '邮箱地址不能超过100个字符'
|
|
|
+ }).optional()
|
|
|
+ .or(z.literal('')) // 允许空字符串
|
|
|
+ .transform(val => val === '' ? undefined : val) // 将空字符串转为undefined
|
|
|
+ .openapi({
|
|
|
+ description: '联系邮箱',
|
|
|
+ example: 'zhangsan@example.com'
|
|
|
+ })
|
|
|
+ ```
|
|
|
+ - [x] 同样修改UpdatePlatformSchema中的contactEmail字段验证规则
|
|
|
+ - [x] 可选:为其他字段添加中文错误提示(如platformName必填验证)
|
|
|
+- [x] 验证数据库兼容性 (AC: 3)
|
|
|
+ - [x] 检查allin-packages/platform-module/src/entities/platform.entity.ts中contactEmail字段为nullable: true
|
|
|
- [ ] 验证现有数据可以正常读取和更新
|
|
|
- [ ] 编写单元测试 (AC: 1, 2, 3)
|
|
|
- [ ] 为平台schema添加测试,验证空字符串转换为undefined
|
|
|
- [ ] 为平台schema添加测试,验证有效邮箱格式通过验证
|
|
|
- - [ ] 为平台schema添加测试,验证无效邮箱格式显示错误
|
|
|
+ - [ ] 为平台schema添加测试,验证无效邮箱格式显示中文错误提示
|
|
|
+ - [ ] 为平台schema添加测试,验证超长邮箱地址显示中文长度错误提示
|
|
|
- [ ] 为平台schema添加测试,验证undefined通过验证(可选字段)
|
|
|
- [ ] 为平台管理表单添加测试,验证邮箱字段可为空的表单提交
|
|
|
- [ ] 为平台管理表单添加测试,验证邮箱字段为有效邮箱格式的表单提交
|
|
|
- - [ ] 为平台管理表单添加测试,验证邮箱字段为无效格式时显示验证错误
|
|
|
+ - [ ] 为平台管理表单添加测试,验证邮箱字段为无效格式时显示中文验证错误
|
|
|
- [ ] 添加集成测试验证端到端功能
|
|
|
- [ ] 执行回归测试 (AC: 3)
|
|
|
- [ ] 测试现有平台数据的显示和编辑功能
|
|
|
@@ -71,21 +86,28 @@ Draft
|
|
|
- 表单验证:使用CreatePlatformSchema和UpdatePlatformSchema进行验证
|
|
|
|
|
|
**平台schema现状**:
|
|
|
-- 创建DTO: `allin-packages/platform-module/src/schemas/platform.schema.ts:53` - `contactEmail`字段有`.email()`验证和`.optional()`
|
|
|
-- 更新DTO: `allin-packages/platform-module/src/schemas/platform.schema.ts:77` - `contactEmail`字段有`.email()`验证和`.optional()`
|
|
|
+- 创建DTO: `allin-packages/platform-module/src/schemas/platform.schema.ts:53` - `contactEmail`字段有`z.email('请输入有效的邮箱')`验证和`.optional()`
|
|
|
+- 更新DTO: `allin-packages/platform-module/src/schemas/platform.schema.ts:77` - `contactEmail`字段有`z.string().email()`验证和`.optional()`(缺少中文错误提示)
|
|
|
- 数据库实体: `allin-packages/platform-module/src/entities/platform.entity.ts:47` - `contactEmail`字段为`nullable: true`
|
|
|
|
|
|
**问题分析**:
|
|
|
当前schema中contactEmail字段有`.optional()`和`.email()`验证,这意味着:
|
|
|
1. 字段是可选的(可以是`undefined`)✅ 符合"非必要输入项"要求
|
|
|
2. 如果填写了,必须是有效的邮箱格式 ⚠️ 当前有.email()验证
|
|
|
+3. 创建DTO有中文错误提示`z.email('请输入有效的邮箱')` ✅
|
|
|
+4. 更新DTO缺少中文错误提示`z.string().email()` ❌ 需要添加
|
|
|
|
|
|
**关键问题发现**:
|
|
|
-前端表单默认值设置有问题:
|
|
|
-- 文件位置:`allin-packages/platform-management-ui/src/components/PlatformManagement.tsx:42`
|
|
|
-- 当前默认值:`contactEmail: ''`(空字符串)
|
|
|
-- 问题:空字符串`''`不是有效的邮箱格式,会导致Zod验证失败
|
|
|
-- 正确做法:默认值应该是`undefined`
|
|
|
+1. **前端表单默认值问题**:
|
|
|
+ - 文件位置:`allin-packages/platform-management-ui/src/components/PlatformManagement.tsx:42`
|
|
|
+ - 当前默认值:`contactEmail: ''`(空字符串)
|
|
|
+ - 问题:空字符串`''`不是有效的邮箱格式,会导致Zod验证失败
|
|
|
+ - 正确做法:默认值应该是`undefined`
|
|
|
+
|
|
|
+2. **schema中文错误提示不统一**:
|
|
|
+ - 创建DTO有中文错误提示
|
|
|
+ - 更新DTO缺少中文错误提示
|
|
|
+ - 需要统一添加完整的中文错误提示
|
|
|
|
|
|
**技术细节**:
|
|
|
- Zod schema:`.optional()`允许`undefined`,但不允许无效的邮箱格式
|
|
|
@@ -93,11 +115,21 @@ Draft
|
|
|
- 当前所有字段都设置为`''`,但只有`contactEmail`需要特殊处理,因为它是可选但需要邮箱验证的字段
|
|
|
|
|
|
**解决方案选项**:
|
|
|
-1. **推荐方案**:修改schema,使用`.or(z.literal(''))`允许空字符串,然后转换
|
|
|
+1. **推荐方案**:修改schema,使用`.or(z.literal(''))`允许空字符串,然后转换,并添加中文错误提示
|
|
|
```typescript
|
|
|
- contactEmail: z.string().email().max(100).optional()
|
|
|
+ contactEmail: z.string({
|
|
|
+ error: '请输入联系邮箱'
|
|
|
+ }).email({
|
|
|
+ message: '请输入有效的邮箱地址'
|
|
|
+ }).max(100, {
|
|
|
+ message: '邮箱地址不能超过100个字符'
|
|
|
+ }).optional()
|
|
|
.or(z.literal('')) // 允许空字符串
|
|
|
.transform(val => val === '' ? undefined : val) // 将空字符串转为undefined
|
|
|
+ .openapi({
|
|
|
+ description: '联系邮箱',
|
|
|
+ example: 'zhangsan@example.com'
|
|
|
+ })
|
|
|
```
|
|
|
2. **备选方案**:前端在提交前将空字符串转换为`undefined`
|
|
|
3. **简单方案**:只修改默认值为`undefined`,但用户清空输入框后还是`''`
|
|
|
@@ -109,9 +141,10 @@ Draft
|
|
|
|
|
|
根据故事"邮箱字段改为非必要输入项"的要求,需要:
|
|
|
1. 修改schema,允许空字符串并转换为`undefined`
|
|
|
-2. 可选:将前端表单默认值从`''`改为`undefined`
|
|
|
-3. 确保字段支持空值(不填写)
|
|
|
-4. 如果用户选择填写,验证邮箱格式
|
|
|
+2. 统一添加完整的中文错误提示(字符串、邮箱格式、长度限制)
|
|
|
+3. 可选:将前端表单默认值从`''`改为`undefined`
|
|
|
+4. 确保字段支持空值(不填写)
|
|
|
+5. 如果用户选择填写,验证邮箱格式并显示中文错误提示
|
|
|
|
|
|
### 文件位置参考
|
|
|
1. **平台管理组件**: `allin-packages/platform-management-ui/src/components/PlatformManagement.tsx`
|
|
|
@@ -138,11 +171,12 @@ Draft
|
|
|
1. schema验证:空字符串`''`转换为`undefined`通过验证
|
|
|
2. schema验证:`undefined`通过验证(可选字段)
|
|
|
3. schema验证:有效邮箱格式通过验证
|
|
|
-4. schema验证:无效邮箱格式显示验证错误
|
|
|
-5. 平台表单:验证提交时邮箱字段可为空(不填写)
|
|
|
-6. 平台表单:验证提交时邮箱字段可为有效邮箱格式
|
|
|
-7. 平台表单:验证提交时邮箱字段为无效格式应显示验证错误
|
|
|
-8. 数据兼容性:验证现有含邮箱数据的显示和编辑
|
|
|
+4. schema验证:无效邮箱格式显示中文错误提示"请输入有效的邮箱地址"
|
|
|
+5. schema验证:超长邮箱地址显示中文长度错误提示"邮箱地址不能超过100个字符"
|
|
|
+6. 平台表单:验证提交时邮箱字段可为空(不填写)
|
|
|
+7. 平台表单:验证提交时邮箱字段可为有效邮箱格式
|
|
|
+8. 平台表单:验证提交时邮箱字段为无效格式应显示中文验证错误
|
|
|
+9. 数据兼容性:验证现有含邮箱数据的显示和编辑
|
|
|
|
|
|
## Testing
|
|
|
### 测试标准
|