2
This commit is contained in:
16
keyBoard/Class/AiTalk/VM/AIMessageVM.h
Normal file
16
keyBoard/Class/AiTalk/VM/AIMessageVM.h
Normal file
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// AIMessageVM.h
|
||||
// keyBoard
|
||||
//
|
||||
// Created by Mac on 2026/1/28.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface AIMessageVM : NSObject
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
12
keyBoard/Class/AiTalk/VM/AIMessageVM.m
Normal file
12
keyBoard/Class/AiTalk/VM/AIMessageVM.m
Normal file
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// AIMessageVM.m
|
||||
// keyBoard
|
||||
//
|
||||
// Created by Mac on 2026/1/28.
|
||||
//
|
||||
|
||||
#import "AIMessageVM.h"
|
||||
|
||||
@implementation AIMessageVM
|
||||
|
||||
@end
|
||||
@@ -9,6 +9,8 @@
|
||||
#import "KBPersonaPageModel.h"
|
||||
#import "KBChatHistoryPageModel.h"
|
||||
#import "KBCommentModel.h"
|
||||
#import "KBLikedCompanionModel.h"
|
||||
#import "KBChattedCompanionModel.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@@ -142,6 +144,16 @@ typedef void (^AiVMSpeechTranscribeCompletion)(KBAiSpeechTranscribeResponse *_Nu
|
||||
- (void)likeCompanionWithCompanionId:(NSInteger)companionId
|
||||
completion:(void(^)(KBCommentLikeResponse * _Nullable response, NSError * _Nullable error))completion;
|
||||
|
||||
#pragma mark - 点赞列表接口
|
||||
|
||||
/// 获取当前用户点赞过的 AI 角色列表(Thumbs Up)
|
||||
/// @param completion 完成回调(返回点赞角色数组)
|
||||
- (void)fetchLikedCompanionsWithCompletion:(void(^)(NSArray<KBLikedCompanionModel *> * _Nullable list, NSError * _Nullable error))completion;
|
||||
|
||||
/// 获取当前用户聊过天的 AI 角色列表(Chatting)
|
||||
/// @param completion 完成回调(返回聊天角色数组)
|
||||
- (void)fetchChattedCompanionsWithCompletion:(void(^)(NSArray<KBChattedCompanionModel *> * _Nullable list, NSError * _Nullable error))completion;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -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