test_user_list_search.sh
2.58 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
# 测试用户列表接口 - 门店ID和岗位搜索功能
# 使用方法: ./scripts/sh/test_user_list_search.sh
BASE_URL="http://localhost:2011"
TOKEN=""
echo "=========================================="
echo "测试用户列表接口 - 门店ID和岗位搜索"
echo "=========================================="
echo ""
# 1. 登录获取token
echo "1. 登录获取token..."
LOGIN_RESPONSE=$(curl -s -X POST "${BASE_URL}/api/oauth/Login" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "account=admin&password=e10adc3949ba59abbe56e057f20f883e")
TOKEN=$(echo $LOGIN_RESPONSE | 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 ""
# 2. 测试基本查询(无搜索条件)
echo "2. 测试基本查询(无搜索条件)..."
BASIC_RESPONSE=$(curl -s -X GET "${BASE_URL}/api/permission/Users?currentPage=1&pageSize=5" \
-H "Authorization: ${TOKEN}" \
-H "Content-Type: application/json")
echo "$BASIC_RESPONSE" | python3 -m json.tool | head -30
echo ""
# 3. 测试岗位搜索(gw=健康师)
echo "3. 测试岗位搜索(gw=健康师)..."
GW_RESPONSE=$(curl -s -X GET "${BASE_URL}/api/permission/Users?currentPage=1&pageSize=5&gw=健康师" \
-H "Authorization: ${TOKEN}" \
-H "Content-Type: application/json")
echo "$GW_RESPONSE" | python3 -m json.tool | head -40
echo ""
# 4. 测试门店ID搜索(使用实际的门店ID)
echo "4. 测试门店ID搜索..."
MDID="1649328471923847168"
MDID_RESPONSE=$(curl -s -X GET "${BASE_URL}/api/permission/Users?currentPage=1&pageSize=5&mdid=${MDID}" \
-H "Authorization: ${TOKEN}" \
-H "Content-Type: application/json")
echo "$MDID_RESPONSE" | python3 -m json.tool | head -40
echo ""
# 5. 测试组合搜索(门店ID + 岗位)
echo "5. 测试组合搜索(门店ID + 岗位)..."
COMBINED_RESPONSE=$(curl -s -X GET "${BASE_URL}/api/permission/Users?currentPage=1&pageSize=5&mdid=${MDID}&gw=健康师" \
-H "Authorization: ${TOKEN}" \
-H "Content-Type: application/json")
echo "$COMBINED_RESPONSE" | python3 -m json.tool | head -40
echo ""
# 6. 测试其他岗位
echo "6. 测试其他岗位(gw=店助)..."
GW2_RESPONSE=$(curl -s -X GET "${BASE_URL}/api/permission/Users?currentPage=1&pageSize=5&gw=店助" \
-H "Authorization: ${TOKEN}" \
-H "Content-Type: application/json")
echo "$GW2_RESPONSE" | python3 -m json.tool | head -40
echo ""
echo "=========================================="
echo "测试完成"
echo "=========================================="