-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcurl.sh
executable file
·199 lines (194 loc) · 4.64 KB
/
curl.sh
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
#! /usr/bin/env bash
set -eu
BASE_URL="http://localhost:8080/api"
echo "🤣 MODE: $MODE"
if [ "${MODE}" = "release" ]; then
BASE_URL="http://101.42.21.155:80/api"
fi
echo "🤣 base url: $BASE_URL"
set -eux
# 00 00
# service, api
case $1 in
1000) # register
curl -X POST "$BASE_URL"/auth/register -d '{
"username": "test",
"password": "123"
}'
;;
1001) # login
curl -X POST "$BASE_URL"/auth/login -d '{
"username": "test",
"password": "123"
}'
;;
2000) # get fabrics list
# query:
# - page: int required, 例如: 1, 2, 3, ...
# - size: int req uired, 例如: 10, 20, 30, ...
# - category: string optional, 例如: defult, new, hot, ...
curl -X GET "$BASE_URL/fabric/list?page=1&size=10&category=default"
;;
2001) # get fabric
curl -X GET "$BASE_URL/fabric/$2"
;;
2002) # post fabric
curl -X POST $BASE_URL/fabric \
-F "name=aaa" \
-F "detail=bbb" \
-F "category=default" \
-F "image=@${2}"
;;
2003) # update fabric
curl -X PUT "$BASE_URL/fabric/$2" \
-F "name=aaa1"
# -F "detail=bbb2" \
# -F "image=@$3"
;;
2004) # delete fabric
curl -X DELETE "$BASE_URL/fabric/$2"
;;
3001) # upload images
# 上传图片
# tableName: string required, 例如: fabric, brand, ...
# 用于指定图片属于哪个表,参考各个 api 的命名规则
# recordId: string required, 例如: 1,2, ...
# images: file required, 例如: a.jpg, b.jpg, ...
# 图片可以传多个,但是数据库最多只能传 5 张
curl -X POST $BASE_URL/image/upload \
-F "tableName=$2" \
-F "recordId=$3" \
-F "images=@$4"
# -F "images=@/home/trdthg/resources/a.jpg" \
# -F "images=@/home/trdthg/resources/a.jpg" \
;;
3002) # delete image
curl -X DELETE "$BASE_URL/image/$2"
;;
4000) # get brand list
# query:
# - page: int required, 例如: 1, 2, 3, ...
# - size: int required, 例如: 10, 20, 30, ...
curl -X GET "$BASE_URL/brand/list?page=1&size=10"
;;
4001) # get brand
curl -X GET "$BASE_URL/brand/$2"
;;
4002) # create brand
curl -X POST $BASE_URL/brand \
-F "name=例如" \
-F "detail=bbb" \
-F "image=@${2}"
;;
4003) # update brand
curl -X PUT "$BASE_URL/brand/$2" \
-F "name=aaa" \
-F "detail=bbb2" \
-F "image=@$3"
;;
4004) # delete brand
curl -X DELETE "$BASE_URL/brand/$2"
;;
5000) # get trend list
# query:
# - page: int required, 例如: 1, 2, 3, ...
# - size: int required, 例如: 10, 20, 30, ...
curl -X GET "$BASE_URL/trend/list?page=1&size=10"
;;
5001) # get trend
curl -X GET "$BASE_URL/trend/$2"
;;
5002) # create trend
curl -X POST $BASE_URL/trend \
-F "name=aaa" \
-F "detail=bbb" \
-F "image=@$2"
;;
5003) # update trend
curl -X PUT "$BASE_URL/trend/$2" \
-F "name=aaa" \
-F "detail=bbb2" \
-F "image=@$3"
;;
5004) # delete trend
curl -X DELETE "$BASE_URL/trend/$2"
;;
6000) # get cloth list
# query:
# - page: int required, 例如: 1, 2, 3, ...
# - size: int required, 例如: 10, 20, 30, ...
curl -X GET "$BASE_URL/cloth/list?page=1&size=10"
;;
6001) # get cloth
curl -X GET "$BASE_URL/cloth/$2"
;;
6002) # create cloth
curl -X POST $BASE_URL/cloth \
-F "name=aaa" \
-F "detail=bbb" \
-F "image=@$2"
;;
6003) # update cloth
curl -X PUT "$BASE_URL/cloth/$2" \
-F "name=aaa" \
-F "detail=bbb2" \
-F "image=@$3"
;;
6004) # delete cloth
curl -X DELETE "$BASE_URL/cloth/$2"
;;
7000) # get dress list
# query:
# - page: int required, 例如: 1, 2, 3, ...
# - size: int required, 例如: 10, 20, 30, ...
curl -X GET "$BASE_URL/dress/list?page=1&size=10"
;;
7001) # get dress
curl -X GET "$BASE_URL/dress/$2"
;;
7002) # create dress
curl -X POST $BASE_URL/dress \
-F "name=aaa" \
-F "detail=例如" \
-F "type=default" \
-F "image=@$2"
;;
7003) # update dress
curl -X PUT "$BASE_URL/dress/$2" \
-F "name=aaa" \
-F "detail=bbb2" \
-F "image=@$3"
;;
7004) # delete dress
curl -X DELETE "$BASE_URL/dress/$2"
;;
8000) # get news list
# query:
# - page: int required, 例如: 1, 2, 3, ...
# - size: int required, 例如: 10, 20, 30, ...
curl -X GET "$BASE_URL/news/list?page=1&size=10"
;;
8001) # get news
curl -X GET "$BASE_URL/news/$2"
;;
8002) # create news
# type: industry | school_company
curl -X POST $BASE_URL/news \
-F "main=你好" \
-F "title=bbb" \
-F "type=industry" \
-F "image=@$2"
;;
8003) # update news
curl -X PUT "$BASE_URL/news/$2" \
-F "name=你好" \
-F "detail=bbb2" \
-F "image=@$3"
;;
8004) # delete news
curl -X DELETE "$BASE_URL/news/$2"
;;
*)
echo "Usage: $0 {get|post|put|delete}"
;;
esac