home_main_api.dart 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. import 'package:common_project/common_project.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:module_home/model/home_banner_model.dart';
  4. import 'package:module_home/model/home_diamond_rank_model.dart';
  5. import 'package:module_home/model/home_dust_rank_model.dart';
  6. import 'package:module_home/model/home_hot_room_list_model.dart';
  7. import 'package:module_home/model/home_may_like_model.dart';
  8. import 'package:module_home/model/home_room_list_model.dart';
  9. import 'package:module_home/model/home_search_content_users_model.dart';
  10. import 'package:module_home/model/home_search_rtc_room_model.dart';
  11. class HomeMainApi{
  12. //获取首页banner
  13. static Future<HomeBannerModel> getBanners() async {
  14. var url="api-app/v1/config/getBanners";
  15. Map<String, dynamic> map = Map();
  16. map.putIfAbsent("bannerPosition", () => 102);
  17. map.putIfAbsent("categoryId", () => -1);
  18. var json = await ApiUtil.request(url,RequestType.GET, formData: map);
  19. return HomeBannerModel.fromJson(json);
  20. }
  21. //获取首页房间列表
  22. static Future<HomeHotRoomListModel> getHotRoomList({required int pageIndex,required String categoryId}) async {
  23. var url="api-app/v1/rtc/getHotRoomList";
  24. Map<String, dynamic> map = Map();
  25. map.putIfAbsent("pageIndex", () => pageIndex);
  26. map.putIfAbsent("categoryId", () => categoryId);
  27. var json = await ApiUtil.request(url,RequestType.GET, formData: map);
  28. return HomeHotRoomListModel.fromJson(json);
  29. }
  30. static Future<HomeRoomListModel> getRoomList({required int pageIndex,required String categoryId}) async {
  31. var url="api-app/v1/rtc/getRoomList";
  32. Map<String, dynamic> map = Map();
  33. map.putIfAbsent("pageIndex", () => pageIndex);
  34. map.putIfAbsent("categoryId", () => categoryId);
  35. var json = await ApiUtil.request(url,RequestType.GET, formData: map);
  36. return HomeRoomListModel.fromJson(json);
  37. }
  38. //猜你喜欢
  39. static Future<HomeMayLikeModel> getMayLike() async {
  40. var url="api-app/v1/social/getMayLike";
  41. Map<String, dynamic> map = Map();
  42. var json = await ApiUtil.request(url,RequestType.GET, formData: map);
  43. return HomeMayLikeModel.fromJson(json);
  44. }
  45. //搜索语聊房间
  46. static Future<HomeSearchRtcRoomModel> searchRtcRoom(String content,int pageIndex,int pageSize) async {
  47. var url="api-common/v1/search/searchRtcRoom";
  48. Map<String, dynamic> map = Map();
  49. map.putIfAbsent("content", () => content);
  50. map.putIfAbsent("pageIndex", () => pageIndex);
  51. map.putIfAbsent("pageSize", () => pageSize);
  52. var json = await ApiUtil.request(url,RequestType.POST, formData: map);
  53. return HomeSearchRtcRoomModel.fromJson(json);
  54. }
  55. //搜索用户
  56. static Future<HomeSearchContentUsersModel> searchContent(String content,int pageNum,int pageSize) async {
  57. var url="api-common/v1/search/searchContent";
  58. Map<String, dynamic> map = Map();
  59. map.putIfAbsent("content", () => content);
  60. map.putIfAbsent("pageNum", () => pageNum);
  61. map.putIfAbsent("pageSize", () => pageSize);
  62. var json = await ApiUtil.request(url,RequestType.POST, formData: map);
  63. return HomeSearchContentUsersModel.fromJson(json);
  64. }
  65. //富豪榜
  66. static Future<HomeDiamondRankModel> getDiamondRankDay(String roomId) async {
  67. var url="api-app/v1/rtc/getDiamondRankDay";
  68. Map<String, dynamic> map = Map();
  69. map.putIfAbsent("roomId", () => roomId);
  70. var json = await ApiUtil.request(url,RequestType.GET, formData: map);
  71. return HomeDiamondRankModel.fromJson(json);
  72. }
  73. //魅力榜
  74. static Future<HomeDustRankModel> getDustRankDay(String roomId) async {
  75. var url="api-app/v1/rtc/getDustRankDay";
  76. Map<String, dynamic> map = Map();
  77. map.putIfAbsent("roomId", () => roomId);
  78. var json = await ApiUtil.request(url,RequestType.GET, formData: map);
  79. return HomeDustRankModel.fromJson(json);
  80. }
  81. //我的收藏房间
  82. static Future<MeFavRoomModel> getFavRoomList(int pageIndex) async {
  83. var url = "api-app/v1/rtc/getFavRoomList";
  84. Map<String, dynamic> map = Map();
  85. map.putIfAbsent("pageIndex", () => pageIndex);
  86. var json = await ApiUtil.request(url, RequestType.GET,formData: map);
  87. return MeFavRoomModel.fromJson(json);
  88. }
  89. static Future<BaseModel> followUser(String targetId) async {
  90. var url="api-app/v1/social/followUser";
  91. Map<String, dynamic> map = Map();
  92. map.putIfAbsent("targetId", () => targetId);
  93. var json = await ApiUtil.request(url,RequestType.POST, formData: map);
  94. return BaseModel.fromJson(json);
  95. }
  96. //取消关注
  97. static Future<BaseModel> unFollowUser(String targetId) async {
  98. var url="api-app/v1/social/unFollowUser";
  99. Map<String, dynamic> map = Map();
  100. map.putIfAbsent("targetId", () => targetId);
  101. var json = await ApiUtil.request(url,RequestType.POST, formData: map);
  102. return BaseModel.fromJson(json);
  103. }
  104. }