MCPcopy
hub / github.com/HisMax/RedInk / create_history

Function create_history

backend/routes/history_routes.py:30–83  ·  view source on GitHub ↗

创建历史记录(草稿) 在用户生成大纲后立即调用,创建一个草稿状态的历史记录。 初始状态为 draft,表示大纲已创建但尚未开始生成图片。 请求体: - topic: 主题标题(必填) - outline: 大纲内容(必填),包含 pages 数组等 - task_id: 关联的任务 ID(可选) 返回: - success: 是否成功 - record_id: 新创建的记录 ID(UUID 格式) 状态流转:

()

Source from the content-addressed store, hash-verified

28
29 @history_bp.route('/history', methods=['POST'])
30 def create_history():
31 """
32 创建历史记录(草稿)
33
34 在用户生成大纲后立即调用,创建一个草稿状态的历史记录。
35 初始状态为 draft,表示大纲已创建但尚未开始生成图片。
36
37 请求体:
38 - topic: 主题标题(必填)
39 - outline: 大纲内容(必填),包含 pages 数组等
40 - task_id: 关联的任务 ID(可选)
41
42 返回:
43 - success: 是否成功
44 - record_id: 新创建的记录 ID(UUID 格式)
45
46 状态流转:
47 新建 -> draft(草稿状态)
48
49 示例请求:
50 {
51 "topic": "小猫的冒险",
52 "outline": {
53 "title": "小猫的冒险",
54 "pages": [
55 {"page": 1, "content": "..."},
56 {"page": 2, "content": "..."}
57 ]
58 },
59 "task_id": "abc123"
60 }
61 """
62 try:
63 data = request.get_json()
64 topic = data.get('topic')
65 outline = data.get('outline')
66 task_id = data.get('task_id')
67
68 if not topic or not outline:
69 return api_error_response(
70 validation_error("topic 和 outline 不能为空", "请提供主题和大纲内容。"),
71 context={"endpoint": "/api/history"},
72 )
73
74 history_service = get_history_service()
75 record_id = history_service.create_record(topic, outline, task_id)
76
77 return jsonify({
78 "success": True,
79 "record_id": record_id
80 }), 200
81
82 except Exception as e:
83 return api_error_response(e, context={"endpoint": "/api/history"})
84
85 @history_bp.route('/history', methods=['GET'])
86 def list_history():

Callers

nothing calls this directly

Calls 5

get_history_serviceFunction · 0.90
api_error_responseFunction · 0.85
validation_errorFunction · 0.85
getMethod · 0.80
create_recordMethod · 0.80

Tested by

no test coverage detected