Files
peko-ios/YuMi/Modules/YMMine/Presenter/XPMineUserDataPresenter.m
2023-08-10 18:44:46 +08:00

99 lines
3.6 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+Monents.h"
#import "Api+Room.h"
#import "XPMonentsMineProtocol.h"
@implementation XPMineUserDataPresenter
/// 获取会长和当前用户家族详细的信息
/// @param uid 用户的uid
- (void)getClanDetailInfo:(NSString *)uid currentUserUid:(NSString *)currentUserUid {
RACSubject* owner = [RACSubject subject];
RACSubject* currentUser = [RACSubject subject];
[[RACSignal combineLatest:@[owner, currentUser] reduce:^id(ClanDetailInfoModel* ownerClanInfo, ClanDetailInfoModel* currentUserClanInfo){
[[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 {
NSString * uid = [AccountInfoStorage instance].getUid;
[Api memberApplyHall:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
[[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 {
NSString * uid = [AccountInfoStorage instance].getUid;
NSString * statusStr = status ? @"1" : @"0";
[Api monentsLike:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
[[self getView] likeMonentsSuccess: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 {
NSString * uid = [AccountInfoStorage instance].getUid;
[Api monentsDelete:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
[[self getView] deleteMonentsSuccess:dynamicId];
} uid:uid dynamicId:dynamicId worldId:worldId];
}
- (void)requesstShieldingWtihType:(NSString *)type objId:(NSString *)objId{
[Api requesstShielding:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
[[self getView] requesstShieldingSuccess:objId];
}] type:type objId:objId];
}
@end