feat: 步骤6提交审核改用智能体执行
- 新增步骤6任务模板(config/agent_submit_template.txt) - 步骤6调用智能体hz4th_editor执行提交操作 - 智能体根据产品类别选择对应API接口提交数据 - 页面新增步骤6模板编辑面板,支持查看/编辑/保存/预览 - 修正步骤5标题为'填充字段'(去掉'并提交') - 新增API: GET/POST /api/process/submit-template
This commit is contained in:
@@ -338,3 +338,84 @@ def preview_fill_fields_template():
|
||||
except Exception as e:
|
||||
logger.error(f"预览填充字段模板失败: {e}")
|
||||
return jsonify({'success': False, 'error': str(e)}), 500
|
||||
|
||||
|
||||
# ===== 步骤6提交审核模板 API =====
|
||||
|
||||
SUBMIT_TEMPLATE_FILE = os.path.join(TEMPLATE_DIR, 'agent_submit_template.txt')
|
||||
|
||||
|
||||
@bp.route('/submit-template', methods=['GET'])
|
||||
def get_submit_template():
|
||||
"""获取步骤6提交审核任务文本模板"""
|
||||
try:
|
||||
if os.path.exists(SUBMIT_TEMPLATE_FILE):
|
||||
with open(SUBMIT_TEMPLATE_FILE, 'r', encoding='utf-8') as f:
|
||||
template = f.read()
|
||||
return jsonify({
|
||||
'success': True,
|
||||
'template': template
|
||||
})
|
||||
else:
|
||||
return jsonify({
|
||||
'success': False,
|
||||
'error': '模板文件不存在'
|
||||
}), 404
|
||||
except Exception as e:
|
||||
logger.error(f"获取提交模板失败: {e}")
|
||||
return jsonify({'success': False, 'error': str(e)}), 500
|
||||
|
||||
|
||||
@bp.route('/submit-template', methods=['POST'])
|
||||
def save_submit_template():
|
||||
"""保存步骤6提交审核任务文本模板"""
|
||||
try:
|
||||
data = request.get_json()
|
||||
template = data.get('template', '')
|
||||
|
||||
if not template:
|
||||
return jsonify({'success': False, 'error': '模板内容不能为空'}), 400
|
||||
|
||||
os.makedirs(TEMPLATE_DIR, exist_ok=True)
|
||||
with open(SUBMIT_TEMPLATE_FILE, 'w', encoding='utf-8') as f:
|
||||
f.write(template)
|
||||
|
||||
return jsonify({
|
||||
'success': True,
|
||||
'message': '模板已保存'
|
||||
})
|
||||
except Exception as e:
|
||||
logger.error(f"保存提交模板失败: {e}")
|
||||
return jsonify({'success': False, 'error': str(e)}), 500
|
||||
|
||||
|
||||
@bp.route('/submit-template/preview', methods=['POST'])
|
||||
def preview_submit_template():
|
||||
"""预览填充后的步骤6任务文本"""
|
||||
try:
|
||||
data = request.get_json()
|
||||
product_name = data.get('product_name', '示例产品')
|
||||
category = data.get('category', '示例类别')
|
||||
subcategory = data.get('subcategory', '示例子类别')
|
||||
product_data = data.get('product_data', '{"name": "示例产品", "visible": true}')
|
||||
|
||||
# 读取模板
|
||||
if os.path.exists(SUBMIT_TEMPLATE_FILE):
|
||||
with open(SUBMIT_TEMPLATE_FILE, 'r', encoding='utf-8') as f:
|
||||
template = f.read()
|
||||
else:
|
||||
return jsonify({'success': False, 'error': '模板文件不存在'}), 404
|
||||
|
||||
# 填充示例数据
|
||||
filled = template.replace('{{product_name}}', product_name)
|
||||
filled = filled.replace('{{category}}', category)
|
||||
filled = filled.replace('{{subcategory}}', subcategory or '无')
|
||||
filled = filled.replace('{{product_data}}', product_data)
|
||||
|
||||
return jsonify({
|
||||
'success': True,
|
||||
'preview': filled
|
||||
})
|
||||
except Exception as e:
|
||||
logger.error(f"预览提交模板失败: {e}")
|
||||
return jsonify({'success': False, 'error': str(e)}), 500
|
||||
Reference in New Issue
Block a user