Files
huang a30b3036bb
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 6m10s
feat(iot-card-import): 为导入任务接口添加平台用户权限控制
- 在 Import/List/GetByID 接口添加用户类型校验
- 仅超级管理员和平台用户可访问
- 同步更新 OpenAPI 路由描述
- 补充集成测试覆盖权限拒绝场景
2026-02-02 10:25:03 +08:00

1.1 KiB
Raw Blame History

1. 权限校验收敛IoT 卡导入任务)

  • 1.1 在 internal/handler/admin/iot_card_import.goImport/List/GetByID 增加用户类型校验:仅 UserTypeSuperAdmin/UserTypePlatform 允许访问,其余返回 CodeForbidden
  • 1.2 校验错误消息文案与设备导入保持同风格(中文、明确动作),并确认不会泄露底层错误细节

2. 路由描述与文档一致性

  • 2.1 在 internal/routes/iot_card.goPOST /iot-cards/importGET /iot-cards/import-tasksGET /iot-cards/import-tasks/:id 补充 Description: "仅平台用户可操作。"

3. 测试补齐

  • 3.1 在集成测试中新增用例:非平台用户(至少覆盖代理账号)访问上述 3 个接口应返回 403Forbidden
  • 3.2 运行并通过相关测试:go test -v ./tests/integration/...(如存在既有失败,需明确区分是否由本变更引入)

4. 本地验证

  • 4.1 对修改过的 Go 文件执行 lsp_diagnostics 确保无新增错误/告警
  • 4.2 运行 go test ./... 做一次全量回归验证(如耗时可接受)