# 平台账号扩展功能使用指南 本文档介绍平台账号(PlatformAccount)模型的扩展字段和相关API的使用方法。 ## 新增字段说明 平台账号模型新增了以下字段: | 字段名称 | 类型 | 说明 | |---------|------|------| | tags | 字符串 | 账号标签,以逗号分隔的标签列表 | | profile_image | URL | 账号头像URL | | last_posting | 日期时间 | 最后发布内容的时间 | ## API接口使用 ### 1. 创建平台账号 在创建平台账号时,可以同时设置标签、头像和最后发布时间。 **请求URL**: `POST /api/operation/platforms/` **请求参数**: ```json { "operator": 1, "platform_name": "youtube", "account_name": "test_channel", "account_id": "UC12345", "status": "active", "followers_count": 1000, "account_url": "https://youtube.com/test_channel", "description": "测试频道描述", "tags": "科技,教育,AI", "profile_image": "https://example.com/profile.jpg", "last_posting": "2023-09-01T10:00:00Z" } ``` **成功响应**: ```json { "code": 200, "message": "平台账号创建成功,并已添加到知识库", "data": { "id": 1, "operator": 1, "operator_name": "测试运营", "platform_name": "youtube", "account_name": "test_channel", "account_id": "UC12345", "status": "active", "followers_count": 1000, "account_url": "https://youtube.com/test_channel", "description": "测试频道描述", "tags": "科技,教育,AI", "profile_image": "https://example.com/profile.jpg", "last_posting": "2023-09-01T10:00:00Z", "created_at": "2023-09-01T10:00:00Z", "updated_at": "2023-09-01T10:00:00Z", "last_login": null } } ``` ### 2. 更新平台账号资料 除了使用标准的PUT/PATCH方法更新平台账号外,还提供了一个专门用于更新标签、头像和最后发布时间的接口。 **请求URL**: `POST /api/operation/platforms/{id}/update_profile/` **请求参数**: ```json { "tags": "科技,编程,AI", "profile_image": "https://example.com/new_profile.jpg", "last_posting": "2023-09-10T15:30:00Z" } ``` **成功响应**: ```json { "code": 200, "message": "平台账号资料更新成功", "data": { "id": 1, "operator": 1, "operator_name": "测试运营", "platform_name": "youtube", "account_name": "test_channel", "account_id": "UC12345", "status": "active", "followers_count": 1000, "account_url": "https://youtube.com/test_channel", "description": "测试频道描述", "tags": "科技,编程,AI", "profile_image": "https://example.com/new_profile.jpg", "last_posting": "2023-09-10T15:30:00Z", "created_at": "2023-09-01T10:00:00Z", "updated_at": "2023-09-10T15:35:00Z", "last_login": null } } ``` ### 3. 获取平台账号详情 获取平台账号详情时,也会返回标签、头像和最后发布时间信息。 **请求URL**: `GET /api/operation/platforms/{id}/` **成功响应**: ```json { "code": 200, "message": "获取平台账号详情成功", "data": { "id": 1, "operator": 1, "operator_name": "测试运营", "platform_name": "youtube", "account_name": "test_channel", "account_id": "UC12345", "status": "active", "followers_count": 1000, "account_url": "https://youtube.com/test_channel", "description": "测试频道描述", "tags": "科技,编程,AI", "profile_image": "https://example.com/new_profile.jpg", "last_posting": "2023-09-10T15:30:00Z", "created_at": "2023-09-01T10:00:00Z", "updated_at": "2023-09-10T15:35:00Z", "last_login": null } } ``` ## 在Apifox中使用的提示 1. **创建平台账号**: - 使用`POST /api/operation/platforms/`端点 - 根据需要添加标签、头像和最后发布时间字段 - 确保operator字段设置为有效的运营账号ID 2. **更新平台账号资料**: - 可以使用标准的`PUT /api/operation/platforms/{id}/`端点更新所有字段 - 或者使用专门的`POST /api/operation/platforms/{id}/update_profile/`端点仅更新资料相关字段 - 日期时间格式应为ISO 8601格式(如`2023-09-10T15:30:00Z`) 3. **获取平台账号详情**: - 使用`GET /api/operation/platforms/{id}/`端点 - 响应中将包含所有字段,包括新增的标签、头像和最后发布时间