更新Company页面的UI为FUI风格
This commit is contained in:
54
app.py
54
app.py
@@ -6466,50 +6466,14 @@ class RelatedData(db.Model):
|
|||||||
|
|
||||||
|
|
||||||
class RelatedConcepts(db.Model):
|
class RelatedConcepts(db.Model):
|
||||||
"""关联数据模型"""
|
"""相关概念模型(AI分析结果)"""
|
||||||
|
__tablename__ = 'related_concepts'
|
||||||
id = db.Column(db.Integer, primary_key=True)
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
event_id = db.Column(db.Integer, db.ForeignKey('event.id'))
|
event_id = db.Column(db.Integer, db.ForeignKey('event.id'))
|
||||||
concept_code = db.Column(db.String(20)) # 数据标题
|
concept = db.Column(db.String(255)) # 概念名称
|
||||||
concept = db.Column(db.String(100)) # 数据类型
|
reason = db.Column(db.Text) # 关联原因(AI分析)
|
||||||
reason = db.Column(db.Text) # 数据描述
|
|
||||||
image_paths = db.Column(db.JSON) # 数据内容(JSON格式)
|
|
||||||
created_at = db.Column(db.DateTime, default=beijing_now)
|
created_at = db.Column(db.DateTime, default=beijing_now)
|
||||||
|
|
||||||
@property
|
|
||||||
def image_paths_list(self):
|
|
||||||
"""返回解析后的图片路径列表"""
|
|
||||||
if not self.image_paths:
|
|
||||||
return []
|
|
||||||
|
|
||||||
try:
|
|
||||||
# 如果是字符串,先解析成JSON
|
|
||||||
if isinstance(self.image_paths, str):
|
|
||||||
paths = json.loads(self.image_paths)
|
|
||||||
else:
|
|
||||||
paths = self.image_paths
|
|
||||||
|
|
||||||
# 确保paths是列表
|
|
||||||
if not isinstance(paths, list):
|
|
||||||
paths = [paths]
|
|
||||||
|
|
||||||
# 从每个对象中提取path字段
|
|
||||||
return [item['path'] if isinstance(item, dict) and 'path' in item
|
|
||||||
else item for item in paths]
|
|
||||||
except Exception as e:
|
|
||||||
print(f"Error processing image paths: {e}")
|
|
||||||
return []
|
|
||||||
|
|
||||||
def get_first_image_path(self):
|
|
||||||
"""获取第一张图片的完整路径"""
|
|
||||||
paths = self.image_paths_list
|
|
||||||
if not paths:
|
|
||||||
return None
|
|
||||||
|
|
||||||
# 获取第一个路径
|
|
||||||
first_path = paths[0]
|
|
||||||
# 返回完整路径
|
|
||||||
return first_path
|
|
||||||
|
|
||||||
|
|
||||||
class EventHotHistory(db.Model):
|
class EventHotHistory(db.Model):
|
||||||
"""事件热度历史记录"""
|
"""事件热度历史记录"""
|
||||||
@@ -6982,23 +6946,21 @@ def get_events_by_stocks():
|
|||||||
|
|
||||||
@app.route('/api/events/<int:event_id>/concepts', methods=['GET'])
|
@app.route('/api/events/<int:event_id>/concepts', methods=['GET'])
|
||||||
def get_related_concepts(event_id):
|
def get_related_concepts(event_id):
|
||||||
"""获取相关概念列表"""
|
"""获取相关概念列表(AI分析结果)"""
|
||||||
try:
|
try:
|
||||||
# 订阅控制:相关概念需要 Pro 及以上
|
# 订阅控制:相关概念需要 Pro 及以上
|
||||||
if not _has_required_level('pro'):
|
if not _has_required_level('pro'):
|
||||||
return jsonify({'success': False, 'error': '需要Pro订阅', 'required_level': 'pro'}), 403
|
return jsonify({'success': False, 'error': '需要Pro订阅', 'required_level': 'pro'}), 403
|
||||||
event = Event.query.get_or_404(event_id)
|
|
||||||
concepts = event.related_concepts.all()
|
# 直接查询 related_concepts 表
|
||||||
|
concepts = RelatedConcepts.query.filter_by(event_id=event_id).all()
|
||||||
|
|
||||||
concepts_data = []
|
concepts_data = []
|
||||||
for concept in concepts:
|
for concept in concepts:
|
||||||
concepts_data.append({
|
concepts_data.append({
|
||||||
'id': concept.id,
|
'id': concept.id,
|
||||||
'concept_code': concept.concept_code,
|
|
||||||
'concept': concept.concept,
|
'concept': concept.concept,
|
||||||
'reason': concept.reason,
|
'reason': concept.reason,
|
||||||
'image_paths': concept.image_paths_list,
|
|
||||||
'first_image_path': concept.get_first_image_path(),
|
|
||||||
'created_at': concept.created_at.isoformat() if concept.created_at else None
|
'created_at': concept.created_at.isoformat() if concept.created_at else None
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user