# 实现任务清单 **Change ID**: `add-customer-account-management` --- ## 阶段 1: DTO 定义 (20 分钟) ### Task 1.1: 创建 DTO 文件 **文件**: `internal/model/customer_account_dto.go` **实现内容**: - [x] 1.1.1 `CustomerAccountListReq` 列表请求(分页、筛选条件) - [x] 1.1.2 `CustomerAccountItem` 列表响应项 - [x] 1.1.3 `CreateCustomerAccountReq` 新增请求 - [x] 1.1.4 `UpdateCustomerAccountReq` 编辑请求 - [x] 1.1.5 `UpdateCustomerAccountPasswordReq` 密码修改请求 - [x] 1.1.6 `UpdateCustomerAccountStatusReq` 状态修改请求 - [x] 1.1.7 `CustomerAccountPageResult` 分页响应 **验证**: - [x] 字段完整 - [x] 验证标签正确 --- ## 阶段 2: Service 层 (1 小时) ### Task 2.1: 创建 CustomerAccount Service **文件**: `internal/service/customer_account/service.go` **实现内容**: - [x] 2.1.1 `List(ctx, req)` - 查询账号列表 - [x] 2.1.2 `Create(ctx, req)` - 新增代理商账号 - [x] 2.1.3 `Update(ctx, id, req)` - 编辑账号 - [x] 2.1.4 `UpdatePassword(ctx, id, password)` - 修改密码 - [x] 2.1.5 `UpdateStatus(ctx, id, status)` - 更新状态 **业务逻辑**: - [x] 2.1.6 查询时过滤 `user_type IN (3, 4)` - [x] 2.1.7 新增时只允许 UserType=3 - [x] 2.1.8 权限校验(账号所属店铺/企业在可见范围内) **验证**: - [x] 业务逻辑正确 - [x] 数据权限正确 --- ## 阶段 3: Handler 层 (45 分钟) ### Task 3.1: 创建 Handler **文件**: `internal/handler/admin/customer_account.go` **实现内容**: - [x] 3.1.1 `List` - GET /api/admin/customer-accounts - [x] 3.1.2 `Create` - POST /api/admin/customer-accounts - [x] 3.1.3 `Update` - PUT /api/admin/customer-accounts/:id - [x] 3.1.4 `UpdatePassword` - PUT /api/admin/customer-accounts/:id/password - [x] 3.1.5 `UpdateStatus` - PUT /api/admin/customer-accounts/:id/status **验证**: - [x] 参数校验正确 --- ### Task 3.2: 路由注册 **文件**: `internal/routes/customer_account.go` **实现内容**: - [x] 3.2.1 注册五个 API 路由 --- ### Task 3.3: Bootstrap 注册 **实现内容**: - [x] 3.3.1 `internal/bootstrap/services.go` - 添加 CustomerAccount Service - [x] 3.3.2 `internal/bootstrap/handlers.go` - 添加 CustomerAccount Handler - [x] 3.3.3 `internal/bootstrap/types.go` - 添加 CustomerAccount Handler 类型 - [x] 3.3.4 `internal/routes/admin.go` - 注册 CustomerAccount 路由 --- ## 阶段 4: 测试 (45 分钟) ### Task 4.1: 功能测试 **实现内容**: - [x] 4.1.1 列表查询测试 - [x] 4.1.2 新增代理商账号测试 - [x] 4.1.3 编辑账号测试 - [x] 4.1.4 密码修改测试 - [x] 4.1.5 状态修改测试 - [x] 4.1.6 数据权限测试 --- ## 完成标准 - [x] 所有 DTO 定义完成 - [x] Service 层业务逻辑完成 - [x] Handler 层 API 实现完成 - [x] 只能新增代理商账号 - [x] 数据权限正确 - [x] 编译通过 - [x] 功能测试通过