update pay function

This commit is contained in:
2025-11-20 18:00:21 +08:00
parent 8dfd344806
commit 2b30d10451

13
app.py
View File

@@ -7430,11 +7430,22 @@ def api_get_events():
# 新增:关键词/全文搜索过滤MySQL JSON
if search_query:
like_pattern = f"%{search_query}%"
# 子查询查找关联股票中匹配的事件ID
stock_subquery = db.session.query(RelatedStock.event_id).filter(
db.or_(
RelatedStock.stock_name.ilike(like_pattern),
RelatedStock.relation_desc.ilike(like_pattern)
)
).distinct()
# 主查询:搜索事件标题、描述、关键词或关联股票
query = query.filter(
db.or_(
Event.title.ilike(like_pattern),
Event.description.ilike(like_pattern),
text(f"JSON_SEARCH(keywords, 'one', '%{search_query}%') IS NOT NULL")
text(f"JSON_SEARCH(keywords, 'one', '%{search_query}%') IS NOT NULL"),
Event.id.in_(stock_subquery)
)
)
if recent_days: