70 lines
1.3 KiB
Markdown
70 lines
1.3 KiB
Markdown
# 涂鸦丫后台管理系统 - API服务
|
|
|
|
## 技术栈
|
|
|
|
- NestJS 11
|
|
- TypeORM
|
|
- PostgreSQL
|
|
- class-validator
|
|
- class-transformer
|
|
|
|
## 环境配置
|
|
|
|
1. 复制 `.env.example` 为 `.env`
|
|
2. 配置数据库连接信息:
|
|
|
|
```env
|
|
PORT=3301
|
|
DB_HOST=localhost
|
|
DB_PORT=5432
|
|
DB_USERNAME=postgres
|
|
DB_PASSWORD=postgres
|
|
DB_DATABASE=doodle_db
|
|
CORS_ORIGIN=http://localhost:3300
|
|
```
|
|
|
|
## 安装依赖
|
|
|
|
```bash
|
|
npm install
|
|
```
|
|
|
|
## 运行
|
|
|
|
### 开发模式
|
|
|
|
```bash
|
|
npm run start:dev
|
|
```
|
|
|
|
### 生产模式
|
|
|
|
```bash
|
|
npm run build
|
|
npm run start:prod
|
|
```
|
|
|
|
## 数据库迁移
|
|
|
|
项目使用 TypeORM 的 `synchronize` 选项(仅开发环境),生产环境应使用迁移。
|
|
|
|
## API 接口
|
|
|
|
### 汉字管理
|
|
|
|
- `GET /words` - 获取汉字列表(分页,每页9个)
|
|
- `GET /words/:id` - 获取汉字详情
|
|
- `PATCH /words/:id` - 更新汉字信息
|
|
- `GET /words/:id/images` - 获取汉字图片列表
|
|
- `PATCH /words/:id/images/sort` - 更新图片排序
|
|
- `DELETE /words/:id/images/:imageId` - 删除图片
|
|
- `GET /words/:id/sentences` - 获取汉字句子列表
|
|
- `POST /words/:id/sentences` - 添加句子
|
|
- `DELETE /words/:id/sentences/:sentenceId` - 删除句子
|
|
|
|
## 注意事项
|
|
|
|
- 汉字、拼音、SVG数据通过其他方式导入,不支持在后台新建
|
|
- 图片最多支持4张
|
|
- 列表按年级升序排序(低年级在前)
|