大家都在搜接口

This commit is contained in:
chenguilong
2022-11-29 15:37:03 +08:00
committed by fengshuo
parent 61b5e3c8a7
commit d0fb9b538d
17 changed files with 119 additions and 22 deletions

View File

@@ -45,6 +45,11 @@ NS_ASSUME_NONNULL_BEGIN
page:(NSString *)page
pageSize:(NSString *)pageSize;
/// 大家都在搜的房间列表
/// @param completion 完成
/// @param sid sid
+ (void)requestEveryOneSearchRoomList:(HttpRequestHelperCompletion)completion wordId:(NSString *)sid;
/// 首页推荐的轮播图
/// @param completion 完成
/// @param uid 用户的uid

View File

@@ -44,6 +44,13 @@
[self makeRequest:@"search/room" method:HttpRequestHelperMethodGET completion:complection, __FUNCTION__, key, type, page, pageSize, nil];
}
///
/// @param completion
/// @param sid sid
+ (void)requestEveryOneSearchRoomList:(HttpRequestHelperCompletion)completion wordId:(NSString *)sid {
[self makeRequest:@"every/one/search/getRoomList" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__, sid, nil];
}
///
/// @param completion
/// @param uid uid

View File

@@ -0,0 +1,20 @@
//
// HomeEveryOneSearchModel.h
// xplan-ios
//
// Created by GLEN on 2022/11/29.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface HomeEveryOneSearchModel : NSObject
@property (nonatomic, copy) NSString *sid;
@property (nonatomic, copy) NSString *relationRoomUid;
@property (nonatomic, copy) NSString *word;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,16 @@
//
// HomeEveryOneSearchModel.m
// xplan-ios
//
// Created by GLEN on 2022/11/29.
//
#import "HomeEveryOneSearchModel.h"
@implementation HomeEveryOneSearchModel
+ (NSDictionary *)replacedKeyFromPropertyName {
return @{@"sid":@"id"};
}
@end

View File

@@ -41,6 +41,8 @@ NS_ASSUME_NONNULL_BEGIN
///是否是推荐房间
@property (nonatomic, assign) BOOL isRecommend;
@property (nonatomic, copy) NSString *erbanNo;
@end
NS_ASSUME_NONNULL_END

View File

@@ -19,6 +19,10 @@ NS_ASSUME_NONNULL_BEGIN
/// 获取首页推荐列表
- (void)getHomeRecommendRoomList;
/// 获取大家都在搜的房间列表
/// @param sid keyID
- (void)getEveryOneSearchRoomList:(NSString *)sid;
@end
NS_ASSUME_NONNULL_END

View File

@@ -36,4 +36,13 @@
}] 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];
}
@end

View File

@@ -9,6 +9,7 @@
#import "Api+Mine.h"
#import "AccountInfoStorage.h"
#import "XPMineFootPrintModel.h"
#import "HomeEveryOneSearchModel.h"
#import "XPInRoomRecordProtocol.h"
@implementation XPInRoomRecordPresenter
@@ -35,7 +36,7 @@
- (void)getEveryoneSearchList {
NSString *uid = [AccountInfoStorage instance].getUid;
[Api requestEveryoneSearch:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
NSArray *array = [XPMineFootPrintModel modelsWithArray:data.data];
NSArray *array = [HomeEveryOneSearchModel modelsWithArray:data.data];
[[self getView] getEveryoneSearchListSuccess:array];
}] uid:uid];
}

View File

@@ -19,6 +19,9 @@ NS_ASSUME_NONNULL_BEGIN
///搜索页获取推荐房间失败
- (void)searchRoomGetRecommendFail;
/// 大家都在搜房间列表成功
- (void)everyoneSearchListSuccess:(NSArray *)list;
@end
NS_ASSUME_NONNULL_END

View File

@@ -14,11 +14,15 @@ typedef NS_ENUM(NSInteger, SearchType){
SearchType_Users = 2,
};
@class HomeSearchResultModel;
@class HomeSearchResultModel, HomeRecommendRoomModel;
@interface XPSearchListTableViewCell : UITableViewCell
///配置数据
- (void)configData:(HomeSearchResultModel *)resultModel type:(SearchType)type;
///配置大家都在搜房间列表
- (void)configEveryoneData:(HomeRecommendRoomModel *)resultModel;
@end
NS_ASSUME_NONNULL_END

View File

@@ -12,6 +12,7 @@
#import "ThemeColor.h"
///Model
#import "HomeSearchResultModel.h"
#import "HomeRecommendRoomModel.h"
///View
#import "NetImageView.h"
@@ -66,6 +67,22 @@
}
}
}
- (void)configEveryoneData:(HomeRecommendRoomModel *)resultModel {
if (resultModel) {
self.avatarImageView.imageUrl = resultModel.avatar;
self.nickLabel.text = resultModel.title ;
self.idLabel.text = [NSString stringWithFormat:@"%@号:%@",AppName, resultModel.erbanNo];
self.sexImageView.image = resultModel.gender == GenderType_Female ? [UIImage imageNamed:@"common_female"] : [UIImage imageNamed:@"common_male"];
if (resultModel.onlineNum > 100) {
self.numberLabel.text = [NSString stringWithFormat:@"%ld", resultModel.onlineNum];
} else {
self.numberLabel.text = [NSString stringWithFormat:@" %ld ", resultModel.onlineNum];
}
self.numberView.hidden = YES;
}
}
#pragma mark - Private Method
- (void)initSubViews {
self.selectionStyle = UITableViewCellSelectionStyleNone;

View File

@@ -69,18 +69,22 @@
if (cell == nil) {
cell = [[XPSearchListTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPSearchListTableViewCell class])];
}
HomeSearchResultModel * resultModel = [self.relateArray safeObjectAtIndex1:indexPath.row];
[cell configData:resultModel type:1];
HomeRecommendRoomModel * resultModel = [self.relateArray safeObjectAtIndex1:indexPath.row];
[cell configEveryoneData:resultModel];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
HomeSearchResultModel * resultModel = [self.relateArray safeObjectAtIndex1:indexPath.row];
HomeRecommendRoomModel * resultModel = [self.relateArray safeObjectAtIndex1:indexPath.row];
if (self.delegate && [self.delegate respondsToSelector:@selector(xPHomeSearchRelateViewEnterRoom:)]) {
[self.delegate xPHomeSearchRelateViewEnterRoom:resultModel.uid];
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 74;
}
#pragma mark - collectionViewDelegate
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return self.recommendArray.count;
@@ -132,7 +136,7 @@
if (!_relateTitle) {
UILabel *label = [[UILabel alloc] init];
label.font = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium];
// label.textColor = [ThemeColor mainTextColor];
label.textColor = [ThemeColor mainTextColor];
label.text = @"相关房间";
_relateTitle = label;
}

View File

@@ -169,26 +169,24 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
}
///
- (void)xPRoomSearchRecordViewControllerEveryoneSearch:(NSString *)word {
- (void)xPRoomSearchRecordViewControllerEveryoneSearch:(NSString *)word sid:(nonnull NSString *)sid {
self.searchView.searchTextField.text = word;
[self.recordVc storeSearchRecord:word];
[self.presenter searchRoomList:word type:@"3"];
[self.presenter getEveryOneSearchRoomList:sid];
}
#pragma mark - XPHomeSearchProtocol
- (void)searchRoomSuccess:(NSArray *)data type:(nonnull NSString *)type {
if (type.integerValue == 3) {
if (data.count) {//
- (void)everyoneSearchListSuccess:(NSArray *)list {
if (list.count) {//
[self.view addSubview:self.relateView];
[self.relateView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.bottom.mas_equalTo(0);
make.top.mas_equalTo(self.searchView.mas_bottom);
}];
self.relateView.relateArray = data;
self.relateView.relateArray = list;
} else {//
[self.presenter getHomeRecommendRoomList];
}
}
}
- (void)searchRoomGetRecommendSuccess:(NSArray *)data {

View File

@@ -15,7 +15,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)xPRoomSearchRecordViewControllerSearchWithWord:(NSString *)word;
///点击了大家都在搜
- (void)xPRoomSearchRecordViewControllerEveryoneSearch:(NSString *)word;
- (void)xPRoomSearchRecordViewControllerEveryoneSearch:(NSString *)word sid:(NSString *)sid;
@end

View File

@@ -23,6 +23,7 @@
#import "XPInRoomRecordProtocol.h"
///Model
#import "XPMineFootPrintModel.h"
#import "HomeEveryOneSearchModel.h"
NSString * const XPConstSearchRecordStoreKey = @"XPConstSearchRecordStoreKey";
@@ -188,7 +189,8 @@ NSString * const XPConstSearchRecordStoreKey = @"XPConstSearchRecordStoreKey";
return cell;
} else if (collectionView == self.everyOneCollectionView) {
XPHomeSearchRecordCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPHomeSearchRecordCell class]) forIndexPath:indexPath];
cell.recordString = [self.everyoneSearchList safeObjectAtIndex1:indexPath.row];
HomeEveryOneSearchModel *model = [self.everyoneSearchList safeObjectAtIndex1:indexPath.row];
cell.recordString = model.word;
return cell;
} else {
XPHomeAttentionCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPHomeAttentionCollectionViewCell class]) forIndexPath:indexPath];
@@ -204,9 +206,9 @@ NSString * const XPConstSearchRecordStoreKey = @"XPConstSearchRecordStoreKey";
[self.delegate xPRoomSearchRecordViewControllerSearchWithWord:str];
}
} else if (collectionView == self.everyOneCollectionView) {
NSString *str = self.searchList[indexPath.row];
if (self.delegate && [self.delegate respondsToSelector:@selector(xPRoomSearchRecordViewControllerEveryoneSearch:)]) {
[self.delegate xPRoomSearchRecordViewControllerEveryoneSearch:str];
HomeEveryOneSearchModel *model = [self.everyoneSearchList safeObjectAtIndex1:indexPath.row];
if (self.delegate && [self.delegate respondsToSelector:@selector(xPRoomSearchRecordViewControllerEveryoneSearch: sid:)]) {
[self.delegate xPRoomSearchRecordViewControllerEveryoneSearch:model.word sid:model.sid];
}
} else {
XPMineFootPrintModel *resultModel = self.inRoomList[indexPath.row];
@@ -227,8 +229,8 @@ NSString * const XPConstSearchRecordStoreKey = @"XPConstSearchRecordStoreKey";
CGFloat width = [str boundingRectWithSize:CGSizeMake(200, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:12]} context:nil].size.width;
return CGSizeMake(width + 26, 26);
} else if(collectionView == self.everyOneCollectionView){
NSString *str = [self.everyoneSearchList safeObjectAtIndex1:indexPath.row];
CGFloat width = [str boundingRectWithSize:CGSizeMake(200, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:12]} context:nil].size.width;
HomeEveryOneSearchModel *model = [self.everyoneSearchList safeObjectAtIndex1:indexPath.row];
CGFloat width = [model.word boundingRectWithSize:CGSizeMake(200, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:12]} context:nil].size.width;
return CGSizeMake(width + 26, 26);
} else {
return CGSizeMake(56, 75);

View File

@@ -306,8 +306,7 @@
/// @param completion
/// @param uid uid
+ (void)requestEveryoneSearch:(HttpRequestHelperCompletion)completion uid:(NSString *)uid {
#warning todo
[self makeRequest:@"" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__, uid, nil];
[self makeRequest:@"every/one/search/getList" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__, uid, nil];
}
///