rest_client.dart 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. import 'dart:io';
  2. import 'package:dio/dio.dart' hide Headers;
  3. import 'package:retrofit/retrofit.dart';
  4. import 'package:sport/bean/UpdateInfo.dart';
  5. import 'package:sport/bean/comment.dart';
  6. import 'package:sport/bean/comment_post.dart';
  7. import 'package:sport/bean/feedback_category.dart';
  8. import 'package:sport/bean/forum.dart';
  9. import 'package:sport/bean/game.dart';
  10. import 'package:sport/bean/game_record.dart';
  11. import 'package:sport/bean/game_record_sum.dart';
  12. import 'package:sport/bean/image.dart';
  13. import 'package:sport/bean/notice.dart';
  14. import 'package:sport/bean/post.dart';
  15. import 'package:sport/bean/rank_game_info.dart';
  16. import 'package:sport/bean/rank_info.dart';
  17. import 'package:sport/bean/share_info.dart';
  18. import 'package:sport/bean/shop.dart';
  19. import 'package:sport/bean/sport_detail.dart';
  20. import 'package:sport/bean/sport_index.dart';
  21. import 'package:sport/bean/sport_step.dart';
  22. import 'package:sport/bean/sport_target.dart';
  23. import 'package:sport/bean/sport_target_index.dart';
  24. import 'package:sport/bean/sport_target_record.dart';
  25. import 'package:sport/bean/sport_target_today.dart';
  26. import 'package:sport/bean/user_friend.dart';
  27. import 'package:sport/bean/user_info.dart';
  28. import 'package:sport/services/api/resp.dart';
  29. import 'package:sport/bean/message.dart';
  30. part 'rest_client.g.dart';
  31. @RestApi()
  32. abstract class RestClient {
  33. factory RestClient(Dio dio, {String baseUrl}) = _RestClient;
  34. @GET("/app/checkUpdate")
  35. Future<RespData<UpdateInfo>> checkUpdate(@Query("version") String version);
  36. @GET("/user/info")
  37. Future<RespData<UserInfo>> getUserInfo(@Query("id") String uid, {@DioOptions() Options options});
  38. @GET("/user/countNameCard")
  39. Future<RespData<int>> getCountNameCard();
  40. // ********************** 运动首页相关 *****************************
  41. @GET("/sport/index")
  42. Future<RespData<SportIndex>> getSportIndex();
  43. @GET("/sport/detail")
  44. Future<RespData<SportDetail>> getSportDetail();
  45. @POST("/sportRecord/addGame")
  46. Future<RespList<SportTarget>> postAddGame(
  47. @Query("game_id") int gameId,
  48. @Query("score") double score,
  49. @Query("duration") int duration,
  50. @Query("consume") int consume,
  51. @Query("screen") int screen,
  52. @Query("jump_count") int jumpCount,
  53. @Query("crouch_count") int crouchCount,
  54. @Query("step_count") int stepCount,
  55. @Query("distance") int distance);
  56. @GET("/sportTarget/all")
  57. Future<RespList<SportTarget>> getSportTargetAll();
  58. @GET("/sportTarget/setold")
  59. Future<RespData<SportTargetToday>> setSportTarget(@Query("id") int id);
  60. @GET("/sportTarget/set")
  61. Future<RespData<SportTargetToday>> setSportTargetToday(@Query("type") String type,{@Query("consume") int consume, @Query("duration_minute") int durationMinute});
  62. @GET("/sportTarget/setCustom")
  63. Future<RespData<SportTargetToday>> setSportTargetCustom(@Query("duration") int duration, @Query("consume") int consume);
  64. @GET("/sportTarget/del")
  65. Future<Resp> delSportTarget();
  66. @GET("/sportTarget/my")
  67. Future<RespData<SportTargetToday>> getSportTargetMy();
  68. @GET("/sportTarget/index")
  69. Future<RespData<SportTargetIndex>> getSportTargetIndex();
  70. @GET("/sportTarget/records")
  71. Future<RespList<SportTargetRecord>> getSportTargetRecord(@Query("year") int year, @Query("month") int month);
  72. @FormUrlEncoded()
  73. @POST("/sportTarget/reward")
  74. Future<RespData<String>> sportTargetReward(@Query("id") int id);
  75. @GET("/sportRecord/listOneDay")
  76. Future<RespData<SportDetailSimple>> getSportRecordListOneDay(@Query("date") String date);
  77. @GET("/sportRecord/listByDay")
  78. Future<RespData<SportDetailSimple>> getSportRecordListByDay(@Query("begin") String begin, @Query("end") String end);
  79. @GET("/sportRecord/listByMonth")
  80. Future<RespData<SportDetailSimple>> getSportRecordListByMonth(@Query("year") int year);
  81. @GET("/sportRecord/listByYear")
  82. Future<RespData<SportDetailSimple>> getSportRecordListByYear();
  83. @GET("/sportRecord/list")
  84. Future<RespPage<RecordsTodaySum>> getSportRecordList(@Query("game_id") int gameId, {@Query("page") int page});
  85. @FormUrlEncoded()
  86. @POST("/stepRecord/addDaily")
  87. Future<RespData<SportStep>> addDaily({@Query("step") int step, @Query("distance") int distance, @Query("time") String time, @Field("data") String data});
  88. @GET("/stepRecord/listOneDay")
  89. Future<RespData<SportStep>> getStepRecordListOneDay(@Query("date") String date);
  90. @GET("/stepRecord/listByDay")
  91. Future<RespData<SportStep>> getStepRecordListByDay(@Query("begin") String begin, @Query("end") String end);
  92. @GET("/stepRecord/listByMonth")
  93. Future<RespData<SportStep>> getStepRecordListByMonth(@Query("year") int year);
  94. @GET("/stepRecord/listByYear")
  95. Future<RespData<SportStep>> getStepRecordListByYear();
  96. @GET("/gameRecord/sum")
  97. Future<RespList<GameRecordSum>> getGameRecordSum();
  98. @GET("/gameRecord/game")
  99. Future<RespData<GameRecord>> getGameRecord(@Query("id") int gameId);
  100. @GET("/rank/game")
  101. Future<RespData<RankInfo>> getRankInfo(@Query("game_id") String gameId,
  102. {@Query("province_id") int provinceId, @Query("city_id") int cityId, @Query("district_id") int districtId});
  103. // ********************** 社区相关 *****************************
  104. @GET("/forum/index")
  105. Future<RespList<Forum>> getForumIndex();
  106. @GET("/forum/list")
  107. Future<RespPage<Post>> getPostList({@Query("forumId") String forumId, @Query("p") int page, @Query("isGood") int isGood, @Query("kw") String kw ,@Query("isOfficial") String isOfficial,});
  108. @GET("/forum/listByOfficial")
  109. Future<RespPage<Post>> getPostListByOfficial({@Query("forumId") String forumId, @Query("p") int page, @Query("limit") int limit, @Query("sortBy") String sortBy,@Query("isOfficial") String isOfficial});
  110. @GET("/forum/listByHot")
  111. Future<RespPage<Post>> getPostListByHot({@Query("forumId") String forumId,@Query("p") int page,@Query("isOfficial") String isOfficial, @DioOptions() Options options});
  112. @GET("/forum/listByUser")
  113. Future<RespPage<Post>> getPostListByUser(@Query("uid") String uid,
  114. {@Query("forumId") String forumId, @Query("p") int page, @Query("sortBy") String sortBy, @Query("removeTop") int removeTop,@Query("isOfficial") String isOfficial});
  115. @GET("/forum/listByFollow")
  116. Future<RespPage<Post>> getPostListByFollow(@Query("uid") String uid, {@Query("forumId") String forumId,@Query("p") int page, @Query("limit") int limit, @Query("testuid") int testuid, @Query("sortBy") String sortBy,@Query("isOfficial") String isOfficial,@DioOptions() Options options});
  117. @GET("/forum/subjectDetail")
  118. Future<RespData<Post>> getPostDetail(@Query("subjectId") String subjectId);
  119. @GET("/forum/comments")
  120. Future<RespPage<Comment>> getPostComments(@Query("subjectId") String subjectId, {@Query("p") int page, @Query("sortBy") String sortBy});
  121. @GET("/forum/subComments")
  122. Future<RespPage<Comment>> getPostCommentSubs(@Query("parentCommentId") String parentCommentId, {@Query("p") int page, @Query("sortBy") String sortBy});
  123. @GET("/forum/commentsFromId")
  124. Future<RespList<Comment>> getPostCommentsFromId(@Query("commentId") String commentId, {@Query("limit") int limit, @Query("sortBy") String sortBy});
  125. @GET("/forum/hotSearchWords")
  126. Future<RespList<String>> getSearchWords();
  127. @POST("/forum/like")
  128. Future<RespData<String>> postForumLike(@Query("objectId") String objectId, @Query("fieldName") String fieldName);
  129. @POST("/forum/unlike")
  130. Future<RespData<String>> postForumUnLike(@Query("objectId") String objectId, @Query("fieldName") String fieldName);
  131. @POST("/forum/delSubject")
  132. Future<RespData<String>> postDelSubject(@Query("subjectId") String subjectId);
  133. @POST("/forum/delComment")
  134. Future<RespData<String>> postDelComment(@Query("commentId") String commentId);
  135. @POST("/forum/report")
  136. Future<RespData<String>> postForumReport({@Query("subjectId") String subjectId, @Query("commentId") String commentId, @Query("content") String content,@Query("userId") int userId});
  137. @POST("/forum/blockUser")
  138. Future<RespList<int>> postForumBlockUser(@Query("uid") String uid);
  139. @POST("/forum/unblockUser")
  140. Future<RespList<int>> postForumUnBlockUser(@Query("uid") String uid);
  141. @GET("/forum/myBlockUsers")
  142. Future<RespList<UserInfo>> getMyBlockUsers();
  143. @POST("/forum/blockObject")
  144. Future<RespData<String>> postForumBlockObject(@Query("objectId") String objectId, @Query("for") String forName);
  145. @POST("/forum/postComment")
  146. Future<RespData<CommentPost>> postForumComment(@Query("subjectId") String subjectId, @Query("content") String content,
  147. {@Query("parentCommentId") String parentCommentId, @Query("toCommentId") String toCommentId});
  148. @POST("/forum/post")
  149. Future<RespData<Map<String, dynamic>>> postForum(@Query("forumId") String forumId, @Query("content") String content,
  150. {@Query("images") String images,
  151. @Query("quoteSubjectId") String quoteSubjectId,
  152. @Query("quoteCommentId") String quoteCommentId,
  153. @Query("quoteData") String quoteData,
  154. CancelToken cancelToken});
  155. @POST("/forum/setUserTopSubjects")
  156. Future<RespData<String>> setUserTopSubjects(@Query("subjectIdList") String subjectIdList);
  157. @POST("/forum/unsetUserTopSubjects")
  158. Future<RespData<String>> unsetUserTopSubjects(@Query("subjectIdList") String subjectIdList);
  159. @GET("/forum/userTopSubjects")
  160. Future<RespList<Post>> getPostUserTopSubjects(@Query("uid") String uid,
  161. {@Query("forumId") String forumId, @Query("p") int page, @Query("sortBy") String sortBy});
  162. @POST("/forum/follow")
  163. Future<RespData<String>> userFollow({@Query("uid") int uid, @Query("groupId") String groupId, @Query("groupName") String groupName});
  164. @POST("/forum/unfollow")
  165. Future<RespData<String>> userUnFollow({@Query("uid") int uid});
  166. @POST("/forum/ignoreFollow")
  167. Future<RespData<String>> userIgnoreFollow({@Query("uid") int uid});
  168. @GET("/forum/followList")
  169. Future<RespListTest<UserFriend>> userFollowList({@Query("groupId") String groupId, @Query("kw") String kw, @Query("p") int page, @Query("limit") int limit = 50});
  170. @GET("/forum/fansList")
  171. Future<RespListTest<UserFriend>> userFansList({@Query("groupId") String groupId, @Query("kw") String kw, @Query("p") int page, @Query("limit") int limit = 50});
  172. @GET("/forum/friends")
  173. Future<RespList<UserFriend>> userFriends({@Query("groupId") String groupId, @Query("kw") String kw, @Query("p") int page, @Query("limit") int limit = 50 ,@Query("test") String test,});
  174. @GET("/forum/friends")
  175. Future<RespListTest<UserFriend>> userFriendsTest({@Query("groupId") String groupId, @Query("kw") String kw, @Query("p") int page, @Query("limit") int limit = 50 ,@Query("test") String test,});
  176. @GET("/user/search")
  177. Future<RespPage<UserInfo>> userSearch({@Query("kw") String kw, @Query("p") int page, @Query("limit") int limit = 20});
  178. @POST("/user/newFriendCode")
  179. Future<RespData> getNewFriendCode({@Query("forever") int forever, @Query("forceUpate") int forceUpdate,});
  180. @POST("/user/newFriend")
  181. Future<RespData<NewFriend>> getNewFriend(@Query("code") String code);
  182. @POST("/share/forwardSubject")
  183. Future<RespData<MessageInstance>> shareForwardSubject(@Query("subject_id") int subjectId,@Query("user_id") int userId,);
  184. @POST("/message/receive")
  185. Future<RespData<Message>> getMessageForPoll({@Query("cur_id") int curId});
  186. @POST("/user/FetchFriendsRequest")
  187. Future<RespList<UserFriend>> getFriendRequest();
  188. @POST("/user/RejectFriend")
  189. Future<RespData<bool>> postRejectFriend(@Query("uid") int uid);
  190. @POST("/user/AcceptFriend")
  191. Future<RespData> postAcceptFriend(@Query("uid") int uid);
  192. @POST("/user/isFriend")
  193. Future<RespData<bool>> postIsFriend(@Query("uid") int uid);
  194. // ********************** 聊天相关 *****************************
  195. @POST("/chat/index")
  196. Future<RespList<ChatMessageInstance>> getChatIndex();
  197. @POST("/chat/user")
  198. Future<RespData<ChatMessage>> getChatUser(@Query("user_id") int userId,{@Query("begin_id") int beginId});
  199. @POST("/chat/send")
  200. Future<RespData<MessageInstance>> postChatSend(@Query("user_id") int userId,@Query("type") String type,@Query("data") String data,);
  201. @POST("/chat/upload")
  202. @Headers(<String, dynamic>{
  203. "content-type": "multipart/form-data",
  204. })
  205. Future<RespData> postChatUpload(@Part(name: "file") File file,);
  206. @POST("/chat/info")
  207. Future<RespList<ChatOnlineInfo>> getChatUserInfo(@Query("user_ids") List<int> userIds,);
  208. // ********************** 分享相关 *****************************
  209. @POST("/share/createSport")
  210. Future<RespData<ShareInfo>> getshareCreateSport(@Query("period") String period,@Query("weight") double weight);
  211. @POST("/share/forwardSport")
  212. Future<RespData<MessageInstance>> getshareForwardSport(@Query("h") String hash,@Query("user_id") int userId);
  213. // ********************** 公告相关 *****************************
  214. @GET("/inform/list")
  215. Future<RespPage<Notice>> getInformList({@Query("p") int page});
  216. @POST("/inform/read")
  217. Future<RespData> postInformRead(@Query("informId") int informId);
  218. @GET("/notice/list")
  219. Future<RespPage<Notice>> getNoticeList(
  220. {@Query("type") String type,
  221. @Query("markread") String markread = "currpage",
  222. @Query("p") int page,
  223. @Query("read") String read,
  224. @Query("isMsg") String isMsg = "1"});
  225. @GET("/notice/count")
  226. Future<RespData<int>> getNoticeCount(@Query("type") String type, @Query("read") String read, {@Query("isMsg") String isMsg = "1"});
  227. @POST("/notice/read")
  228. Future<RespData<Notice>> postNoticeRead(@Query("noticeId") int noticeId);
  229. // ********************** 反馈相关 *****************************
  230. @GET("/feedback/types")
  231. Future<RespList<FeedbackCategory>> getFeedbackTypes();
  232. @GET("/feedback/myChats")
  233. Future<RespList<FeedbackCategory>> getFeedbackChat({@Query("groupId") int groupId, @Query("typeId") int typeId});
  234. @POST("/feedback/post")
  235. Future<RespData<String>> postFeedback(@Query("typeId") int typeId, @Query("content") String content,
  236. {@Query("images") String images, @Query("extra") String extra});
  237. @POST("/media/Up4Feedback")
  238. @Headers(<String, dynamic>{
  239. "content-type": "multipart/form-data",
  240. })
  241. Future<RespData<String>> mediaUp4Feedback(@Part(name: "media") File file);
  242. @POST("/media/Up4Subject")
  243. @Headers(<String, dynamic>{
  244. "content-type": "multipart/form-data",
  245. })
  246. Future<RespData<Image>> mediaUp4Subject(@Part(name: "media") File file,
  247. {@Query("srcType") String srcType, @Query("subjectId") String subjectId, CancelToken cancelToken});
  248. // ********************** 游戏相关 *********************************
  249. @GET("/game/all")
  250. Future<RespList<GameInfoData>> getGameAll();
  251. @GET("/game/all")
  252. Future getGameById(@Query("id") int id);
  253. @GET("/rank/all")
  254. Future<RespList<RankInfoData>> getRankInfoAll();
  255. @GET("/rank/game")
  256. Future<RespData<RankGameInfoData>> getRankGameInfo(@Query("game_id") String id,
  257. {@Query("scope") String scope});
  258. @GET("/rank/sport")
  259. Future<RespData<RankGameInfoData>> getRankSportInfo(@Query("rank_id") String id,
  260. {@Query("scope") String scope});
  261. // ********************** 商城相关 *********************************
  262. @GET("/shop/item")
  263. Future<RespData<ShopIndex>> getShopIndex();
  264. @GET("/score/record")
  265. Future<RespData<ScoreList>> getScoreIndex();
  266. @POST("/shop/buy")
  267. Future<RespData<String>> buyItem(@Query("item_id") String id,);
  268. }