slow_wild.api 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  1. syntax = "v1"
  2. info (
  3. title: "SlowWildServer API"
  4. desc: "This is the API definition for SlowWildServer"
  5. version: "1.0.0"
  6. )
  7. type (
  8. UserEntity {
  9. id int64 `json:"id"`
  10. avatar string `json:"avatar"`
  11. nickname string `json:"nickname"`
  12. username string `json:"username"`
  13. phone string `json:"phone"`
  14. status int32 `json:"status"`
  15. sex int32 `json:"sex"`
  16. follows int64 `json:"follows"`
  17. followings int64 `json:"followings"`
  18. get_likes_count int32 `json:"get_likes_count"`
  19. get_collection_count int32 `json:"get_collection_count"`
  20. }
  21. UserInfo {
  22. id int64 `json:"id"`
  23. avatar string `json:"avatar"`
  24. nickname string `json:"nickname"`
  25. sex int32 `json:"sex"`
  26. }
  27. FollowUserInfo {
  28. user UserInfo `json:"user"`
  29. is_mutual_follow bool `json:"is_mutual_follow"`
  30. }
  31. LoginAndRegisterRsp {
  32. token string `json:"token"`
  33. expire int64 `json:"expire"`
  34. }
  35. LoginReq {
  36. phone string `json:"phone"`
  37. password string `json:"password"`
  38. code string `json:"code"`
  39. login_type int32 `json:"login_type"`
  40. login_ip string `json:"login_ip"`
  41. }
  42. RegisterReq {
  43. phone string `json:"phone"`
  44. nickname string `json:"nickname"`
  45. password string `json:"password"`
  46. avatar string `json:"avatar"`
  47. sex int32 `json:"sex"`
  48. username string `json:"username"`
  49. code string `json:"code"`
  50. }
  51. GetUserInfoReq {
  52. user_id int64 `json:"user_id"`
  53. query_user_id int64 `json:"query_user_id"`
  54. }
  55. GetUserInfoResp {
  56. id int64 `json:"id"`
  57. avatar string `json:"avatar"`
  58. nickname string `json:"nickname"`
  59. sex int32 `json:"sex"`
  60. is_follow bool `json:"is_follow"`
  61. }
  62. FindUserReq {
  63. username string `json:"username"`
  64. phone string `json:"phone"`
  65. ids []int64 `json:"ids"`
  66. }
  67. FindUserResp {
  68. user_list []UserInfo `json:"user_list"`
  69. }
  70. FollowUserReq {
  71. user_id int64 `json:"user_id"`
  72. follow_user_id int64 `json:"follow_user_id"`
  73. }
  74. FollowUserRes {
  75. success bool `json:"success"`
  76. }
  77. UnFollowUserReq {
  78. user_id int64 `json:"user_id"`
  79. un_follow_user_id int64 `json:"un_follow_user_id"`
  80. }
  81. UnFollowUserRes {
  82. success bool `json:"success"`
  83. }
  84. GetFollowingReq {
  85. user_id int64 `json:"user_id"`
  86. page_size int32 `json:"page_size"`
  87. page int32 `json:"page"`
  88. query_user_id int64 `json:"query_user_id"`
  89. }
  90. GetFollowingRes {
  91. list []FollowUserInfo `json:"list"`
  92. total int64 `json:"total"`
  93. }
  94. GetFollowReq {
  95. user_id int64 `json:"user_id"`
  96. page_size int32 `json:"page_size"`
  97. page int32 `json:"page"`
  98. query_user_id int64 `json:"query_user_id"`
  99. }
  100. GetFollowRes {
  101. list []FollowUserInfo `json:"list"`
  102. total int64 `json:"total"`
  103. }
  104. GetUserProfileReq {
  105. user_id int64 `json:"user_id"`
  106. }
  107. GetUserProfileRes {
  108. id int64 `json:"id"`
  109. nickname string `json:"nickname"`
  110. username string `json:"username"`
  111. status int32 `json:"status"`
  112. avatar string `json:"avatar"`
  113. phone string `json:"phone"`
  114. tweet_count int32 `json:"tweet_count"`
  115. is_following bool `json:"is_following"`
  116. created_on int64 `json:"created_on"`
  117. follows int64 `json:"follows"`
  118. fans int64 `json:"fans"`
  119. get_likes_count int32 `json:"get_likes_count"`
  120. get_collection_count int32 `json:"get_collection_count"`
  121. sex int32 `json:"sex"`
  122. }
  123. SearchUsernameReq {
  124. keyword string `json:"keyword"`
  125. page int32 `json:"page"`
  126. page_size int32 `json:"page_size"`
  127. user_id int64 `json:"user_id"`
  128. }
  129. SearchUsernameItem {
  130. nickname string `json:"nickname"`
  131. avatar string `json:"avatar"`
  132. id int64 `json:"id"`
  133. sex int32 `json:"sex"`
  134. is_follow bool `json:"is_follow"`
  135. }
  136. SearchUsernameRes {
  137. list []SearchUsernameItem `json:"list"`
  138. total int64 `json:"total"`
  139. }
  140. CreateTag {
  141. name string `json:"name"`
  142. id int64 `json:"id"`
  143. }
  144. CreatePostReq {
  145. user_id int64 `json:"user_id"`
  146. title string `json:"title"`
  147. content string `json:"content"`
  148. tags []CreateTag `json:"tags"`
  149. at_user_ids []int64 `json:"at_user_ids"`
  150. post_type int32 `json:"post_type"`
  151. visibility int32 `json:"visibility"`
  152. images []string `json:"images"`
  153. video_cover string `json:"video_cover"`
  154. video_url string `json:"video_url"`
  155. ip string `json:"ip"`
  156. ip_loc string `json:"ip_loc"`
  157. }
  158. CreatePostRsp {
  159. post_id int64 `json:"post_id"`
  160. }
  161. GetTagListReq {
  162. page int32 `json:"page"`
  163. page_size int32 `json:"page_size"`
  164. tag_name string `json:"tag_name"`
  165. sort_by int32 `json:"sort_by"`
  166. }
  167. TagItem {
  168. name string `json:"name"`
  169. hot_num int64 `json:"hot_num"`
  170. user UserInfo `json:"user"`
  171. id int64 `json:"id"`
  172. created_on int64 `json:"created_on"`
  173. }
  174. GetTagListRsp {
  175. tag_list []TagItem `json:"tag_list"`
  176. total int32 `json:"total"`
  177. }
  178. GetTagReq {
  179. tag_id int64 `json:"tag_id"`
  180. user_id int64 `json:"user_id"`
  181. }
  182. GetTagRsp {
  183. name string `json:"name"`
  184. hot_num int64 `json:"hot_num"`
  185. user UserInfo `json:"user"`
  186. id int64 `json:"id"`
  187. created_on int64 `json:"created_on"`
  188. post_count int64 `json:"post_count"`
  189. follow_count int64 `json:"follow_count"`
  190. is_followed bool `json:"is_followed"`
  191. }
  192. GetPostListReq {
  193. page int32 `json:"page"`
  194. page_size int32 `json:"page_size"`
  195. search_type int32 `json:"search_type"`
  196. sort_type int32 `json:"sort_type"`
  197. keyword string `json:"keyword"`
  198. user_id int64 `json:"user_id"`
  199. }
  200. GetPostListItem {
  201. id int64 `json:"id"`
  202. user UserInfo `json:"user"`
  203. title string `json:"title"`
  204. content_summary string `json:"content_summary"`
  205. post_type int32 `json:"post_type"`
  206. comment_count int64 `json:"comment_count"`
  207. upvote_count int64 `json:"upvote_count"`
  208. collection_count int64 `json:"collection_count"`
  209. share_count int64 `json:"share_count"`
  210. visibility int32 `json:"visibility"`
  211. ip_loc string `json:"ip_loc"`
  212. hot_num int64 `json:"hot_num"`
  213. images []string `json:"images"`
  214. video_url string `json:"video_url"`
  215. video_cover string `json:"video_cover"`
  216. created_on int64 `json:"created_on"`
  217. tags []TagItem `json:"tags"`
  218. is_liked bool `json:"is_liked"`
  219. is_collected bool `json:"is_collected"`
  220. is_mine bool `json:"is_mine"`
  221. }
  222. GetPostListRsp {
  223. list []GetPostListItem `json:"list"`
  224. total int64 `json:"total"`
  225. }
  226. GetPostReq {
  227. user_id int64 `json:"user_id"`
  228. post_id int64 `json:"post_id"`
  229. }
  230. GetPostRsp {
  231. id int64 `json:"id"`
  232. user UserInfo `json:"user"`
  233. title string `json:"title"`
  234. content_summary string `json:"content_summary"`
  235. post_type int32 `json:"post_type"`
  236. comment_count int64 `json:"comment_count"`
  237. upvote_count int64 `json:"upvote_count"`
  238. collection_count int64 `json:"collection_count"`
  239. share_count int64 `json:"share_count"`
  240. visibility int32 `json:"visibility"`
  241. ip_loc string `json:"ip_loc"`
  242. hot_num int64 `json:"hot_num"`
  243. images []string `json:"images"`
  244. video_url string `json:"video_url"`
  245. video_cover string `json:"video_cover"`
  246. content string `json:"content"`
  247. created_on int64 `json:"created_on"`
  248. tags []TagItem `json:"tags"`
  249. with_user []UserInfo `json:"with_user"`
  250. latest_replied_on int64 `json:"latest_replied_on"`
  251. is_liked bool `json:"is_liked"`
  252. is_collected bool `json:"is_collected"`
  253. is_mine bool `json:"is_mine"`
  254. }
  255. PostUpvoteReq {
  256. post_id int64 `json:"post_id"`
  257. user_id int64 `json:"user_id"`
  258. }
  259. PostUpvoteRsp {
  260. success bool `json:"success"`
  261. }
  262. PostCollectionReq {
  263. post_id int64 `json:"post_id"`
  264. user_id int64 `json:"user_id"`
  265. }
  266. PostCollectionRsp {
  267. success bool `json:"success"`
  268. }
  269. PostShareReq {
  270. post_id int64 `json:"post_id"`
  271. user_id int64 `json:"user_id"`
  272. }
  273. PostShareRsp {
  274. success bool `json:"success"`
  275. }
  276. PostCommentReq {
  277. post_id int64 `json:"post_id"`
  278. user_id int64 `json:"user_id"`
  279. content string `json:"content"`
  280. image string `json:"image"`
  281. at_user_id int64 `json:"at_user_id"`
  282. ip string `json:"ip"`
  283. ip_loc string `json:"ip_loc"`
  284. }
  285. PostCommentRsp {
  286. comment_id int64 `json:"comment_id"`
  287. }
  288. PostReplyReq {
  289. post_id int64 `json:"post_id"`
  290. user_id int64 `json:"user_id"`
  291. content string `json:"content"`
  292. image string `json:"image"`
  293. at_user_id int64 `json:"at_user_id"`
  294. ip string `json:"ip"`
  295. ip_loc string `json:"ip_loc"`
  296. comment_id int64 `json:"comment_id"`
  297. to_reply_id int64 `json:"to_reply_id"`
  298. }
  299. PostReplyRsp {
  300. reply_id int64 `json:"reply_id"`
  301. }
  302. GetPostCommentListReq {
  303. page int32 `json:"page"`
  304. page_size int32 `json:"page_size"`
  305. post_id int64 `json:"post_id"`
  306. user_id int64 `json:"user_id"`
  307. }
  308. RepliesItem {
  309. id int64 `json:"id"`
  310. post_id int64 `json:"post_id"`
  311. user UserInfo `json:"user"`
  312. ip_loc string `json:"ip_loc"`
  313. content string `json:"content"`
  314. image string `json:"image"`
  315. with_user []UserInfo `json:"with_user"`
  316. upvote_count int64 `json:"upvote_count"`
  317. is_liked bool `json:"is_liked"`
  318. is_mine bool `json:"is_mine"`
  319. created_on int64 `json:"created_on"`
  320. }
  321. CommentItem {
  322. id int64 `json:"id"`
  323. post_id int64 `json:"post_id"`
  324. user UserInfo `json:"user"`
  325. ip_loc string `json:"ip_loc"`
  326. content string `json:"content"`
  327. image string `json:"image"`
  328. with_user []UserInfo `json:"with_user"`
  329. reply_count int64 `json:"reply_count"`
  330. upvote_count int64 `json:"upvote_count"`
  331. reply_item []RepliesItem `json:"reply_item"`
  332. is_liked bool `json:"is_liked"`
  333. is_mine bool `json:"is_mine"`
  334. created_on int64 `json:"created_on"`
  335. }
  336. GetPostCommentListRsp {
  337. list []CommentItem `json:"list"`
  338. total int64 `json:"total"`
  339. }
  340. GetReplyListReq {
  341. page int32 `json:"page"`
  342. page_size int32 `json:"page_size"`
  343. comment_id int64 `json:"comment_id"`
  344. user_id int64 `json:"user_id"`
  345. }
  346. GetReplyListRsp {
  347. list []RepliesItem `json:"list"`
  348. total int64 `json:"total"`
  349. }
  350. PostCommentUpvoteReq {
  351. user_id int64 `json:"user_id"`
  352. comment_id int64 `json:"comment_id"`
  353. comment_type int32 `json:"comment_type"`
  354. }
  355. PostCommentUpvoteRsp {
  356. success bool `json:"success"`
  357. }
  358. PostDeleteReq {
  359. user_id int64 `json:"user_id"`
  360. post_id int64 `json:"post_id"`
  361. }
  362. PostDeleteRsp {
  363. success bool `json:"success"`
  364. }
  365. CommentDeleteReq {
  366. user_id int64 `json:"user_id"`
  367. comment_id int64 `json:"comment_id"`
  368. comment_type int32 `json:"comment_type"`
  369. }
  370. CommentDeleteRsp {
  371. success bool `json:"success"`
  372. }
  373. GetUserPostListReq {
  374. user_id int64 `json:"user_id"`
  375. page int64 `json:"page"`
  376. page_size int64 `json:"page_size"`
  377. query_user_id int64 `json:"query_user_id"`
  378. }
  379. GetUserPostListRsp {
  380. list []GetPostListItem `json:"list"`
  381. total int64 `json:"total"`
  382. }
  383. GetUserPostCollectionListReq {
  384. user_id int64 `json:"user_id"`
  385. page int64 `json:"page"`
  386. page_size int64 `json:"page_size"`
  387. query_user_id int64 `json:"query_user_id"`
  388. }
  389. GetUserPostCollectionListRsp {
  390. list []GetPostListItem `json:"list"`
  391. total int64 `json:"total"`
  392. }
  393. GetUserPostLikeListReq {
  394. user_id int64 `json:"user_id"`
  395. page int64 `json:"page"`
  396. page_size int64 `json:"page_size"`
  397. query_user_id int64 `json:"query_user_id"`
  398. }
  399. GetUserPostLikeListRsp {
  400. list []GetPostListItem `json:"list"`
  401. total int64 `json:"total"`
  402. }
  403. )
  404. @server (
  405. perfix: /v1
  406. )
  407. service slowwild {
  408. @doc "登录方法"
  409. @handler login
  410. post /api/user/login (LoginReq) returns (LoginAndRegisterRsp)
  411. @doc "用户注册"
  412. @handler register
  413. post /api/user/register (RegisterReq) returns (LoginAndRegisterRsp)
  414. }
  415. @server (
  416. perfix: /v1
  417. jwt: Auth // 开启 jwt 认证
  418. )
  419. service slowwild {
  420. @doc "获取用户信息"
  421. @handler getUserInfo
  422. get /api/user/info (GetUserInfoReq) returns (GetUserInfoResp)
  423. @doc "查询用户"
  424. @handler findUser
  425. post /api/user/find (FindUserReq) returns (FindUserResp)
  426. @doc "关注用户"
  427. @handler followUser
  428. post /api/user/follow (FollowUserReq) returns (FollowUserRes)
  429. @doc "取消关注用户"
  430. @handler unfollowUser
  431. post /api/user/unfollow (UnFollowUserReq) returns (UnFollowUserRes)
  432. @doc "获取粉丝"
  433. @handler getFans
  434. get /api/user/fans (GetFollowingReq) returns (GetFollowingRes)
  435. @doc "获取关注列表"
  436. @handler getFollows
  437. get /api/user/follows (GetFollowReq) returns (GetFollowRes)
  438. @doc "获取用户信息"
  439. @handler getUserProfile
  440. get /api/user/profile (GetUserProfileReq) returns (GetUserProfileRes)
  441. @doc "搜索用户"
  442. @handler searchUsername
  443. get /api/user/search (SearchUsernameReq) returns (SearchUsernameRes)
  444. }
  445. @server (
  446. perfix: /v1
  447. jwt: Auth
  448. )
  449. service slowwild {
  450. @doc "创建帖子"
  451. @handler createPost
  452. post /api/post/create (CreatePostReq) returns (CreatePostRsp)
  453. @doc "帖子点赞"
  454. @handler postUpvote
  455. post /api/post/upvote (PostUpvoteReq) returns (PostUpvoteRsp)
  456. @doc "帖子收藏"
  457. @handler postCollection
  458. post /api/post/collection (PostCollectionReq) returns (PostCollectionRsp)
  459. @doc "帖子分享"
  460. @handler postShare
  461. post /api/post/share (PostShareReq) returns (PostShareRsp)
  462. @doc "发布评论"
  463. @handler postComment
  464. post /api/post/comment (PostCommentReq) returns (PostCommentRsp)
  465. @doc "回复评论"
  466. @handler postReply
  467. post /api/post/reply (PostReplyReq) returns (PostReplyRsp)
  468. @doc "评论点赞"
  469. @handler postCommentUpvote
  470. post /api/post/comment/upvote (PostCommentUpvoteReq) returns (PostCommentUpvoteRsp)
  471. @doc "帖子删除"
  472. @handler postDelete
  473. post /api/post/delete (PostDeleteReq) returns (PostDeleteRsp)
  474. @doc "评论删除"
  475. @handler commentDelete
  476. post /api/comment/delete (CommentDeleteReq) returns (CommentDeleteRsp)
  477. }
  478. @server (
  479. perfix: /v1
  480. middleware: OptionalJwtMiddleware
  481. )
  482. service slowwild {
  483. @doc "获取话题列表"
  484. @handler getTagList
  485. get /api/tag/list (GetTagListReq) returns (GetTagListRsp)
  486. @doc "获取话题详情"
  487. @handler getTag
  488. get /api/tag (GetTagReq) returns (GetTagRsp)
  489. @doc "获取帖子列表"
  490. @handler getPostList
  491. get /api/post/list (GetPostListReq) returns (GetPostListRsp)
  492. @doc "获取帖子详情"
  493. @handler getPost
  494. get /api/post (GetPostReq) returns (GetPostRsp)
  495. @doc "获取评论列表"
  496. @handler getPostCommentList
  497. get /api/post/comment/list (GetPostCommentListReq) returns (GetPostCommentListRsp)
  498. @doc "获取回复列表"
  499. @handler getReplyList
  500. get /api/post/reply/list (GetReplyListReq) returns (GetReplyListRsp)
  501. @doc "获取用户发布的帖子列表"
  502. @handler getUserPostList
  503. get /api/user/post/list (GetUserPostListReq) returns (GetUserPostListRsp)
  504. @doc "获取用户收藏的帖子列表"
  505. @handler getUserPostCollectionList
  506. get /api/user/post/collection/list (GetUserPostCollectionListReq) returns (GetUserPostCollectionListRsp)
  507. @doc "获取用户点赞的帖子列表"
  508. @handler getUserPostLikeList
  509. get /api/user/post/like/list (GetUserPostLikeListReq) returns (GetUserPostLikeListRsp)
  510. }