import 'package:common_project/common_project.dart'; import 'package:flutter/material.dart'; import 'package:module_home/model/home_banner_model.dart'; import 'package:module_home/model/home_diamond_rank_model.dart'; import 'package:module_home/model/home_dust_rank_model.dart'; import 'package:module_home/model/home_hot_room_list_model.dart'; import 'package:module_home/model/home_may_like_model.dart'; import 'package:module_home/model/home_room_list_model.dart'; import 'package:module_home/model/home_search_content_users_model.dart'; import 'package:module_home/model/home_search_rtc_room_model.dart'; class HomeMainApi{ //获取首页banner static Future getBanners() async { var url="api-app/v1/config/getBanners"; Map map = Map(); map.putIfAbsent("bannerPosition", () => 102); map.putIfAbsent("categoryId", () => -1); var json = await ApiUtil.request(url,RequestType.GET, formData: map); return HomeBannerModel.fromJson(json); } //获取首页房间列表 static Future getHotRoomList({required int pageIndex,required String categoryId}) async { var url="api-app/v1/rtc/getHotRoomList"; Map map = Map(); map.putIfAbsent("pageIndex", () => pageIndex); map.putIfAbsent("categoryId", () => categoryId); var json = await ApiUtil.request(url,RequestType.GET, formData: map); return HomeHotRoomListModel.fromJson(json); } static Future getRoomList({required int pageIndex,required String categoryId}) async { var url="api-app/v1/rtc/getRoomList"; Map map = Map(); map.putIfAbsent("pageIndex", () => pageIndex); map.putIfAbsent("categoryId", () => categoryId); var json = await ApiUtil.request(url,RequestType.GET, formData: map); return HomeRoomListModel.fromJson(json); } //猜你喜欢 static Future getMayLike() async { var url="api-app/v1/social/getMayLike"; Map map = Map(); var json = await ApiUtil.request(url,RequestType.GET, formData: map); return HomeMayLikeModel.fromJson(json); } //搜索语聊房间 static Future searchRtcRoom(String content,int pageIndex,int pageSize) async { var url="api-common/v1/search/searchRtcRoom"; Map map = Map(); map.putIfAbsent("content", () => content); map.putIfAbsent("pageIndex", () => pageIndex); map.putIfAbsent("pageSize", () => pageSize); var json = await ApiUtil.request(url,RequestType.POST, formData: map); return HomeSearchRtcRoomModel.fromJson(json); } //搜索用户 static Future searchContent(String content,int pageNum,int pageSize) async { var url="api-common/v1/search/searchContent"; Map map = Map(); map.putIfAbsent("content", () => content); map.putIfAbsent("pageNum", () => pageNum); map.putIfAbsent("pageSize", () => pageSize); var json = await ApiUtil.request(url,RequestType.POST, formData: map); return HomeSearchContentUsersModel.fromJson(json); } //富豪榜 static Future getDiamondRankDay(String roomId) async { var url="api-app/v1/rtc/getDiamondRankDay"; Map map = Map(); map.putIfAbsent("roomId", () => roomId); var json = await ApiUtil.request(url,RequestType.GET, formData: map); return HomeDiamondRankModel.fromJson(json); } //魅力榜 static Future getDustRankDay(String roomId) async { var url="api-app/v1/rtc/getDustRankDay"; Map map = Map(); map.putIfAbsent("roomId", () => roomId); var json = await ApiUtil.request(url,RequestType.GET, formData: map); return HomeDustRankModel.fromJson(json); } //我的收藏房间 static Future getFavRoomList(int pageIndex) async { var url = "api-app/v1/rtc/getFavRoomList"; Map map = Map(); map.putIfAbsent("pageIndex", () => pageIndex); var json = await ApiUtil.request(url, RequestType.GET,formData: map); return MeFavRoomModel.fromJson(json); } static Future followUser(String targetId) async { var url="api-app/v1/social/followUser"; Map map = Map(); map.putIfAbsent("targetId", () => targetId); var json = await ApiUtil.request(url,RequestType.POST, formData: map); return BaseModel.fromJson(json); } //取消关注 static Future unFollowUser(String targetId) async { var url="api-app/v1/social/unFollowUser"; Map map = Map(); map.putIfAbsent("targetId", () => targetId); var json = await ApiUtil.request(url,RequestType.POST, formData: map); return BaseModel.fromJson(json); } }