123 lines
4.2 KiB
Objective-C
123 lines
4.2 KiB
Objective-C
//
|
|
// YMMineUserInfoPresenter.m
|
|
// YUMI
|
|
//
|
|
// Created by YUMI on 2021/9/23.
|
|
//
|
|
|
|
#import "XPMineUserInfoPresenter.h"
|
|
///Tool
|
|
#import "Api+Mine.h"
|
|
#import "AccountInfoStorage.h"
|
|
#import "UploadFile.h"
|
|
///Model
|
|
#import "UserInfoModel.h"
|
|
#import "XPSoundCardModel.h"
|
|
#import "XPMineUserInfoTagModel.h"
|
|
///P
|
|
#import "XPMineUserInfoProtocol.h"
|
|
|
|
@implementation XPMineUserInfoPresenter
|
|
|
|
// 获取用户信息
|
|
- (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) {
|
|
|
|
}] uid:uid];
|
|
}
|
|
|
|
// 获取用户详细信息
|
|
- (void)getUserDetailInfoWithUid:(NSString *)uid {
|
|
@kWeakify(self);
|
|
[Api userDetailInfoCompletion:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
@kStrongify(self);
|
|
UserInfoModel * infoModel = [UserInfoModel modelWithDictionary:data.data];
|
|
[[self getView] onGetDetailInfoSuccess:infoModel];
|
|
}] uid:uid page:@"1" pageSize:@"20"];
|
|
}
|
|
|
|
/// 两个人的关注状态
|
|
/// @param targetUid 对方的uid
|
|
- (void)getUserAttentionState:(NSString *)targetUid; {
|
|
@kWeakify(self);
|
|
NSString * uid = [[AccountInfoStorage instance] getUid];
|
|
[Api attentionStatusCompletion:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
@kStrongify(self);
|
|
BOOL isLike = ((NSNumber *)data.data).boolValue;
|
|
[[self getView] getAttentionStateSuccess:isLike];
|
|
}] uid:uid isLikeUid:targetUid];
|
|
}
|
|
|
|
|
|
/// 关注用户 /取消该关注
|
|
/// @param targetUid 目标用户的uid
|
|
/// @param state 是否关注 yes 关注 NO 取消关注
|
|
- (void)attentionUser:(NSString *)targetUid state:(BOOL)state {
|
|
NSString * uid = [[AccountInfoStorage instance] getUid];
|
|
NSString * ticket = [[AccountInfoStorage instance] getTicket];
|
|
NSString * type = state ? @"1" : @"2";
|
|
@kWeakify(self);
|
|
[Api attentionCompletion:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
@kStrongify(self);
|
|
[[self getView] attentionUserSuccess:state];
|
|
}] uid:uid likedUid:targetUid ticket:ticket type:type];
|
|
}
|
|
|
|
///上传访问用户主页记录
|
|
///@param targetUid 被访问用户的uid
|
|
- (void)visitUser:(NSString *)targetUid {
|
|
[Api uploadVisitUserCompletion:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
}] uid:targetUid];
|
|
}
|
|
/// 上传声音文件
|
|
/// @param filePath 文件路径
|
|
- (void)uploadVoice:(NSString *)filePath {
|
|
@kWeakify(self);
|
|
NSString *name = [NSString stringWithFormat:@"file/%@",[NSString createUUID]];
|
|
[[UploadFile share]QCloudUploadFile:filePath named:name success:^(NSString * _Nonnull key, NSDictionary * _Nonnull resp) {
|
|
@kStrongify(self);
|
|
[[self getView] uploadVoiceFileToThirdSuccess:key];
|
|
} failure:^(NSNumber * _Nonnull resCode, NSString * _Nonnull message) {
|
|
@kStrongify(self);
|
|
[[self getView] uploadVoiceFileFail:message];
|
|
}];
|
|
}
|
|
-(void)saveSoundWithUrl:(NSString *)audioUrl second:(NSString *)second{
|
|
@kWeakify(self);
|
|
[Api saveSoundCardInfo:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
@kStrongify(self);
|
|
[[self getView]saveSoundSuccess:audioUrl];
|
|
} fail:^(NSInteger code, NSString * _Nullable msg) {
|
|
@kStrongify(self);
|
|
[[self getView]saveSoundFailWithMsg:msg];
|
|
} showLoading:NO] audioUrl:audioUrl second:second];
|
|
}
|
|
-(void)deleteSound{
|
|
@kWeakify(self);
|
|
[Api deleteSoundCardInfo:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
[[self getView]deleteSoundSuccess];
|
|
} showLoading:YES]];
|
|
}
|
|
///得到个人简介标签
|
|
-(void)getTagList{
|
|
@kWeakify(self);
|
|
[Api getTagList:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
@kStrongify(self);
|
|
XPMineUserInfoTagModel *model = [XPMineUserInfoTagModel modelWithDictionary:data.data];
|
|
[[self getView]getTagListSuccess:model];
|
|
}showLoading:YES]];
|
|
}
|
|
-(void)saveTagListWithLabels:(NSString *)labels{
|
|
@kWeakify(self);
|
|
[Api saveTagList:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
@kStrongify(self);
|
|
[[self getView]saveTagListSuccess];
|
|
}showLoading:YES errorToast:YES] labels:labels];
|
|
}
|
|
@end
|