2021-10-18 19:10:13 +08:00
|
|
|
//
|
|
|
|
// XPRoomPresenter.m
|
|
|
|
// xplan-ios
|
|
|
|
//
|
|
|
|
// Created by 冯硕 on 2021/10/18.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "XPRoomPresenter.h"
|
|
|
|
///API
|
|
|
|
#import "Api+Room.h"
|
|
|
|
#import "UserInfoModel.h"
|
|
|
|
///Tool
|
|
|
|
#import "AccountInfoStorage.h"
|
2021-10-19 18:30:03 +08:00
|
|
|
///P
|
|
|
|
#import "XPRoomProtocol.h"
|
2021-10-18 19:10:13 +08:00
|
|
|
|
|
|
|
|
|
|
|
@implementation XPRoomPresenter
|
|
|
|
|
|
|
|
|
|
|
|
/// 获取用户信息
|
2021-10-19 18:30:03 +08:00
|
|
|
- (void)getUserInfoWithUid:(NSString *)uid {
|
2021-10-21 17:55:51 +08:00
|
|
|
[Api getUserInfo:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
|
|
UserInfoModel * infoModel = [UserInfoModel modelWithJSON:data.data];
|
|
|
|
[[self getView] getUserInfoSuccess:infoModel];
|
|
|
|
} fail:^(NSInteger code, NSString * _Nullable msg) {
|
|
|
|
[[self getView] enterRoomFail];
|
|
|
|
} errorToast:NO] uid:uid];
|
2021-10-18 19:10:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// 获取进入的那个房间信息
|
|
|
|
/// @param uid 进入的房间的uid
|
2021-10-19 18:30:03 +08:00
|
|
|
- (void)getRoomInfoWithUid:(NSString *)uid {
|
2021-10-21 17:55:51 +08:00
|
|
|
NSString * intoUid = [AccountInfoStorage instance].getUid;
|
2021-10-21 21:21:43 +08:00
|
|
|
[Api getRoomInfo:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
2021-10-21 17:55:51 +08:00
|
|
|
RoomInfoModel * model = [RoomInfoModel modelWithJSON:data.data];
|
|
|
|
[[self getView] getRoomInfoSuccess:model];
|
|
|
|
} fail:^(NSInteger code, NSString * _Nullable msg) {
|
|
|
|
[[self getView] enterRoomFail];
|
|
|
|
} showLoading:YES errorToast:NO] uid:uid intoUid:intoUid];
|
2021-10-18 19:10:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// 开启用户自己的房间
|
|
|
|
/// @param title 房间标题
|
|
|
|
/// @param type 房间类型
|
|
|
|
/// @param roomPwd 房间密码
|
|
|
|
/// @param roomDesc 房间介绍
|
|
|
|
/// @param backPic 房间背景
|
|
|
|
- (void)openUserRoomWithTitle:(NSString *)title
|
|
|
|
type:(RoomType)type
|
|
|
|
roomPwd:(NSString *)roomPwd
|
|
|
|
roomDesc:(NSString *)roomDesc
|
|
|
|
backPic:(NSString *)backPic {
|
|
|
|
NSString * uid = [AccountInfoStorage instance].getUid;
|
|
|
|
NSString * ticket = [AccountInfoStorage instance].getTicket;
|
|
|
|
if (roomPwd.length <= 0) {
|
|
|
|
roomPwd = @"";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (roomDesc.length <= 0) {
|
|
|
|
roomDesc = @"";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (backPic.length <= 0) {
|
|
|
|
backPic = @"";
|
|
|
|
}
|
|
|
|
|
2021-10-21 21:21:43 +08:00
|
|
|
[Api openRoom:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
2021-10-19 18:30:03 +08:00
|
|
|
RoomInfoModel * infoModel = [RoomInfoModel modelWithJSON:data.data];
|
|
|
|
[[self getView] openRoomSuccess:infoModel];
|
|
|
|
} fail:^(NSInteger code, NSString * _Nullable msg) {
|
2021-10-21 17:55:51 +08:00
|
|
|
[[self getView] enterRoomFail];
|
|
|
|
} showLoading:YES] title:title type:type roomPwd:roomPwd roomDesc:roomDesc backPic:backPic uid:uid ticket:ticket];
|
2021-10-18 19:10:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@end
|