2
This commit is contained in:
@@ -9,6 +9,8 @@
|
||||
#import "KBAPI.h"
|
||||
#import "KBNetworkManager.h"
|
||||
#import "KBCommentModel.h"
|
||||
#import "KBLikedCompanionModel.h"
|
||||
#import "KBChattedCompanionModel.h"
|
||||
#import <MJExtension/MJExtension.h>
|
||||
|
||||
@implementation KBAiSyncData
|
||||
@@ -599,4 +601,94 @@ autoShowBusinessError:NO
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - 点赞列表接口
|
||||
|
||||
- (void)fetchLikedCompanionsWithCompletion:(void (^)(NSArray<KBLikedCompanionModel *> * _Nullable, NSError * _Nullable))completion {
|
||||
NSLog(@"[AiVM] /ai-companion/liked request");
|
||||
[[KBNetworkManager shared]
|
||||
GET:@"/ai-companion/liked"
|
||||
parameters:nil
|
||||
headers:nil
|
||||
autoShowBusinessError:NO
|
||||
completion:^(NSDictionary *_Nullable json,
|
||||
NSURLResponse *_Nullable response,
|
||||
NSError *_Nullable error) {
|
||||
if (error) {
|
||||
NSLog(@"[AiVM] /ai-companion/liked failed: %@", error.localizedDescription ?: @"");
|
||||
if (completion) {
|
||||
completion(nil, error);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
NSLog(@"[AiVM] /ai-companion/liked response: %@", json);
|
||||
|
||||
NSInteger code = [json[@"code"] integerValue];
|
||||
if (code != 0) {
|
||||
NSString *message = json[@"message"] ?: @"请求失败";
|
||||
NSError *bizError = [NSError errorWithDomain:@"AiVM"
|
||||
code:code
|
||||
userInfo:@{NSLocalizedDescriptionKey: message}];
|
||||
if (completion) {
|
||||
completion(nil, bizError);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
NSArray *dataArray = json[@"data"];
|
||||
if (![dataArray isKindOfClass:[NSArray class]]) {
|
||||
dataArray = @[];
|
||||
}
|
||||
|
||||
NSArray<KBLikedCompanionModel *> *list = [KBLikedCompanionModel mj_objectArrayWithKeyValuesArray:dataArray];
|
||||
if (completion) {
|
||||
completion(list, nil);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)fetchChattedCompanionsWithCompletion:(void (^)(NSArray<KBChattedCompanionModel *> * _Nullable, NSError * _Nullable))completion {
|
||||
NSLog(@"[AiVM] /ai-companion/chatted request");
|
||||
[[KBNetworkManager shared]
|
||||
GET:@"/ai-companion/chatted"
|
||||
parameters:nil
|
||||
headers:nil
|
||||
autoShowBusinessError:NO
|
||||
completion:^(NSDictionary *_Nullable json,
|
||||
NSURLResponse *_Nullable response,
|
||||
NSError *_Nullable error) {
|
||||
if (error) {
|
||||
NSLog(@"[AiVM] /ai-companion/chatted failed: %@", error.localizedDescription ?: @"");
|
||||
if (completion) {
|
||||
completion(nil, error);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
NSLog(@"[AiVM] /ai-companion/chatted response: %@", json);
|
||||
|
||||
NSInteger code = [json[@"code"] integerValue];
|
||||
if (code != 0) {
|
||||
NSString *message = json[@"message"] ?: @"请求失败";
|
||||
NSError *bizError = [NSError errorWithDomain:@"AiVM"
|
||||
code:code
|
||||
userInfo:@{NSLocalizedDescriptionKey: message}];
|
||||
if (completion) {
|
||||
completion(nil, bizError);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
NSArray *dataArray = json[@"data"];
|
||||
if (![dataArray isKindOfClass:[NSArray class]]) {
|
||||
dataArray = @[];
|
||||
}
|
||||
|
||||
NSArray<KBChattedCompanionModel *> *list = [KBChattedCompanionModel mj_objectArrayWithKeyValuesArray:dataArray];
|
||||
if (completion) {
|
||||
completion(list, nil);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user