161 lines
5.7 KiB
Objective-C
161 lines
5.7 KiB
Objective-C
//
|
|
// YMMineUserDataPresenter.m
|
|
// YUMI
|
|
//
|
|
// Created by YUMI on 2022/4/14.
|
|
//
|
|
|
|
#import "XPMineUserDataPresenter.h"
|
|
#import <ReactiveObjC/ReactiveObjC.h>
|
|
#import "Api+Guild.h"
|
|
#import "ClanDetailInfoModel.h"
|
|
#import "AccountInfoStorage.h"
|
|
#import "MineSkillCardListInfoModel.h"
|
|
#import "XPMineUserDataProtocol.h"
|
|
#import "UserInfoModel.h"
|
|
#import "Api+Moments.h"
|
|
#import "Api+Room.h"
|
|
#import "XPMomentsMineProtocol.h"
|
|
#import "Api+GameOrder.h"
|
|
#import "XPMineGamePartnerInfoModel.h"
|
|
|
|
@implementation XPMineUserDataPresenter
|
|
|
|
/// 获取会长和当前用户家族详细的信息
|
|
/// @param uid 用户的uid
|
|
- (void)getClanDetailInfo:(NSString *)uid currentUserUid:(NSString *)currentUserUid {
|
|
RACSubject* owner = [RACSubject subject];
|
|
RACSubject* currentUser = [RACSubject subject];
|
|
|
|
// @kWeakify(self);
|
|
[[RACSignal combineLatest:@[owner, currentUser] reduce:^id(ClanDetailInfoModel* ownerClanInfo, ClanDetailInfoModel* currentUserClanInfo){
|
|
// @kStrongify(self);
|
|
// [[self getView] getClanDetailInfoSuccess:ownerClanInfo currentUserClanInfo:currentUserClanInfo];
|
|
return nil;
|
|
}] subscribeError:^(NSError * _Nullable error) {
|
|
|
|
}];
|
|
|
|
[Api getClanDetailInfo:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
ClanDetailInfoModel * clanDetailInfo = [ClanDetailInfoModel modelWithDictionary:data.data];
|
|
[currentUser sendNext:clanDetailInfo];
|
|
[currentUser sendCompleted];
|
|
}fail:^(NSInteger code, NSString * _Nullable msg) {
|
|
[currentUser sendNext:nil];
|
|
[currentUser sendCompleted];
|
|
}] uid:currentUserUid];
|
|
|
|
[Api getClanDetailInfo:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
ClanDetailInfoModel * clanDetailInfo = [ClanDetailInfoModel modelWithDictionary:data.data];
|
|
[owner sendNext:clanDetailInfo];
|
|
[owner sendCompleted];
|
|
}fail:^(NSInteger code, NSString * _Nullable msg) {
|
|
[owner sendNext:nil];
|
|
[owner sendCompleted];
|
|
}] uid:uid];
|
|
}
|
|
|
|
|
|
///// 用户申请加入公会
|
|
///// @param hallId 公会的id
|
|
//- (void)memberApplyHall:(NSString *)hallId {
|
|
// @kWeakify(self);
|
|
// NSString *uid = [AccountInfoStorage instance].getUid;
|
|
// [Api memberApplyHall:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
// @kStrongify(self);
|
|
// [[self getView] memberApplyHallSuccess];
|
|
// } showLoading:YES] hallId:hallId uid:uid];
|
|
//}
|
|
|
|
- (void)getUserInfo:(NSString *)uid success:(void(^)(UserInfoModel * info))success {
|
|
[Api getUserInfo:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
UserInfoModel * info = [UserInfoModel modelWithDictionary:data.data];
|
|
if (success) {
|
|
success(info);
|
|
}
|
|
}] uid:uid];
|
|
}
|
|
/// 动态点赞
|
|
/// @param dynamicId 动态id
|
|
/// @param status yes 点赞 NO 取消
|
|
/// @param likedUid 点赞人的uid
|
|
/// @param worldId 话题的id
|
|
- (void)likeMonent:(NSString *)dynamicId status:(BOOL)status likedUid:(NSString *)likedUid worldId:(NSString *)worldId {
|
|
@kWeakify(self);
|
|
NSString * uid = [AccountInfoStorage instance].getUid;
|
|
NSString * statusStr = status ? @"1" : @"0";
|
|
[Api momentsLike:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
@kStrongify(self);
|
|
[[self getView] likeMomentsSuccess:dynamicId status:status];
|
|
} showLoading:YES] dynamicId:dynamicId uid:uid status:statusStr likedUid:likedUid worldId:worldId];
|
|
}
|
|
|
|
/// 删除动态
|
|
/// @param dynamicId 动态id
|
|
/// @param worldId 话题id
|
|
- (void)deleteMonents:(NSString *)dynamicId worldId:(NSString *)worldId {
|
|
@kWeakify(self);
|
|
NSString * uid = [AccountInfoStorage instance].getUid;
|
|
[Api momentsDelete:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
|
@kStrongify(self);
|
|
[[self getView] deleteMomentsSuccess:dynamicId];
|
|
} uid:uid dynamicId:dynamicId worldId:worldId];
|
|
}
|
|
- (void)requesstShieldingWtihType:(NSString *)type objId:(NSString *)objId{
|
|
@kWeakify(self);
|
|
[Api requestShielding:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
@kStrongify(self);
|
|
[[self getView] requesstShieldingSuccess:objId];
|
|
}] type:type objId:objId];
|
|
}
|
|
|
|
- (void)loadGamePartnerInfoList:(void(^)(NSArray<XPMineGamePartnerInfoModel *> *infos))success uid:(NSInteger)uid{
|
|
[Api requestGamePartnerInfoList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
|
if (code == 200) {
|
|
NSArray *models = [XPMineGamePartnerInfoModel modelsWithArray:data.data];
|
|
if (success) {
|
|
success(models);
|
|
}
|
|
}
|
|
} uid:@(uid).stringValue];
|
|
}
|
|
|
|
- (void)loadGameOrderRecord:(void(^)(NSArray <XPMineGameOrderRecoredModel *>* orderRecords))success
|
|
failure:(void(^)(NSString *msg))failure
|
|
page:(NSInteger)currentPage
|
|
type:(NSInteger)searchType {
|
|
[Api requestGameOrderRecord:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
|
if (code == 200) {
|
|
if (success) {
|
|
NSArray *records = [XPMineGameOrderRecoredModel modelsWithArray:data.data];
|
|
success(records);
|
|
}
|
|
} else {
|
|
if (failure) {
|
|
failure(msg);
|
|
}
|
|
}
|
|
} currSize:currentPage pageSize:20 searchType:searchType uid:[AccountInfoStorage instance].getUid];
|
|
}
|
|
|
|
|
|
- (void)submitOrder:(void(^)(void))success
|
|
failure:(void(^)(NSString *msg))failure
|
|
gameId:(NSInteger)gameId
|
|
gameUid:(NSInteger)gameUid
|
|
inning:(NSInteger)inning {
|
|
[Api requestGameOrder:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
|
if (code == 200) {
|
|
if (success) {
|
|
success();
|
|
}
|
|
} else {
|
|
if (failure) {
|
|
failure(msg);
|
|
}
|
|
}
|
|
} gameId:gameId gameUid:gameUid inning:inning uid:[AccountInfoStorage instance].getUid];
|
|
}
|
|
|
|
@end
|