-
Notifications
You must be signed in to change notification settings - Fork 124
/
api.thrift
80 lines (66 loc) · 2.29 KB
/
api.thrift
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
// refer to https://www.cloudwego.io/zh/docs/hertz/tutorials/toolkit/toolkit/
namespace go user_gorm
namespace py user_gorm
namespace java user_gorm
enum Code {
Success = 1
ParamInvalid = 2
DBErr = 3
}
enum Gender {
Unknown = 0
Male = 1
Female = 2
}
struct User {
1: i64 user_id
2: string name
3: Gender gender
4: i64 age
5: string introduce
}
struct CreateUserRequest{
1: string name (api.body="name", api.form="name",api.vd="(len($) > 0 && len($) < 100)")
2: Gender gender (api.body="gender", api.form="gender",api.vd="($ == 1||$ == 2)")
3: i64 age (api.body="age", api.form="age",api.vd="$>0")
4: string introduce (api.body="introduce", api.form="introduce",api.vd="(len($) > 0 && len($) < 1000)")
}
struct CreateUserResponse{
1: Code code
2: string msg
}
struct QueryUserRequest{
1: optional string Keyword (api.body="keyword", api.form="keyword",api.query="keyword")
2: i64 page (api.body="page", api.form="page",api.query="page",api.vd="$ > 0")
3: i64 page_size (api.body="page_size", api.form="page_size",api.query="page_size",api.vd="($ > 0 || $ <= 100)")
}
struct QueryUserResponse{
1: Code code
2: string msg
3: list<User> users
4: i64 totoal
}
struct DeleteUserRequest{
1: i64 user_id (api.path="user_id",api.vd="$>0")
}
struct DeleteUserResponse{
1: Code code
2: string msg
}
struct UpdateUserRequest{
1: i64 user_id (api.path="user_id",api.vd="$>0")
2: string name (api.body="name", api.form="name",api.vd="(len($) > 0 && len($) < 100)")
3: Gender gender (api.body="gender", api.form="gender",api.vd="($ == 1||$ == 2)")
4: i64 age (api.body="age", api.form="age",api.vd="$>0")
5: string introduce (api.body="introduce", api.form="introduce",api.vd="(len($) > 0 && len($) < 1000)")
}
struct UpdateUserResponse{
1: Code code
2: string msg
}
service UserService {
UpdateUserResponse UpdateUser(1:UpdateUserRequest req)(api.post="/v1/user/update/:user_id")
DeleteUserResponse DeleteUser(1:DeleteUserRequest req)(api.post="/v1/user/delete/:user_id")
QueryUserResponse QueryUser(1: QueryUserRequest req)(api.post="/v1/user/query/")
CreateUserResponse CreateUser(1:CreateUserRequest req)(api.post="/v1/user/create/")
}