Files
emall-api/README.md
2025-10-17 16:21:14 +08:00

138 lines
3.2 KiB
Markdown
Raw Permalink 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.

# FutureMail API 项目
这是一个基于.NET Core 9.0的未来邮件系统API支持创建定时邮件、时光胶囊、AI辅助等功能。
## 功能特性
- 用户认证与授权
- 创建和管理未来邮件
- 时光胶囊可视化
- AI写作辅助和情感分析
- 个人时间线和统计数据
- 文件上传功能
## 技术栈
- .NET Core 9.0
- Entity Framework Core (Code First)
- MySQL数据库
- JWT身份验证
- Swagger API文档
- Quartz.NET任务调度
## 快速开始
### 1. 运行项目
最简单的方法是使用提供的启动脚本:
```bash
start_project.bat
```
这将:
- 启动API服务器
- 打开Swagger文档页面
- 打开API测试页面
### 2. 手动运行
如果需要手动运行,请按照以下步骤:
1. 启动API服务器
```bash
cd FutureMailAPI
dotnet run
```
2. 访问Swagger文档
```
http://localhost:5003/swagger
```
3. 使用API测试页面
```
打开 api_test.html 文件
```
## API文档
详细的API文档请参考
- [API接口文档详细说明.md](./API接口文档详细说明.md)
- Swagger交互式文档http://localhost:5003/swagger
## 主要接口
### 认证相关
- `POST /api/v1/auth/register` - 用户注册
- `POST /api/v1/auth/login` - 用户登录
- `POST /api/v1/auth/refresh` - 刷新令牌
- `POST /api/v1/auth/logout` - 用户登出
### 邮件管理
- `POST /api/v1/mails/create` - 创建邮件
- `GET /api/v1/mails` - 获取邮件列表
- `GET /api/v1/mails/{mailId}` - 获取邮件详情
- `PUT /api/v1/mails/{mailId}` - 更新邮件
- `DELETE /api/v1/mails/{mailId}` - 删除邮件
- `POST /api/v1/mails/{mailId}/revoke` - 撤销发送
### 时光胶囊
- `GET /api/v1/capsules` - 获取胶囊视图
- `PUT /api/v1/capsules/{capsuleId}/style` - 更新胶囊样式
### AI助手
- `POST /api/v1/ai/writing-assistant` - AI写作辅助
- `POST /api/v1/ai/sentiment-analysis` - 情感分析
### 个人空间
- `GET /api/v1/timeline` - 获取时间线
- `GET /api/v1/statistics` - 获取统计数据
- `GET /api/v1/user/profile` - 获取用户信息
### 文件上传
- `POST /api/v1/upload/attachment` - 上传附件
- `POST /api/v1/upload/avatar` - 上传头像
## 数据库配置
数据库连接字符串配置在 `appsettings.json` 文件中:
```json
{
"ConnectionStrings": {
"DefaultConnection": "Server=localhost;Database=FutureMailDB;User=root;Password=yourpassword;"
}
}
```
请根据您的MySQL配置修改连接字符串。
## 项目结构
```
FutureMailAPI/
├── Controllers/ # API控制器
├── DTOs/ # 数据传输对象
├── Data/ # 数据模型和上下文
├── Helpers/ # 辅助类
├── Middleware/ # 中间件
├── Services/ # 服务类
├── Program.cs # 应用程序入口点
└── appsettings.json # 配置文件
```
## 测试
项目包含一个完整的API测试页面 `api_test.html`可以测试所有主要API接口。
## 注意事项
1. 确保MySQL服务器已安装并运行
2. 首次运行时EF Core会自动创建数据库和表
3. JWT密钥应在生产环境中更改为安全的值
4. 文件上传功能需要配置适当的存储路径
## 许可证
本项目仅供学习和演示使用。