Files
peko-ios/YuMi/Modules/YMMine/Presenter/XPMineUserInfoPresenter.m
2024-03-26 14:56:55 +08:00

104 lines
3.8 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 {
[Api getUserInfo:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
UserInfoModel * infoModel = [UserInfoModel modelWithDictionary:data.data];
[[self getView] onGetUserInfoSuccess:infoModel];
} fail:^(NSInteger code, NSString * _Nullable msg) {
}] uid:uid];
}
// 获取用户详细信息
- (void)getUserDetailInfoWithUid:(NSString *)uid {
[Api userDetailInfoCompletion:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
UserInfoModel * infoModel = [UserInfoModel modelWithDictionary:data.data];
[[self getView] ongetDetailInfoSuccess:infoModel];
}] uid:uid page:@"1" pageSize:@"20"];
}
/// 两个人的关注状态
/// @param targetUid 对方的uid
- (void)getUserAttentionState:(NSString *)targetUid; {
NSString * uid = [[AccountInfoStorage instance] getUid];
[Api attentionStatusCompletion:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
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";
[Api attentionCompletion:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
[[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 {
NSString *name = [NSString stringWithFormat:@"file/%@",[NSString createUUID]];
[[UploadFile share]QCloudUploadFile:filePath named:name success:^(NSString * _Nonnull key, NSDictionary * _Nonnull resp) {
[[self getView] uploadVoiceFileToThirdSuccess:key];
} failure:^(NSNumber * _Nonnull resCode, NSString * _Nonnull message) {
[[self getView] uploadVoiceFileFail:message];
}];
}
-(void)saveSoundWithUrl:(NSString *)audioUrl second:(NSString *)second{
[Api saveSoundCardInfo:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
[[self getView]saveSoundSuccess:audioUrl];
} fail:^(NSInteger code, NSString * _Nullable msg) {
[[self getView]saveSoundFailWithMsg:msg];
} showLoading:NO] audioUrl:audioUrl second:second];
}
-(void)deleteSound{
[Api deleteSoundCardInfo:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
[[self getView]deleteSoundSuccess];
} showLoading:YES]];
}
///得到个人简介标签
-(void)getTagList{
[Api getTagList:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
XPMineUserInfoTagModel *model = [XPMineUserInfoTagModel modelWithDictionary:data.data];
[[self getView]getTagListSuccess:model];
}showLoading:YES]];
}
-(void)saveTagListWithLabels:(NSString *)labels{
[Api saveTagList:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
[[self getView]saveTagListSuccess];
}showLoading:YES errorToast:YES] labels:labels];
}
@end