60 lines
2.1 KiB
Objective-C
60 lines
2.1 KiB
Objective-C
//
|
|
// XPHomeSearchPresenter.m
|
|
// xplan-ios
|
|
//
|
|
// Created by 冯硕 on 2021/11/29.
|
|
//
|
|
|
|
#import "XPHomeSearchPresenter.h"
|
|
#import "Api+Home.h"
|
|
#import "XPHomeSearchProtocol.h"
|
|
#import "AccountInfoStorage.h"
|
|
#import "HomeSearchResultModel.h"
|
|
#import "HomeRecommendRoomModel.h"
|
|
#import "HomeSearchHijackBaseModel.h"
|
|
|
|
@implementation XPHomeSearchPresenter
|
|
|
|
|
|
/// 搜索房间或者用户
|
|
/// @param key 搜索的关键字
|
|
/// @param type 类型 1 房间 2 用户
|
|
- (void)searchRoomList:(NSString *)key type:(NSString *)type {
|
|
[Api searchComplection:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
NSArray * array = [HomeSearchResultModel modelsWithArray:data.data];
|
|
[[self getView] searchRoomSuccess:array type:type];
|
|
} showLoading:YES] key:key type:type page:@"1" pageSize:@"50"];
|
|
}
|
|
|
|
/// 获取首页推荐列表
|
|
- (void)getHomeRecommendRoomList {
|
|
NSString * uid = [AccountInfoStorage instance].getUid;
|
|
[Api homeRecommendRoomList:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
NSArray<HomeRecommendRoomModel *> * array = [HomeRecommendRoomModel modelsWithArray:data.data];
|
|
[[self getView] searchRoomGetRecommendSuccess:array];
|
|
}fail:^(NSInteger code, NSString * _Nullable msg) {
|
|
[[self getView] searchRoomGetRecommendFail];
|
|
}] uid:uid];
|
|
}
|
|
|
|
/// 获取大家都在搜的房间列表
|
|
/// @param sid keyID
|
|
- (void)getEveryOneSearchRoomList:(NSString *)sid {
|
|
[Api requestEveryOneSearchRoomList:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
NSArray<HomeRecommendRoomModel *> * array = [HomeRecommendRoomModel modelsWithArray:data.data];
|
|
[[self getView] everyoneSearchListSuccess:array];
|
|
}] wordId:sid];
|
|
}
|
|
|
|
///搜索劫持
|
|
- (void)getSearchHijack:(NSString *)key {
|
|
[Api requestSearchHijack:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
HomeSearchHijackBaseModel *model = [HomeSearchHijackBaseModel modelWithJSON:data.data];
|
|
[[self getView] searchHijackSuccess:model key:key];
|
|
} fail:^(NSInteger code, NSString * _Nullable msg) {
|
|
[[self getView] searchHijackFail:key];
|
|
}] key:key];
|
|
}
|
|
|
|
@end
|