rest_client.dart 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  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_add_entity.dart';
  11. import 'package:sport/bean/game_record.dart';
  12. import 'package:sport/bean/game_record_sum.dart';
  13. import 'package:sport/bean/game_record_history.dart';
  14. import 'package:sport/bean/hardware.dart';
  15. import 'package:sport/bean/image.dart';
  16. import 'package:sport/bean/jog/detail.dart';
  17. import 'package:sport/bean/jog/record.dart';
  18. import 'package:sport/bean/jog/sum.dart';
  19. import 'package:sport/bean/notice.dart';
  20. import 'package:sport/bean/post.dart';
  21. import 'package:sport/bean/rank_game_info.dart';
  22. import 'package:sport/bean/rank_info.dart';
  23. import 'package:sport/bean/share_info.dart';
  24. import 'package:sport/bean/shop.dart';
  25. import 'package:sport/bean/sport_detail.dart';
  26. import 'package:sport/bean/sport_index.dart';
  27. import 'package:sport/bean/exer_index.dart';
  28. import 'package:sport/bean/sport_step.dart';
  29. import 'package:sport/bean/sport_target.dart';
  30. import 'package:sport/bean/sport_target_index.dart';
  31. import 'package:sport/bean/sport_target_record.dart';
  32. import 'package:sport/bean/sport_target_today.dart';
  33. import 'package:sport/bean/user_friend.dart';
  34. import 'package:sport/bean/user_info.dart';
  35. import 'package:sport/services/api/resp.dart';
  36. import 'package:sport/bean/message.dart';
  37. import 'package:sport/bean/friend_list.dart';
  38. import 'package:sport/bean/friend_relation.dart';
  39. part 'rest_client.g.dart';
  40. @RestApi()
  41. abstract class RestClient {
  42. factory RestClient(Dio dio, {String baseUrl}) = _RestClient;
  43. @GET("/app/checkUpdate")
  44. Future<RespData<UpdateInfo>> checkUpdate(@Query("version") String version);
  45. @GET("/app/hardwareLastVer")
  46. Future<RespData<Hardware>> checkHardwareUpdate(@Query("hardware_ver") String ver, @Query("app_ver") String appVer);
  47. @POST("/app/onConnBt")
  48. Future<RespData<String>> onConnBt(@Query("shoes_mac") String shoes_mac, @Query("firmware_ver") String firmware_ver, @Query("hardware_ver") String hardware_ver, @Query("app_ver") String app_ver, @Query("os_name") String os_name, @Query("os_ver") String os_ver, @Query("lang") String lang, @Query("phone_brand") String phone_brand, @Query("phone_model") String phone_model);
  49. @POST("/app/logHardwareErr")
  50. Future<RespData<String>> logHardwareErr(@Query("shoes_mac") String shoes_mac, @Query("firmware_ver") String firmware_ver, @Query("hardware_ver") String hardware_ver, @Query("app_ver") String app_ver, @Query("err_code") String err_code, @Query("err_msg") String err_msg, @Query("err_detail") String err_detail);
  51. @GET("/user/info")
  52. Future<RespData<UserInfo>> getUserInfo(@Query("id") String uid, {@DioOptions() Options? options});
  53. @GET("/user/info")
  54. Future<RespData<UserInfo>> getUserInfoSelf();
  55. @GET("/user/countNameCard")
  56. Future<RespData<int>> getCountNameCard();
  57. // ********************** 运动首页相关 *****************************
  58. @GET("/sport/index")
  59. Future<RespData<SportIndex>> getSportIndex();
  60. @GET("/exer/index")
  61. Future<RespData<ExerIndex>> getExerIndex();
  62. @GET("/sport/detail")
  63. Future<RespData<SportDetail>> getSportDetail();
  64. @POST("/gameRecord/addGame")
  65. Future<RespData<GameAddEntity>> postAddGame(
  66. @Query("game_id") String gameId,
  67. @Query("score") double score,
  68. @Query("level") int level,
  69. @Query("record") int record,
  70. @Query("mode") int mode,
  71. @Query("duration") int duration,
  72. @Query("consume") int consume,
  73. @Query("screen") int screen,
  74. @Query("jump") int jumpCount,
  75. @Query("crouch") int crouchCount,
  76. @Query("step") int stepCount,
  77. @Query("distance") int distance,
  78. @Query("opponent_id") int opponent_id,
  79. @Query("is_cancel") int is_cancel,
  80. @Query("play_group") String play_group,
  81. @Query("movements") String movements,
  82. @Query("time") String time,
  83. );
  84. @GET("/sportTarget/all")
  85. Future<RespList<SportTarget>> getSportTargetAll();
  86. @GET("/sportTarget/setold")
  87. Future<RespData<SportTargetToday>> setSportTarget(@Query("id") int id);
  88. @GET("/sportTarget/set")
  89. Future<RespData<SportTargetToday>> setSportTargetToday(@Query("type") String type, {@Query("consume") int? consume, @Query("duration_minute") int? durationMinute});
  90. @GET("/sportTarget/setCustom")
  91. Future<RespData<SportTargetToday>> setSportTargetCustom(@Query("duration") int duration, @Query("consume") int consume);
  92. @GET("/sportTarget/del")
  93. Future<Resp> delSportTarget();
  94. @GET("/sportTarget/my")
  95. Future<RespData<SportTargetToday>> getSportTargetMy();
  96. @GET("/sportTarget/index")
  97. Future<RespData<SportTargetIndex>> getSportTargetIndex();
  98. @GET("/sportTarget/records")
  99. Future<RespList<SportTargetRecord>> getSportTargetRecord(@Query("year") int year, @Query("month") int month);
  100. @FormUrlEncoded()
  101. @POST("/sportTarget/reward")
  102. Future<RespData<String>> sportTargetReward(@Query("id") int id);
  103. @GET("/exerRecord/listOneDay")
  104. Future<RespData<SportDetailSimple>> getSportRecordListOneDay(@Query("date") String date, {@Query("except_daily") int? exceptDaily});
  105. @GET("/exerRecord/listByDay")
  106. Future<RespData<SportDetailSimple>> getSportRecordListByDay(@Query("begin") String begin, @Query("end") String end, {@Query("except_daily") int? exceptDaily});
  107. @GET("/exerRecord/listByMonth")
  108. Future<RespData<SportDetailSimple>> getSportRecordListByMonth(@Query("year") int year, {@Query("except_daily") int? exceptDaily});
  109. @GET("/exerRecord/listByYear")
  110. Future<RespData<SportDetailSimple>> getSportRecordListByYear({@Query("except_daily") int? exceptDaily});
  111. @GET("/exerRecord/history")
  112. Future<RespList<SportHistory>> getSportRecordHistory(@Query("year") int year);
  113. @GET("/gameRecord/list")
  114. Future<RespPage<RecordsTodaySum>> getSportRecordList(@Query("game_id") int gameId, {@Query("page") int? page});
  115. @FormUrlEncoded()
  116. @POST("/stepRecord/addDaily")
  117. Future<RespData<SportStep>> addDaily({@Query("step") int? step, @Query("distance") int? distance, @Query("time") String? time, @Field("data") String? data});
  118. @GET("/stepRecord/listOneDay")
  119. Future<RespData<SportStep>> getStepRecordListOneDay(@Query("date") String date);
  120. @GET("/stepRecord/listByDay")
  121. Future<RespData<SportStep>> getStepRecordListByDay(@Query("begin") String begin, @Query("end") String end);
  122. @GET("/stepRecord/listByMonth")
  123. Future<RespData<SportStep>> getStepRecordListByMonth(@Query("year") int year);
  124. @GET("/stepRecord/listByYear")
  125. Future<RespData<SportStep>> getStepRecordListByYear();
  126. @GET("/gameRecord/sum")
  127. Future<RespData<GameRecordHistory>> getGameRecordSum();
  128. @GET("/gameRecord/game")
  129. Future<RespData<GameRecord>> getGameRecord(@Query("id") int gameId);
  130. @GET("/rank/game")
  131. Future<RespData<RankInfo>> getRankInfo(@Query("game_id") String gameId, {@Query("province_id") int? provinceId, @Query("city_id") int? cityId, @Query("district_id") int? districtId, @Query("scope") String? scope});
  132. // ********************** 社区相关 *****************************
  133. @GET("/forum/index")
  134. Future<RespList<Forum>> getForumIndex();
  135. @GET("/forum/index2")
  136. Future<RespList<Forum>> getForumIndex2();
  137. @GET("/forum/list")
  138. Future<RespPage<Post>> getPostList({
  139. @Query("forumId") String? forumId,
  140. @Query("p") int? page,
  141. @Query("isGood") int? isGood,
  142. @Query("kw") String? kw,
  143. @Query("isOfficial") String? isOfficial,
  144. });
  145. @GET("/forum/listByOfficial")
  146. Future<RespPage<Post>> getPostListByOfficial({@Query("forumId") String? forumId, @Query("p") int? page, @Query("limit") int? limit, @Query("sortBy") String? sortBy, @Query("isOfficial") String? isOfficial});
  147. @GET("/forum/listByHot")
  148. Future<RespPage<Post>> getPostListByHot({@Query("forumId") String? forumId, @Query("p") int? page, @Query("isOfficial") String? isOfficial, @DioOptions() Options? options});
  149. @GET("/forum/listByUser")
  150. Future<RespPage<Post>> getPostListByUser(@Query("uid") String uid, {@Query("forumId") String? forumId, @Query("p") int? page, @Query("sortBy") String? sortBy, @Query("removeTop") int? removeTop, @Query("isOfficial") String? isOfficial});
  151. @GET("/forum/listByFollow")
  152. 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});
  153. @GET("/forum/subjectDetail")
  154. Future<RespData<Post>> getPostDetail(@Query("subjectId") String subjectId);
  155. @GET("/forum/comments")
  156. Future<RespPage<Comment>> getPostComments(@Query("subjectId") String subjectId, {@Query("p") int? page, @Query("sortBy") String? sortBy});
  157. @GET("/forum/subComments")
  158. Future<RespPage<Comment>> getPostCommentSubs(@Query("parentCommentId") String parentCommentId, {@Query("p") int? page, @Query("sortBy") String? sortBy});
  159. @GET("/forum/commentsFromId")
  160. Future<RespList<Comment>> getPostCommentsFromId(@Query("commentId") String commentId, {@Query("limit") int? limit, @Query("sortBy") String? sortBy});
  161. @GET("/forum/hotSearchWords")
  162. Future<RespList<String>> getSearchWords();
  163. @POST("/forum/like")
  164. Future<RespData<String>> postForumLike(@Query("objectId") String objectId, @Query("fieldName") String fieldName);
  165. @POST("/forum/unlike")
  166. Future<RespData<String>> postForumUnLike(@Query("objectId") String objectId, @Query("fieldName") String fieldName);
  167. @POST("/forum/delSubject")
  168. Future<RespData<String>> postDelSubject(@Query("subjectId") String subjectId);
  169. @POST("/forum/delComment")
  170. Future<RespData<String>> postDelComment(@Query("commentId") String commentId);
  171. @POST("/forum/report")
  172. Future<RespData<String>> postForumReport({@Query("subjectId") String? subjectId, @Query("commentId") String? commentId, @Query("content") String? content, @Query("userId") int? userId});
  173. @POST("/forum/blockUser")
  174. Future<RespList<int>> postForumBlockUser(@Query("uid") String uid);
  175. @POST("/forum/unblockUser")
  176. Future<RespList<int>> postForumUnBlockUser(@Query("uid") String uid);
  177. @GET("/forum/myBlockUsers")
  178. Future<RespList<UserInfo>> getMyBlockUsers();
  179. @POST("/forum/blockObject")
  180. Future<RespData<String>> postForumBlockObject(@Query("objectId") String objectId, @Query("for") String forName);
  181. @POST("/forum/postComment")
  182. Future<RespData<CommentPost>> postForumComment(@Query("subjectId") String subjectId, @Query("content") String content, {@Query("parentCommentId") String? parentCommentId, @Query("toCommentId") String? toCommentId});
  183. @POST("/forum/post")
  184. Future<RespData<Map<String, dynamic>>> postForum(@Query("forumId") String forumId, @Query("content") String content, {@Query("images") String? images, @Query("quoteSubjectId") String? quoteSubjectId, @Query("quoteCommentId") String? quoteCommentId, @Query("quoteData") String? quoteData, CancelToken? cancelToken});
  185. @POST("/forum/setUserTopSubjects")
  186. Future<RespData<String>> setUserTopSubjects(@Query("subjectIdList") String subjectIdList);
  187. @POST("/forum/unsetUserTopSubjects")
  188. Future<RespData<String>> unsetUserTopSubjects(@Query("subjectIdList") String subjectIdList);
  189. @GET("/forum/userTopSubjects")
  190. Future<RespList<Post>> getPostUserTopSubjects(@Query("uid") String uid, {@Query("forumId") String? forumId, @Query("p") int? page, @Query("sortBy") String? sortBy});
  191. @POST("/forum/follow")
  192. Future<RespData<String>> userFollow({@Query("uid") int? uid, @Query("groupId") String? groupId, @Query("groupName") String? groupName});
  193. @POST("/forum/unfollow")
  194. Future<RespData<String>> userUnFollow({@Query("uid") int? uid});
  195. @POST("/forum/ignoreFollow")
  196. Future<RespData<bool>> userIgnoreFollow({@Query("uid") int? uid});
  197. @POST("/forum/UserRelation")
  198. Future<RespData<FriendRelation>> userRelation({@Query("uid") int? uid});
  199. @GET("/forum/followList")
  200. Future<RespData<FriendList>> userFollowList({@Query("groupId") String? groupId, @Query("kw") String? kw, @Query("p") int? page, @Query("limit") int limit = 50});
  201. @GET("/forum/fansList")
  202. Future<RespData<FriendList>> userFansList({@Query("groupId") String? groupId, @Query("kw") String? kw, @Query("p") int? page, @Query("limit") int limit = 50});
  203. @GET("/forum/friends")
  204. Future<RespList<UserFriend>> userFriends({
  205. @Query("groupId") String? groupId,
  206. @Query("kw") String? kw,
  207. @Query("p") int? page,
  208. @Query("limit") int limit = 50,
  209. @Query("test") String? test,
  210. });
  211. @GET("/forum/friends")
  212. Future<RespData<FriendList>> userFriendsTest({
  213. @Query("groupId") String? groupId,
  214. @Query("kw") String? kw,
  215. @Query("p") int? page,
  216. @Query("limit") int limit = 50,
  217. @Query("test") String? test,
  218. });
  219. @GET("/user/search")
  220. Future<RespPage<UserInfo>> userSearch({@Query("kw") String? kw, @Query("p") int? page, @Query("limit") int limit = 20});
  221. @POST("/user/newFriendCode")
  222. Future<RespData> getNewFriendCode({
  223. @Query("forever") int? forever,
  224. @Query("forceUpate") int? forceUpdate,
  225. });
  226. @POST("/user/newFriend")
  227. Future<RespData<NewFriend>> getNewFriend(@Query("code") String code);
  228. @POST("/share/forwardSubject")
  229. Future<RespData<MessageInstance>> shareForwardSubject(
  230. @Query("subject_id") int subjectId,
  231. @Query("user_id") int userId,
  232. );
  233. @POST("/message/receive")
  234. Future<RespData<Message>> getMessageForPoll({@Query("cur_id") int? curId});
  235. @POST("/user/FetchFriendsRequest")
  236. Future<RespList<UserFriend>> getFriendRequest();
  237. @POST("/user/RejectFriend")
  238. Future<RespData<bool>> postRejectFriend(@Query("uid") int uid);
  239. @POST("/user/AcceptFriend")
  240. Future<RespData> postAcceptFriend(@Query("uid") int uid);
  241. @POST("/user/isFriend")
  242. Future<RespData<bool>> postIsFriend(@Query("uid") int uid);
  243. // ********************** 聊天相关 *****************************
  244. @POST("/chat/index")
  245. Future<RespList<ChatMessageInstance>> getChatIndex();
  246. @POST("/chat/user")
  247. Future<RespData<ChatMessage>> getChatUser(@Query("user_id") int userId, {@Query("begin_id") int? beginId});
  248. @POST("/chat/send")
  249. Future<RespData<MessageInstance>> postChatSend(
  250. @Query("user_id") String userId,
  251. @Query("type") String type,
  252. @Query("data") String data,
  253. );
  254. @POST("/chat/upload")
  255. @Headers(<String, dynamic>{
  256. "content-type": "multipart/form-data",
  257. })
  258. Future<RespData> postChatUpload(
  259. @Part(name: "file") File file,
  260. );
  261. @FormUrlEncoded()
  262. @POST("/chat/info")
  263. Future<RespList<ChatOnlineInfo>> getChatUserInfo(
  264. @Field("user_ids") String userIds,
  265. );
  266. // ********************** 分享相关 *****************************
  267. @POST("/share/createSport")
  268. Future<RespData<ShareInfo>> getshareCreateSport(@Query("period") String period, @Query("weight") double weight);
  269. @POST("/share/forwardSport")
  270. Future<RespData<MessageInstance>> getshareForwardSport(@Query("h") String hash, @Query("user_id") int userId);
  271. // ********************** 公告相关 *****************************
  272. @GET("/inform/list")
  273. Future<RespPage<Notice>> getInformList({@Query("p") int? page});
  274. @POST("/inform/read")
  275. Future<RespData> postInformRead(@Query("informId") int informId);
  276. @GET("/notice/list")
  277. Future<RespPage<Notice>> getNoticeList({@Query("type") String? type, @Query("markread") String? markread = "currpage", @Query("p") int? page, @Query("read") String? read, @Query("isMsg") String? isMsg = "1"});
  278. @GET("/notice/count")
  279. Future<RespData<int>> getNoticeCount(@Query("type") String type, @Query("read") String read, {@Query("isMsg") String isMsg = "1"});
  280. @POST("/notice/read")
  281. Future<RespData<Notice>> postNoticeRead(@Query("noticeId") int noticeId);
  282. // ********************** 反馈相关 *****************************
  283. @GET("/feedback/types")
  284. Future<RespList<FeedbackCategory>> getFeedbackTypes();
  285. @GET("/feedback/myChats")
  286. Future<RespList<FeedbackCategory>> getFeedbackChat({@Query("groupId") int? groupId, @Query("typeId") int? typeId});
  287. @POST("/feedback/post")
  288. Future<RespData<String>> postFeedback(@Query("typeId") String typeId, @Query("content") String content, {@Query("images") String? images, @Query("extra") String? extra});
  289. @POST("/media/Up4Feedback")
  290. @Headers(<String, dynamic>{
  291. "content-type": "multipart/form-data",
  292. })
  293. Future<RespData<String>> mediaUp4Feedback(@Part(name: "media") File file);
  294. @POST("/media/Up4Subject")
  295. @Headers(<String, dynamic>{
  296. "content-type": "multipart/form-data",
  297. })
  298. Future<RespData<Image>> mediaUp4Subject(@Part(name: "media") File file, {@Query("srcType") String? srcType, @Query("subjectId") String? subjectId, CancelToken? cancelToken});
  299. // ********************** 游戏相关 *********************************
  300. @GET("/game/all")
  301. Future<RespList<GameInfoData>> getGameAll();
  302. @GET("/game/all")
  303. Future getGameById(@Query("id") int id);
  304. @GET("/rank/all")
  305. Future<RespList<RankInfoData>> getRankInfoAll();
  306. @GET("/rank/game")
  307. Future<RespData<RankGameInfoData>> getRankGameInfo(@Query("game_id") String id, {@Query("scope") String? scope});
  308. @GET("/rank/sport")
  309. Future<RespData<RankGameInfoData>> getRankSportInfo(@Query("rank_id") String id, {@Query("scope") String? scope});
  310. // ********************** 商城相关 *********************************
  311. @GET("/shop/item")
  312. Future<RespData<ShopIndex>> getShopIndex();
  313. @GET("/score/record")
  314. Future<RespData<ScoreList>> getScoreIndex();
  315. @POST("/shop/buy")
  316. Future<RespData<Map<String, dynamic>>> buyItem(
  317. @Query("item_id") String id,
  318. );
  319. // ********************** 跑步相关 *********************************
  320. @POST("/jog/addRecord")
  321. @Headers(<String, dynamic>{
  322. "content-type": "multipart/form-data",
  323. })
  324. Future<RespData<Map<String, dynamic>>> jogAddRecord(
  325. @Part(name:"begin") int begin,
  326. @Part(name:"end") int end,
  327. @Part(name:"distance") int distance,
  328. @Part(name:"step") int step,
  329. @Part(name:"consume") int consume,
  330. @Part(name:"track") String track,
  331. @Part(name:"step_info") String stepInfo,
  332. @Part(name:"altitude_info") String altitudeInfo,
  333. @Part(name:"km_duration_info") String kmDurationInfo,
  334. @Part(name:"track_thumb") String thumb,
  335. @Part(name: "media") File media,
  336. );
  337. @POST("/jog/delRecord")
  338. Future<RespData<String>> jogDelRecord(@Query("id") int id);
  339. @POST("/jog/copyRecord")
  340. Future<RespData<String>> jogCopyRecord(@Query("id") int id);
  341. @GET("/jog/show")
  342. Future<RespData<JogDetail>> jogShowRecord(@Query("id") int id);
  343. @GET("/jog/listOneYear")
  344. Future<RespData<JogSum>> jogListOneYear(@Query("year") int year);
  345. @GET("/jog/listByDay")
  346. Future<RespData<JogRecord>> jogListByDay(@Query("begin") String begin, @Query("end") String end);
  347. @GET("/jog/listByMonth")
  348. Future<RespData<JogRecord>> jogListByMonth(@Query("year") int year);
  349. @GET("/jog/listByYear")
  350. Future<RespData<JogRecord>> jogListByYear();
  351. @FormUrlEncoded()
  352. @POST("/jog/setting")
  353. Future<RespData<Map<String, dynamic>>> jogSetting({@Field("setting") String? setting});
  354. }