HaniBlindBox/.kiro/specs/api-infrastructure/tasks.md
2026-01-02 15:46:56 +08:00

108 lines
3.5 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.

# Implementation Plan: API 基础架构搭建
## Overview
本实现计划将 HoneyBox .NET 8 Web API 项目基础架构分解为可执行的任务,按顺序完成四层项目结构搭建、配置和验证。
## Tasks
- [x] 1. 创建解决方案和项目结构
- [x] 1.1 创建解决方案和四个项目Api、Model、Core、Infrastructure
- 使用 dotnet CLI 创建解决方案
- 创建 HoneyBox.Api (webapi)
- 创建 HoneyBox.Model (classlib)
- 创建 HoneyBox.Core (classlib)
- 创建 HoneyBox.Infrastructure (classlib)
- _Requirements: 1.1_
- [x] 1.2 配置项目引用关系
- Api → Core, Model
- Core → Model, Infrastructure
- _Requirements: 1.2, 1.3, 1.4, 1.5_
- [x] 1.3 配置各项目 NuGet 包
- Model: EF Core, EF Core SqlServer
- Core: Mapster
- Infrastructure: Redis, Autofac
- Api: Autofac.Extensions, Serilog, Swagger, JWT
- _Requirements: 2.1, 3.1, 4.1_
- [x] 2. 配置 HoneyBox.Model 数据模型层
- [x] 2.1 创建 Base 目录和 ApiResponse 基类
- 创建 ApiResponse 类
- 创建 ApiResponse<T> 泛型类
- _Requirements: 2.4_
- [x] 2.2 创建 Data 目录和 DbContext
- 使用 EF Core 脚手架从数据库生成实体
- 配置 HoneyBoxDbContext
- _Requirements: 2.2, 2.3_
- [x] 2.3 创建 Models 目录结构
- 创建 Common.cs 通用模型
- 创建按控制器分类的子目录User、Goods、Order 等)
- _Requirements: 2.5_
- [x] 3. 配置 HoneyBox.Infrastructure 基础设施层
- [x] 3.1 创建 Cache 目录和缓存服务
- 创建 ICacheService 接口
- 创建 RedisCacheService 实现
- _Requirements: 3.1, 3.3, 3.4_
- [x] 3.2 创建 Modules 目录和 Autofac 模块
- 创建 ServiceModule 服务注册模块
- 创建 InfrastructureModule 基础设施注册模块
- _Requirements: 3.2_
- [x] 3.3 创建 External 目录结构
- 创建 WeChat、Payment、Sms 子目录(预留)
- _Requirements: 3.1_
- [x] 4. 配置 HoneyBox.Core 核心业务层
- [x] 4.1 创建 Mappings 目录和映射配置
- 创建 MappingConfig 类
- _Requirements: 4.2_
- [x] 4.2 创建 Services 和 Interfaces 目录
- 创建目录结构
- _Requirements: 4.3_
- [x] 4.3 创建 Constants 目录
- 创建常量定义文件
- _Requirements: 4.4_
- [x] 5. 配置 HoneyBox.Api 入口层
- [x] 5.1 配置 appsettings.json
- 配置数据库连接字符串
- 配置 Redis 连接字符串
- 配置 Serilog 日志
- _Requirements: 2.6, 3.5, 5.2_
- [x] 5.2 配置 Program.cs 主程序
- 配置 Autofac 依赖注入
- 配置 DbContext
- 配置 Mapster
- 配置 Serilog
- 配置 Swagger
- 配置 CORS
- _Requirements: 5.1, 5.2, 5.3, 5.5_
- [x] 5.3 创建 Filters 目录和全局异常处理
- 创建 GlobalExceptionFilter
- _Requirements: 5.4_
- [x] 6. 创建健康检查接口
- [x] 6.1 创建 HealthController
- 实现 /api/health 接口
- 检查数据库连接状态
- 检查 Redis 连接状态
- 返回统一 ApiResponse 格式
- _Requirements: 6.1, 6.2, 6.3, 6.4, 6.5_
- [x] 7. 验证和测试
- [x] 7.1 编译验证
- 运行 dotnet build 确保编译通过
- _Requirements: 1.6_
- [x] 7.2 运行验证
- 启动应用
- 访问 Swagger 文档
- 调用健康检查接口
- 检查日志输出
- _Requirements: 5.6, 6.1_
## Notes
- 任务按顺序执行,后续任务依赖前置任务完成
- 每个任务完成后进行编译验证
- 最终通过健康检查接口验证整体架构