80 lines
2.6 KiB
Objective-C
80 lines
2.6 KiB
Objective-C
//
|
|
// MessagePresenter.m
|
|
// YUMI
|
|
//
|
|
// Created by zu on 2021/12/8.
|
|
//
|
|
|
|
#import "MessagePresenter.h"
|
|
#import "Api+Message.h"
|
|
#import "ChatLimitModel.h"
|
|
#import "MessageProtocol.h"
|
|
#import "Api+Mine.h"
|
|
#import "UserInfoModel.h"
|
|
#import "AccountInfoStorage.h"
|
|
#import "NIMMessageUtils.h"
|
|
#import "XPMessageRemoteExtModel.h"
|
|
|
|
@implementation MessagePresenter
|
|
|
|
// 获取用户信息
|
|
- (void)getUserInfoWithUid:(NSString *)uid {
|
|
@kWeakify(self);
|
|
[Api getUserInfo:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
@kStrongify(self);
|
|
UserInfoModel * infoModel = [UserInfoModel modelWithDictionary:data.data];
|
|
[[self getView] onGetUserInfoSuccess:infoModel];
|
|
} fail:^(NSInteger code, NSString * _Nullable msg) {
|
|
if ([self.getView respondsToSelector:@selector(onGetUserFailure:)]) {
|
|
[self.getView onGetUserFailure:code];
|
|
}
|
|
}] uid:uid];
|
|
}
|
|
|
|
- (void)getChatLimitReceiverUid:(NSString *)receiverUid {
|
|
@kWeakify(self);
|
|
[Api getChatLimit:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
@kStrongify(self);
|
|
ChatLimitModel *chatLimit = [ChatLimitModel modelWithJSON:data.data];
|
|
[[self getView] onGetLimitChat:chatLimit];
|
|
} showLoading:NO errorToast:NO] receiverUid:receiverUid];
|
|
}
|
|
|
|
/// 获取用户信息
|
|
/// @param uid 用户uid
|
|
- (void)getUserInfo:(NSString *)uid {
|
|
@kWeakify(self);
|
|
[Api userDetailInfoCompletion:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
@kStrongify(self);
|
|
UserInfoModel * infoModel = [UserInfoModel modelWithDictionary:data.data];
|
|
[[self getView] onGetSessionUserInfoSuccess:infoModel];
|
|
}] uid:uid page:@"1" pageSize:@"20"];
|
|
}
|
|
|
|
///是否关注当前用户
|
|
- (void)getFansLike:(NSString *)likeUid {
|
|
@kWeakify(self);
|
|
NSString * uid = [AccountInfoStorage instance].getUid;
|
|
[Api attentionStatusCompletion:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
@kStrongify(self);
|
|
BOOL isLike = [data.data boolValue] || [NIMMessageUtils isOfficalAccount:likeUid];
|
|
[[self getView] getFansLikeSuccess:isLike];
|
|
}] uid:uid isLikeUid:likeUid];
|
|
}
|
|
|
|
/// 关注用户
|
|
/// @param targetUid 目标用户的uid
|
|
- (void)attentionUser:(NSString *)targetUid {
|
|
NSString * uid = [[AccountInfoStorage instance] getUid];
|
|
NSString * ticket = [[AccountInfoStorage instance] getTicket];
|
|
NSString * type = @"1";
|
|
@kWeakify(self);
|
|
[Api attentionCompletion:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
@kStrongify(self);
|
|
[[self getView] attentionUserSuccess:targetUid];
|
|
} showLoading:YES] uid:uid likedUid:targetUid ticket:ticket type:type];
|
|
}
|
|
|
|
|
|
@end
|