-
Notifications
You must be signed in to change notification settings - Fork 127
/
Copy pathuser.proto
94 lines (78 loc) · 2.4 KB
/
user.proto
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
syntax = "proto3";
package user;
// biz/model
option go_package = "hertz/user";
import "api.proto";
enum Code {
Success = 0;
ParamInvalid = 1;
DBErr = 2;
}
enum Gender {
Unknown = 0;
Male = 1;
Female = 2;
}
message User{
int64 user_id = 1;
string name = 2;
Gender gender = 3;
int64 age = 4;
string introduce = 5;
}
message CreateUserReq{
string name = 1 [(api.body) = "name", (api.form) = "name", (api.vd) = "(len($) > 0 && len($) < 100)"];
Gender gender = 2 [(api.body) = "gender", (api.form) = "gender", (api.vd) = "($ == 1||$ == 2)"];
int64 age = 3 [(api.body) = "age", (api.form) = "age", (api.vd) = "$>0"];
string introduce = 4 [(api.body) = "introduce", (api.form) = "introduce", (api.vd) = "(len($) > 0 && len($) < 1000)"];
}
message CreateUserResp{
Code code = 1;
string msg = 2;
}
message QueryUserReq{
string keyword = 1 [(api.body) = "keyword", (api.form) = "keyword"];
int64 page = 2 [(api.body) = "page", (api.form) = "page", (api.vd) = "$>0"];
int64 page_size = 3 [(api.body) = "page_size", (api.form) = "page_size", (api.vd) = "($ > 0 || $ <= 100)"];
}
message QueryUserResp{
Code code = 1;
string msg = 2;
repeated User user = 3;
int64 total = 4;
}
message DeleteUserReq{
int64 user_id = 1 [(api.path) = "user_id", (api.vd) = "$>0"];
}
message DeleteUserResp{
Code code = 1;
string msg = 2;
}
message UpdateUserReq{
int64 user_id = 1 [(api.path) = "user_id", (api.vd) = "$>0"];
string name = 2 [(api.body) = "name", (api.form) = "name", (api.vd) = "(len($) > 0 && len($) < 100)"];
Gender gender = 3 [(api.body) = "gender", (api.form) = "gender", (api.vd) = "($ == 1||$ == 2)"];
int64 age = 4 [(api.body) = "age", (api.form) = "age", (api.vd) = "$>0"];
string introduce = 5 [(api.body) = "introduce", (api.form) = "introduce", (api.vd) = "(len($) > 0 && len($) < 1000)"];
}
message UpdateUserResp{
Code code = 1;
string msg = 2;
}
message OtherResp {
string msg = 1;
}
service UserService {
rpc CreateUserResponse(CreateUserReq) returns(CreateUserResp) {
option (api.post) = "/v1/user/create";
}
rpc QueryUserResponse(QueryUserReq) returns(QueryUserResp){
option (api.post) = "/v1/user/query";
}
rpc UpdateUserResponse(UpdateUserReq) returns(UpdateUserResp){
option (api.post) = "/v1/user/update/:user_id";
}
rpc DeleteUserResponse(DeleteUserReq) returns(DeleteUserResp){
option (api.post) = "/v1/user/delete/:user_id";
}
}