删除多个不再需要的文档,包括AI服务错误分析报告、模板树状结构更新说明、数据库备份和恢复工具使用说明等,简化项目结构,提升可维护性。同时,更新文档服务以支持从input_data和template_code中提取模板配置,增强查询逻辑的灵活性。

This commit is contained in:
python 2025-12-10 10:39:36 +08:00
parent 11be119ffc
commit e38ba42669
11 changed files with 13 additions and 3 deletions

View File

@ -65,9 +65,9 @@ class DocumentService:
cursor = conn.cursor(pymysql.cursors.DictCursor) cursor = conn.cursor(pymysql.cursors.DictCursor)
try: try:
# 查询文件配置template_code存储在input_data的JSON字段中 # 查询文件配置template_code可能存储在template_code列或input_data的JSON字段中
sql = """ sql = """
SELECT id, name, file_path, input_data SELECT id, name, file_path, input_data, template_code
FROM f_polic_file_config FROM f_polic_file_config
WHERE tenant_id = %s WHERE tenant_id = %s
AND state = 1 AND state = 1
@ -75,8 +75,18 @@ class DocumentService:
cursor.execute(sql, (self.tenant_id,)) cursor.execute(sql, (self.tenant_id,))
configs = cursor.fetchall() configs = cursor.fetchall()
# 从input_data的JSON中查找匹配的template_code # 查找匹配的template_code优先检查template_code列然后检查input_data JSON
for config in configs: for config in configs:
# 方法1: 检查template_code列
if config.get('template_code') == template_code:
return {
'id': config['id'],
'name': config['name'],
'file_path': config['file_path'],
'template_code': template_code
}
# 方法2: 从input_data的JSON中查找匹配的template_code
try: try:
input_data = json.loads(config['input_data']) if config['input_data'] else {} input_data = json.loads(config['input_data']) if config['input_data'] else {}
if input_data.get('template_code') == template_code: if input_data.get('template_code') == template_code: