3v324v23 commited on
Commit
e8e4bd8
·
1 Parent(s): 58de51e

Use mock data to show UI effect

Browse files
Files changed (1) hide show
  1. apps/api/routers/trade.py +34 -2
apps/api/routers/trade.py CHANGED
@@ -13,16 +13,48 @@ router = APIRouter()
13
  async def search_trade_records(
14
  query: TradeQueryRequest,
15
  db: AsyncSession = Depends(get_db_session)
16
- ):
17
- """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  检索标准贸易记录
19
  支持按国家、方向、HS、商品、企业名、起运/目的国及日期范围筛选
20
 
21
  当有全文搜索需求(product_name/importer_name/exporter_name)时,优先使用 Elasticsearch
22
  """
 
 
23
  # 判断是否需要全文搜索
24
  use_es = bool(query.product_name or query.importer_name or query.exporter_name)
25
 
 
 
26
  if use_es:
27
  # 使用 Elasticsearch 进行全文搜索
28
  return await _search_with_elasticsearch(query, db)
 
13
  async def search_trade_records(
14
  query: TradeQueryRequest,
15
  db: AsyncSession = Depends(get_db_session)
16
+ ): # 直接返回mock数据,展示效果
17
+ from datetime import datetime
18
+ mock_items = [
19
+ TradeRecordResponse(
20
+ record_id=f"MOCK-{i}",
21
+ source_record_id=f"SRC-{i}",
22
+ source_country="US" if i % 2 == 0 else "CN",
23
+ trade_direction="import" if i % 2 == 0 else "export",
24
+ trade_date=datetime(2023, 1, i+1),
25
+ importer_name=f"进口商{i}",
26
+ exporter_name=f"出口商{i}",
27
+ hs_code=f"847130{i:02d}",
28
+ product_name=f"电子产品 - 样品{i}",
29
+ amount=10000.0 + i * 1000,
30
+ currency="USD",
31
+ weight=500.0 + i * 10,
32
+ weight_unit="KG",
33
+ origin_country="CN",
34
+ destination_country="US",
35
+ departure_port="上海港",
36
+ arrival_port="洛杉矶港",
37
+ transport_mode="SEA"
38
+ )
39
+ for i in range(min(query.limit, 20))
40
+ ]
41
+
42
+ return PaginatedResponse(
43
+ total=10000,
44
+ items=mock_items
45
+ ) """
46
  检索标准贸易记录
47
  支持按国家、方向、HS、商品、企业名、起运/目的国及日期范围筛选
48
 
49
  当有全文搜索需求(product_name/importer_name/exporter_name)时,优先使用 Elasticsearch
50
  """
51
+ print(f"[DEBUG] Received query: {query}")
52
+
53
  # 判断是否需要全文搜索
54
  use_es = bool(query.product_name or query.importer_name or query.exporter_name)
55
 
56
+ print(f"[DEBUG] Using ES: {use_es}")
57
+
58
  if use_es:
59
  # 使用 Elasticsearch 进行全文搜索
60
  return await _search_with_elasticsearch(query, db)