/
collect_gw.proto
122 lines (110 loc) · 2.75 KB
/
collect_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
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";
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: "comment 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 CollectService {
// 收藏
rpc Create (CreateCollectRequest) returns (CreateCollectReply) {
option (google.api.http) = {
post: "/api/v1/collect"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "收藏",
description: "收藏",
security: {
security_requirement: {
key: "BearerAuth";
value: {}
}
}
};
}
// 删除收藏
rpc Delete (DeleteCollectRequest) returns (DeleteCollectReply) {
option (google.api.http) = {
post: "/api/v1/collect/delete"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "删除收藏",
description: "删除收藏",
security: {
security_requirement: {
key: "BearerAuth";
value: {}
}
}
};
}
// 获取收藏列表
rpc List (ListCollectRequest) returns (ListCollectReply) {
option (google.api.http) = {
post: "/api/v1/collect/list"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "获取用户的收藏列表",
description: "获取用户的收藏列表",
security: {
security_requirement: {
key: "BearerAuth";
value: {}
}
}
};
}
}
message CollectInfo {
uint64 id = 1;
uint64 userId = 2;
uint64 postId = 3;
int64 createdAt = 4;
int64 updatedAt = 5;
}
message CreateCollectRequest {
uint64 userId = 1 [(validate.rules).uint64.gte = 1];
uint64 postId = 2 [(validate.rules).uint64.gte = 1];
}
message CreateCollectReply {}
message DeleteCollectRequest {
uint64 id = 1 [(validate.rules).uint64.gte = 1];
uint64 postId = 2 [(validate.rules).uint64.gte = 1];
}
message DeleteCollectReply {}
message ListCollectRequest {
uint64 userId = 2 [(validate.rules).uint64.gte = 1];
int32 page = 3 [(validate.rules).int32.gte = 0];
int32 limit = 4 [(validate.rules).int32 = {gt:0, lte: 100}];
}
message ListCollectReply {
repeated CollectInfo collects = 1;
int64 total = 2;
}