/
user_gw.proto
247 lines (217 loc) · 6.03 KB
/
user_gw.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
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
syntax = "proto3";
package api.community_gw.v1;
import "google/api/annotations.proto";
import "protoc-gen-openapiv2/options/annotations.proto";
import "tagger/tagger.proto";
import "validate/validate.proto";
import "api/types/types.proto";
option go_package = "community_gw/api/community_gw/v1;v1";
// Default settings for generating swagger documents
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
host: "localhost:8080"
base_path: ""
info: {
title: "user api docs";
version: "2.0";
}
schemes: HTTP;
schemes: HTTPS;
consumes: "application/json";
produces: "application/json";
security_definitions: {
security: {
key: "BearerAuth";
value: {
type: TYPE_API_KEY;
in: IN_HEADER;
name: "Authorization";
description: "Input a \"Bearer your-jwt-token\" to Value";
}
}
}
};
service UserService {
// 发送邮件验证码
rpc SendEmailVerifyCode(SendEmailVerifyCodeRequest) returns (SendEmailVerifyCodeReply) {
option (google.api.http) = {
post: "/api/v1/auth/email"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "发送邮件验证码",
description: "发送邮件验证码",
};
}
// 注册
rpc Register(RegisterRequest) returns (RegisterReply) {
option (google.api.http) = {
post: "/api/v1/auth/register"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "注册",
description: "注册",
};
}
// 登录
rpc Login(LoginRequest) returns (LoginReply) {
option (google.api.http) = {
post: "/api/v1/auth/login"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "登录",
description: "登录",
};
}
// 登出
rpc Logout(LogoutRequest) returns (LogoutReply) {
option (google.api.http) = {
post: "/api/v1/auth/logout"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "登出",
description: "登出",
security: {
security_requirement: {
key: "BearerAuth";
value: {}
}
}
};
}
// 更新用户
rpc UpdateByID(UpdateUserByIDRequest) returns (UpdateUserByIDReply) {
option (google.api.http) = {
put: "/api/v1/user/{id}"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "更新用户",
description: "通过id更新用户",
security: {
security_requirement: {
key: "BearerAuth";
value: {}
}
}
};
}
// 用户详情
rpc GetByID(GetUserByIDRequest) returns (GetUserByIDReply) {
option (google.api.http) = {
get: "/api/v1/user/{id}"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "用户详情",
description: "通过id获取用户详情",
security: {
security_requirement: {
key: "BearerAuth";
value: {}
}
}
};
}
// 更新密码
rpc UpdatePassword(UpdatePasswordRequest) returns (UpdatePasswordReply) {
option (google.api.http) = {
put: "/api/v1/user/password/{id}"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "更新密码",
description: "更新密码",
security: {
security_requirement: {
key: "BearerAuth";
value: {}
}
}
};
}
}
message SendEmailVerifyCodeRequest {
string email = 1 [(validate.rules).string.email = true];
}
message SendEmailVerifyCodeReply {}
message RegisterRequest {
string email = 1 [(validate.rules).string.email = true];
string emailCode = 2 [(validate.rules).string.len = 6];
string password = 3 [(validate.rules).string.min_len = 6];
}
message RegisterReply {
uint64 id = 1;
}
message LoginRequest {
string email = 1 [(validate.rules).string.email = true];
string password = 2 [(validate.rules).string.min_len = 6];
string ip = 3;
}
message LoginReply {
uint64 id = 1;
string token = 2;
}
message CheckAuthRequest {
string token = 1 [(validate.rules).string.min_len = 50];
}
message CheckAuthReply {}
message LogoutRequest {
uint64 id = 1 [(validate.rules).uint64.gte = 1];
string token = 2 [(validate.rules).string.min_len = 20];
}
message LogoutReply {
}
message DeleteUserByIDRequest {
uint64 id =1 [(validate.rules).uint64.gte = 1, (tagger.tags) = "uri:\"id\"" ];
}
message DeleteUserByIDReply {
}
message UpdateUserByIDRequest {
uint64 id = 1 [(validate.rules).uint64.gte = 1, (tagger.tags) = "uri:\"id\"" ];
string name = 2; // 用户名
string nickName = 3; // 用户昵称
string phone = 4; // 手机号码
string avatar = 5; // 头像
int32 gender = 6; // 性别,1:男,2:女,其他值:未知
int32 age = 7; // 年龄
string birthday = 8; // 出生日期
}
message UpdateUserByIDReply {
}
message User {
uint64 id = 1;
string name = 2; // 用户名
string nickName = 3; // 用户昵称
string email = 4; // 邮件
string phone = 5; // 手机号码
string avatar = 6; // 头像
int32 gender = 7; // 性别,1:男,2:女,其他值:未知
int32 age = 8; // 年龄
string birthday = 9; // 出生日期
int64 loginAt = 10; // 登录时间
string loginIp = 11; // 登录ip
int32 status = 12; // 状态, 1:正常, 2:删除, 3:封禁
int64 createdAt = 13;
int64 updatedAt = 14;
}
message GetUserByIDRequest {
uint64 id =1 [(validate.rules).uint64.gte = 1, (tagger.tags) = "uri:\"id\"" ];
}
message GetUserByIDReply {
User userInfo = 1;
}
message ListUserRequest {
types.Params params = 1;
}
message ListUserReply {
int64 total =1;
repeated User userInfos = 2;
}
message UpdatePasswordRequest {
uint64 id = 1 [(validate.rules).uint64.gte = 1, (tagger.tags) = "uri:\"id\"" ];
string password = 2 [(validate.rules).string.min_len = 6];
}
message UpdatePasswordReply {
}