# 内容API

内容API位于 `backend/app/api/content.py`

## 端点列表

| 方法 | 路径 | 说明 |
|------|------|------|
| GET | /api/v1/contents | 获取内容列表 |
| POST | /api/v1/contents | 创建内容 |
| GET | /api/v1/contents/{id} | 获取内容详情 |
| PUT | /api/v1/contents/{id} | 更新内容 |
| DELETE | /api/v1/contents/{id} | 删除内容 |
| POST | /api/v1/contents/generate | 生成内容 |
| POST | /api/v1/contents/{id}/optimize | 优化内容 |

## 获取内容列表

```
GET /api/v1/contents
```

### 查询参数

| 参数 | 类型 | 说明 |
|------|------|------|
| page | int | 页码 |
| page_size | int | 每页数量 |
| brand_id | uuid | 品牌ID |
| content_type | string | 内容类型 |
| status | string | 状态 |

### 响应

```json
{
  "success": true,
  "data": {
    "items": [
      {
        "id": "uuid",
        "title": "内容标题",
        "content_type": "article",
        "status": "draft",
        "brand_id": "uuid",
        "created_at": "2024-01-01T00:00:00Z"
      }
    ],
    "total": 100,
    "page": 1,
    "page_size": 20
  }
}
```

## 创建内容

```
POST /api/v1/contents
```

### 请求体

```json
{
  "brand_id": "uuid",
  "title": "内容标题",
  "content_type": "article",
  "body": "内容正文",
  "template_id": "uuid",
  "keywords": ["关键词1", "关键词2"]
}
```

## 生成内容

```
POST /api/v1/contents/generate
```

### 请求体

```json
{
  "brand_id": "uuid",
  "content_type": "article",
  "template_id": "uuid",
  "keywords": ["关键词1", "关键词2"],
  "requirements": "内容要求描述"
}
```

### 响应

```json
{
  "success": true,
  "data": {
    "content_id": "uuid",
    "title": "生成的内容标题",
    "body": "生成的正文内容",
    "status": "draft"
  }
}
```

## 优化内容

```
POST /api/v1/contents/{id}/optimize
```

### 请求体

```json
{
  "optimization_type": "seo",
  "keywords": ["新关键词"],
  "target_platform": "kimi"
}
```

### 响应

```json
{
  "success": true,
  "data": {
    "original_content": "原文",
    "optimized_content": "优化后内容",
    "changes": ["变更描述1", "变更描述2"]
  }
}
```
