slow_wild.api 15 KB

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