|
@@ -729,6 +729,7 @@ async def get_records_by_creator_and_report(
|
|
|
db: Session = Depends(get_db),
|
|
|
creator_id = Depends(valid_access_token)
|
|
|
):
|
|
|
+ # creator_id=1
|
|
|
# 查询 ReportManagement 表以获取对应记录
|
|
|
report = db.query(ReportManagement).filter(
|
|
|
ReportManagement.creator_id == creator_id,
|
|
@@ -760,20 +761,22 @@ async def get_records_by_creator_and_report(
|
|
|
column_names = [column['name'] for column in columns]
|
|
|
column_comments = {column['name']: column['comment'] for column in columns if 'comment' in column}
|
|
|
|
|
|
- # 构造返回结果
|
|
|
- results = []
|
|
|
- excluded_columns = ['id', 'user_id', 'create_id', 'collect_status']
|
|
|
-
|
|
|
- # 添加字段名和字段注释作为第一行
|
|
|
- first_row = {column: column_comments.get(column, '') for column in column_names if column not in excluded_columns}
|
|
|
- first_row['user_name'] = column_comments.get('user_name', '用户昵称') # 添加用户昵称的注释
|
|
|
- results.append(first_row)
|
|
|
+ # 构造字段信息
|
|
|
+ columns_info = []
|
|
|
+ for column in column_names:
|
|
|
+ if column not in ['id', 'user_id', 'create_id', 'collect_status']:
|
|
|
+ columns_info.append({
|
|
|
+ 'prop': column,
|
|
|
+ 'label': column_comments.get(column, '')
|
|
|
+ })
|
|
|
|
|
|
+ # 构造返回结果
|
|
|
+ rows_data = []
|
|
|
for row in rows:
|
|
|
# 过滤掉不需要的列,并添加到结果中
|
|
|
- filtered_row = {column: row[idx] for idx, column in enumerate(column_names) if column not in excluded_columns}
|
|
|
+ filtered_row = {column: row[idx] for idx, column in enumerate(column_names) if column not in ['id', 'user_id', 'create_id', 'collect_status']}
|
|
|
filtered_row['user_name'] = row[-1] # 添加用户昵称
|
|
|
- results.append(filtered_row)
|
|
|
+ rows_data.append(filtered_row)
|
|
|
|
|
|
# 获取报告的开始和结束时间,并格式化为字符串
|
|
|
start_time_str = report.start_time.strftime('%Y-%m-%d %H:%M:%S') if report.start_time else None
|
|
@@ -784,5 +787,6 @@ async def get_records_by_creator_and_report(
|
|
|
'msg': '查询成功',
|
|
|
'start_time': start_time_str,
|
|
|
"end_time": end_time_str,
|
|
|
- "data": results
|
|
|
+ "columns": columns_info,
|
|
|
+ "rows": rows_data
|
|
|
}
|