api.proto 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. syntax = "proto3";
  2. package community.service.thumbup.v1;
  3. import "github.com/gogo/protobuf/gogoproto/gogo.proto";
  4. import "google/protobuf/empty.proto";
  5. option go_package = "api";
  6. option (gogoproto.goproto_getters_all) = false;
  7. service Thumbup {
  8. // 点赞接口
  9. rpc Like(LikeReq) returns(LikeReply);
  10. // 查询计数接口
  11. rpc Stats(StatsReq) returns(StatsReply);
  12. // 批量查询计数接口
  13. rpc MultiStats(MultiStatsReq) returns(MultiStatsReply);
  14. // 查询是否点赞接口
  15. rpc HasLike(HasLikeReq) returns (HasLikeReply);
  16. // 用户对业务的点赞列表
  17. rpc UserLikes(UserLikesReq) returns(UserLikesReply);
  18. // 对象的点赞人列表
  19. rpc ItemLikes(ItemLikesReq) returns(ItemLikesReply);
  20. // 修改计数的值
  21. rpc UpdateCount(UpdateCountReq) returns(.google.protobuf.Empty);
  22. // 查询原始计数 未修改的值
  23. rpc RawStat(RawStatReq) returns(RawStatReply);
  24. }
  25. enum Action {
  26. // The first value represents the default and must be == 0.
  27. ACTION_UNSPECIFIED = 0;
  28. ACTION_LIKE = 1;
  29. ACTION_CANCEL_LIKE = 2;
  30. ACTION_DISLIKE = 3;
  31. ACTION_CANCEL_DISLIKE = 4;
  32. }
  33. enum State {
  34. // The first value represents the default and must be == 0.
  35. STATE_UNSPECIFIED = 0;
  36. STATE_LIKE = 1;
  37. STATE_DISLIKE = 2;
  38. }
  39. message LikeReq {
  40. // 业务
  41. string business = 1 [(gogoproto.moretags) = 'form:"business" validate:"required"'];
  42. // mid
  43. int64 mid = 2 [(gogoproto.moretags) = 'form:"mid" validate:"required,min=1"'];
  44. // up 主mid
  45. int64 up_mid = 3 [(gogoproto.moretags) = 'form:"up_mid"'];
  46. // 来源id
  47. int64 origin_id = 4 [(gogoproto.moretags) = 'form:"origin_id"', (gogoproto.customname) = "OriginID"];
  48. // 对象id
  49. int64 message_id = 5 [(gogoproto.moretags) = 'form:"message_id" validate:"required"', (gogoproto.customname) = "MessageID"];
  50. Action action = 6 [(gogoproto.moretags) = 'form:"action_id" validate:"required"'];
  51. // ip
  52. string ip = 7 [(gogoproto.jsontag) = "ip", (gogoproto.customname) = "IP"];
  53. }
  54. message StatState {
  55. // 来源id
  56. int64 origin_id = 1 [(gogoproto.customname) = "OriginID"];
  57. // 对象id
  58. int64 message_id = 2 [(gogoproto.customname) = "MessageID"];
  59. // 点赞数
  60. int64 like_number = 3;
  61. // 点踩数
  62. int64 dislike_number = 4;
  63. // 点赞状态
  64. State like_state = 5;
  65. }
  66. message LikeReply {
  67. // 来源id
  68. int64 origin_id = 1 [(gogoproto.customname) = "OriginID"];
  69. // 对象id
  70. int64 message_id = 2 [(gogoproto.customname) = "MessageID"];
  71. // 点赞数
  72. int64 like_number = 3;
  73. // 点踩数
  74. int64 dislike_number = 4;
  75. }
  76. message StatsReq {
  77. // 业务
  78. string business = 1 [(gogoproto.moretags) = 'form:"business" validate:"required"'];
  79. // 来源id
  80. int64 origin_id = 2 [(gogoproto.moretags) = 'form:"origin_id"', (gogoproto.customname) = "OriginID"];
  81. // 对象id
  82. repeated int64 message_ids = 3 [(gogoproto.moretags) = 'form:"message_ids" validate:"required"'];
  83. // mid 可选参数 不需要返回like_state不要填
  84. int64 mid = 4 [(gogoproto.moretags) = 'form:"mid"'];
  85. // ip
  86. string ip = 5 [(gogoproto.jsontag) = "ip", (gogoproto.customname) = "IP"];
  87. }
  88. message StatsReply {
  89. map<int64, StatState> stats = 1;
  90. }
  91. message HasLikeReq {
  92. // 业务
  93. string business = 1 [(gogoproto.moretags) = 'form:"business" validate:"required"'];
  94. // 对象id
  95. repeated int64 message_ids = 2 [(gogoproto.moretags) = 'form:"message_ids" validate:"required"'];
  96. // mid
  97. int64 mid = 3 [(gogoproto.moretags) = 'form:"mid" validate:"required"'];
  98. // ip
  99. string ip = 4 [(gogoproto.jsontag) = "ip", (gogoproto.customname) = "IP"];
  100. }
  101. message HasLikeReply {
  102. map<int64, UserLikeState> states = 1;
  103. }
  104. message UserLikeState {
  105. // mid
  106. int64 mid = 1;
  107. // 点赞时间
  108. int64 time = 2[(gogoproto.casttype) = "go-common/library/time.Time"];
  109. State state = 3;
  110. }
  111. message UserLikesReq {
  112. // 业务
  113. string business = 1 [(gogoproto.moretags) = 'form:"business" validate:"required"'];
  114. // mid
  115. int64 mid = 2 [(gogoproto.moretags) = 'form:"mid" validate:"required"'];
  116. // pn
  117. int64 pn = 3 [(gogoproto.moretags) = 'form:"pn" validate:"required,min=1"'];
  118. // ps
  119. int64 ps = 4 [(gogoproto.moretags) = 'form:"ps" validate:"required,min=1"'];
  120. // ip
  121. string ip = 5 [(gogoproto.jsontag) = "ip", (gogoproto.customname) = "IP"];
  122. }
  123. message ItemRecord {
  124. // 对象id
  125. int64 message_id = 1 [(gogoproto.customname) = "MessageID"];
  126. // 点赞时间
  127. int64 time = 2[(gogoproto.casttype) = "go-common/library/time.Time"];
  128. }
  129. message UserLikesReply {
  130. int64 total = 1;
  131. repeated ItemRecord items = 2;
  132. }
  133. message UserRecord {
  134. // mid
  135. int64 mid = 1;
  136. // 点赞时间
  137. int64 time = 2[(gogoproto.casttype) = "go-common/library/time.Time"];
  138. }
  139. message ItemLikesReq {
  140. // 业务
  141. string business = 1 [(gogoproto.moretags) = 'form:"business" validate:"required"'];
  142. // 来源id
  143. int64 origin_id = 2 [(gogoproto.moretags) = 'form:"origin_id"', (gogoproto.customname) = "OriginID"];
  144. // 对象id
  145. int64 message_id = 3 [(gogoproto.moretags) = 'form:"message_id" validate:"required"', (gogoproto.customname) = "MessageID"];
  146. // last_mid 上个mid 去重用
  147. int64 last_mid = 4 [(gogoproto.moretags) = 'form:"last_mid" json:"last_mid"'];
  148. // pn
  149. int64 pn = 5 [(gogoproto.moretags) = 'form:"pn" validate:"required,min=1"'];
  150. // ps
  151. int64 ps = 6 [(gogoproto.moretags) = 'form:"ps" validate:"required,min=1"'];
  152. // ip
  153. string ip = 7 [(gogoproto.jsontag) = "ip", (gogoproto.customname) = "IP"];
  154. }
  155. message ItemLikesReply {
  156. repeated UserRecord users = 1;
  157. }
  158. message UpdateCountReq {
  159. // 业务
  160. string business = 1 [(gogoproto.moretags) = 'form:"business" validate:"required"'];
  161. // 来源id
  162. int64 origin_id = 2 [(gogoproto.moretags) = 'form:"origin_id"', (gogoproto.customname) = "OriginID"];
  163. // 对象id
  164. int64 message_id = 3 [(gogoproto.moretags) = 'form:"message_id" validate:"required"', (gogoproto.customname) = "MessageID"];
  165. // 点赞数修改(增量)
  166. int64 like_change = 4;
  167. // 点踩数修改(增量)
  168. int64 dislike_change = 5;
  169. // 操作人
  170. string operator = 6;
  171. // ip
  172. string ip = 7 [(gogoproto.jsontag) = "ip", (gogoproto.customname) = "IP"];
  173. }
  174. message RawStatReq {
  175. // 业务
  176. string business = 1 [(gogoproto.moretags) = 'form:"business" validate:"required"'];
  177. // 来源id
  178. int64 origin_id = 2 [(gogoproto.moretags) = 'form:"origin_id"', (gogoproto.customname) = "OriginID"];
  179. // 对象id
  180. int64 message_id = 3 [(gogoproto.moretags) = 'form:"message_id" validate:"required"', (gogoproto.customname) = "MessageID"];
  181. // ip
  182. string ip = 4 [(gogoproto.jsontag) = "ip", (gogoproto.customname) = "IP"];
  183. }
  184. message RawStatReply {
  185. // 来源id
  186. int64 origin_id = 1 [(gogoproto.moretags) = 'form:"origin_id"', (gogoproto.customname) = "OriginID"];
  187. // 对象id
  188. int64 message_id = 2 [(gogoproto.moretags) = 'form:"message_id" validate:"required"', (gogoproto.customname) = "MessageID"];
  189. // 点赞数
  190. int64 like_number = 3;
  191. // 点踩数
  192. int64 dislike_number = 4;
  193. // 点赞数修改(增量)
  194. int64 like_change = 5;
  195. // 点踩数修改(增量)
  196. int64 dislike_change = 6;
  197. }
  198. message MultiStatsReq {
  199. message Record {
  200. // 来源id
  201. int64 origin_id = 1 [(gogoproto.moretags) = 'form:"origin_id"', (gogoproto.customname) = "OriginID"];
  202. // 对象id
  203. int64 message_id = 2 [(gogoproto.moretags) = 'form:"message_id" validate:"required"', (gogoproto.customname) = "MessageID"];
  204. }
  205. message Business {
  206. repeated Record records = 1;
  207. }
  208. // mid
  209. int64 mid = 1 [(gogoproto.moretags) = 'form:"mid" validate:"required"'];
  210. // business and records
  211. map<string, Business> business = 2;
  212. // ip
  213. string ip = 3 [(gogoproto.jsontag) = "ip", (gogoproto.customname) = "IP"];
  214. }
  215. message MultiStatsReply {
  216. message Records {
  217. map<int64, StatState> records = 1;
  218. }
  219. // business and records
  220. map<string, Records> business = 1;
  221. }