Blame view

scripts/sh/test_deduct_list.sh 2.05 KB
1fffa876   “wangming”   优化储扣列表接口:增加门店、时间、...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
  #!/bin/bash
  
  # 测试储扣列表接口
  
  echo "=== 测试储扣列表接口 ==="
  
  # 获取Token
  TOKEN=$(curl -s -X POST "http://localhost:2011/api/oauth/Login" \
    -H "Content-Type: application/x-www-form-urlencoded" \
    -d "account=admin&password=e10adc3949ba59abbe56e057f20f883e" | python3 -c "import sys, json; print(json.load(sys.stdin)['data']['token'])" 2>/dev/null)
  
  if [ -z "$TOKEN" ]; then
    echo "❌ 获取Token失败"
    exit 1
  fi
  
  echo "✅ Token获取成功"
  echo ""
  
  # 测试1: 基础查询
  echo "--- 测试1: 基础查询(第1页,每页5条) ---"
  RESPONSE1=$(curl -s -w "\nTIME:%{time_total}" -X GET "http://localhost:2011/api/Extend/lqkdkdjlb/deduct-list?currentPage=1&pageSize=5" \
    -H "Authorization: $TOKEN")
  TIME1=$(echo "$RESPONSE1" | grep "TIME:" | cut -d: -f2)
  RESPONSE_BODY1=$(echo "$RESPONSE1" | sed '/TIME:/d')
  echo "响应时间: ${TIME1}秒"
  echo "$RESPONSE_BODY1" | python3 -c "
  import sys, json
  try:
      data = json.load(sys.stdin)
      if data.get('code') == 200:
          result = data.get('data', {})
          if 'list' in result:
              print(f'✅ 接口调用成功')
              print(f'当前页记录数: {len(result.get(\"list\", []))}')
              print(f'总记录数: {result.get(\"pagination\", {}).get(\"total\", 0)}')
              if 'statistics' in result:
                  stats = result['statistics']
                  print(f'统计信息:')
                  print(f'  - 总记录数: {stats.get(\"totalCount\", 0)}')
                  print(f'  - 总金额: {stats.get(\"totalAmount\", 0):,.2f}')
                  print(f'  - 总项目数: {stats.get(\"totalProjectNumber\", 0)}')
              else:
                  print('❌ 缺少统计信息')
          else:
              print('❌ 返回结构不正确')
              print('返回的keys:', list(result.keys()) if isinstance(result, dict) else 'N/A')
      else:
          print(f'❌ 接口返回错误: {data.get(\"msg\", \"未知错误\")}')
  except Exception as e:
      print(f'❌ 解析响应失败: {e}')
      import traceback
      traceback.print_exc()
  " 2>&1
  echo ""
  
  echo "=== 测试完成 ==="