Files
junhong_cmp_fiber/openspec/changes/archive/2026-01-29-add-role-handler-validation/tasks.md
huang b02175271a
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 5m39s
feat: 实现企业设备授权功能并归档 OpenSpec 变更
- 新增企业设备授权模块(Model、DTO、Service、Handler、Store)
- 实现设备授权的创建、查询、更新、删除等完整业务逻辑
- 添加企业卡授权与设备授权的关联关系
- 新增 2 个数据库迁移脚本
- 同步 OpenSpec delta specs 到 main specs
- 归档 add-enterprise-device-authorization 变更
- 更新 API 文档和路由配置
- 新增完整的集成测试和单元测试覆盖
2026-01-29 13:18:49 +08:00

31 lines
1.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 实现任务
## 1. 修改 RoleHandler 结构
- [x] 1.1 在 RoleHandler 结构体中添加 `validator *validator.Validate` 字段
- [x] 1.2 修改 NewRoleHandler 构造函数,接收 validator 参数
- [x] 1.3 导入 `github.com/go-playground/validator/v10`
## 2. 添加验证逻辑
- [x] 2.1 Create 方法BodyParser 后调用 validator.Struct(&req)
- [x] 2.2 Update 方法BodyParser 后调用 validator.Struct(&req)
- [x] 2.3 AssignPermissions 方法BodyParser 后调用 validator.Struct(&req)
- [x] 2.4 UpdateStatus 方法BodyParser 后调用 validator.Struct(&req)
## 3. 更新 Bootstrap
- [x] 3.1 修改 internal/bootstrap/handlers.go 中的 initHandlers 函数
- [x] 3.2 传递 validate 参数给 NewRoleHandler`admin.NewRoleHandler(svc.Role, validate)`
## 4. 取消测试跳过
- [x] 4.1 删除 tests/integration/role_test.go:51-62 的 TODO 跳过代码
- [x] 4.2 取消注释被跳过的测试代码
## 5. 验证
- [x] 5.1 运行 `go test -v ./tests/integration/role_test.go` 确保测试通过
- [x] 5.2 运行 LSP diagnostics 检查 internal/handler/admin/role.go
- [x] 5.3 确认没有编译错误