/
like_gw.proto
154 lines (140 loc) · 3.6 KB
/
like_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
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 LikeService {
// 点赞
rpc Create (CreateLikeRequest) returns (CreateLikeReply) {
option (google.api.http) = {
post: "/api/v1/like"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "点赞",
description: "点赞",
security: {
security_requirement: {
key: "BearerAuth";
value: {}
}
}
};
}
// 取消点赞
rpc Delete (DeleteLikeRequest) returns (DeleteLikeReply) {
option (google.api.http) = {
post: "/api/v1/like/delete"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "取消点赞",
description: "取消点赞",
security: {
security_requirement: {
key: "BearerAuth";
value: {}
}
}
};
}
// 获取帖子点赞列表
rpc ListPost (ListPostLikeRequest) returns (ListPostLikeReply) {
option (google.api.http) = {
post: "/api/v1/like/post/list"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "获取贴子点赞列表",
description: "获取贴子点赞列表",
security: {
security_requirement: {
key: "BearerAuth";
value: {}
}
}
};
}
// 获取评论点赞列表
rpc ListComment (ListCommentLikeRequest) returns (ListCommentLikeReply) {
option (google.api.http) = {
post: "/api/v1/like/comment/list"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "获取评论点赞列表",
description: "获取评论点赞列表",
security: {
security_requirement: {
key: "BearerAuth";
value: {}
}
}
};
}
}
message LikeInfo {
uint64 id = 1;
uint64 userId = 2;
int32 objType = 3;
uint64 objId = 4;
int32 status = 5;
int64 createdAt = 6;
int64 updatedAt = 7;
}
message CreateLikeRequest {
uint64 userId = 1 [(validate.rules).uint64.gte = 1];
int32 objType = 2 [(validate.rules).int32 = {gte:1, lte: 2}];
uint64 objId = 3 [(validate.rules).uint64.gte = 1];
}
message CreateLikeReply {}
message DeleteLikeRequest {
uint64 userId = 1 [(validate.rules).uint64.gte = 1];
int32 objType = 2 [(validate.rules).int32 = {gte:1, lte: 2}];
uint64 objId = 3 [(validate.rules).uint64.gte = 1];
}
message DeleteLikeReply {}
message ListPostLikeRequest {
uint64 postId = 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 ListPostLikeReply {
repeated LikeInfo likes = 1;
int64 total = 2;
}
message ListCommentLikeRequest {
uint64 commentId = 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 ListCommentLikeReply {
repeated LikeInfo likes = 1;
int64 total = 2;
}