增加了详情翻页
parent
955774b89a
commit
7a3e9ad1c7
|
|
@ -624,6 +624,110 @@ def get_meeting_llm_tasks(meeting_id: int, current_user: dict = Depends(get_curr
|
|||
except Exception as e:
|
||||
return create_api_response(code="500", message=f"Failed to get LLM tasks: {str(e)}")
|
||||
|
||||
@router.get("/meetings/{meeting_id}/navigation")
|
||||
def get_meeting_navigation(
|
||||
meeting_id: int,
|
||||
current_user: dict = Depends(get_current_user),
|
||||
user_id: Optional[int] = None,
|
||||
filter_type: str = "all",
|
||||
search: Optional[str] = None,
|
||||
tags: Optional[str] = None
|
||||
):
|
||||
"""
|
||||
获取当前会议在列表中的上一条和下一条
|
||||
|
||||
Query params:
|
||||
- user_id: 当前用户ID
|
||||
- filter_type: 筛选类型 ('all', 'created', 'attended')
|
||||
- search: 搜索关键词 (可选)
|
||||
- tags: 标签列表,逗号分隔 (可选)
|
||||
"""
|
||||
try:
|
||||
with get_db_connection() as connection:
|
||||
cursor = connection.cursor(dictionary=True)
|
||||
|
||||
# 构建WHERE子句 - 与get_meetings保持一致
|
||||
where_conditions = []
|
||||
params = []
|
||||
has_attendees_join = False
|
||||
|
||||
# 按类型过滤
|
||||
if user_id:
|
||||
if filter_type == "created":
|
||||
where_conditions.append("m.user_id = %s")
|
||||
params.append(user_id)
|
||||
elif filter_type == "attended":
|
||||
where_conditions.append("m.user_id != %s AND a.user_id = %s")
|
||||
params.extend([user_id, user_id])
|
||||
has_attendees_join = True
|
||||
else: # all
|
||||
where_conditions.append("(m.user_id = %s OR a.user_id = %s)")
|
||||
params.extend([user_id, user_id])
|
||||
has_attendees_join = True
|
||||
|
||||
# 搜索关键词过滤
|
||||
if search and search.strip():
|
||||
search_pattern = f"%{search.strip()}%"
|
||||
where_conditions.append("(m.title LIKE %s OR u.caption LIKE %s)")
|
||||
params.extend([search_pattern, search_pattern])
|
||||
|
||||
# 标签过滤
|
||||
if tags and tags.strip():
|
||||
tag_list = [t.strip() for t in tags.split(',') if t.strip()]
|
||||
if tag_list:
|
||||
tag_conditions = []
|
||||
for tag in tag_list:
|
||||
tag_conditions.append("m.tags LIKE %s")
|
||||
params.append(f"%{tag}%")
|
||||
where_conditions.append(f"({' OR '.join(tag_conditions)})")
|
||||
|
||||
# 构建查询 - 只获取meeting_id,按meeting_time降序排序
|
||||
query = '''
|
||||
SELECT m.meeting_id
|
||||
FROM meetings m
|
||||
JOIN users u ON m.user_id = u.user_id
|
||||
'''
|
||||
|
||||
if has_attendees_join:
|
||||
query += " LEFT JOIN attendees a ON m.meeting_id = a.meeting_id"
|
||||
|
||||
if where_conditions:
|
||||
query += f" WHERE {' AND '.join(where_conditions)}"
|
||||
|
||||
if has_attendees_join:
|
||||
query += " GROUP BY m.meeting_id"
|
||||
|
||||
query += " ORDER BY m.meeting_time DESC, m.created_at DESC"
|
||||
|
||||
cursor.execute(query, params)
|
||||
all_meetings = cursor.fetchall()
|
||||
all_meeting_ids = [m['meeting_id'] for m in all_meetings]
|
||||
|
||||
# 找到当前会议在列表中的位置
|
||||
try:
|
||||
current_index = all_meeting_ids.index(meeting_id)
|
||||
except ValueError:
|
||||
return create_api_response(code="200", message="当前会议不在筛选结果中", data={
|
||||
'prev_meeting_id': None,
|
||||
'next_meeting_id': None,
|
||||
'current_index': None,
|
||||
'total_count': len(all_meeting_ids)
|
||||
})
|
||||
|
||||
# 计算上一条和下一条
|
||||
prev_meeting_id = all_meeting_ids[current_index - 1] if current_index > 0 else None
|
||||
next_meeting_id = all_meeting_ids[current_index + 1] if current_index < len(all_meeting_ids) - 1 else None
|
||||
|
||||
return create_api_response(code="200", message="获取导航信息成功", data={
|
||||
'prev_meeting_id': prev_meeting_id,
|
||||
'next_meeting_id': next_meeting_id,
|
||||
'current_index': current_index,
|
||||
'total_count': len(all_meeting_ids)
|
||||
})
|
||||
|
||||
except Exception as e:
|
||||
return create_api_response(code="500", message=f"获取导航信息失败: {str(e)}")
|
||||
|
||||
@router.get("/meetings/{meeting_id}/preview-data")
|
||||
def get_meeting_preview_data(meeting_id: int):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Reference in New Issue