1
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#import "KBLikedCompanionModel.h"
|
||||
#import "KBChattedCompanionModel.h"
|
||||
#import "KBChatSessionResetModel.h"
|
||||
#import "KBAICompanionDetailModel.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@@ -116,12 +117,12 @@ typedef void (^AiVMSpeechTranscribeCompletion)(KBAiSpeechTranscribeResponse *_Nu
|
||||
/// @param content 评论内容
|
||||
/// @param parentId 父评论 ID(一级评论传 NULL)
|
||||
/// @param rootId 根评论 ID(用于标识一级评论)
|
||||
/// @param completion 完成回调(返回 code 200 表示成功)
|
||||
/// @param completion 完成回调(newItem 可能为空,取决于后端是否返回 data)
|
||||
- (void)addCommentWithCompanionId:(NSInteger)companionId
|
||||
content:(NSString *)content
|
||||
parentId:(nullable NSNumber *)parentId
|
||||
rootId:(NSInteger)rootId
|
||||
completion:(void(^)(NSInteger code, NSError * _Nullable error))completion;
|
||||
content:(NSString *)content
|
||||
parentId:(nullable NSNumber *)parentId
|
||||
rootId:(nullable NSNumber *)rootId
|
||||
completion:(void(^)(KBCommentItem * _Nullable newItem, NSInteger code, NSError * _Nullable error))completion;
|
||||
|
||||
/// 分页查询评论列表
|
||||
/// @param companionId AI 陪聊角色 ID
|
||||
|
||||
@@ -435,14 +435,14 @@ autoShowBusinessError:NO
|
||||
- (void)addCommentWithCompanionId:(NSInteger)companionId
|
||||
content:(NSString *)content
|
||||
parentId:(nullable NSNumber *)parentId
|
||||
rootId:(NSInteger)rootId
|
||||
completion:(void (^)(NSInteger, NSError * _Nullable))completion {
|
||||
rootId:(nullable NSNumber *)rootId
|
||||
completion:(void (^)(KBCommentItem * _Nullable, NSInteger, NSError * _Nullable))completion {
|
||||
if (content.length == 0) {
|
||||
NSError *error = [NSError errorWithDomain:@"AiVM"
|
||||
code:-1
|
||||
userInfo:@{NSLocalizedDescriptionKey: @"评论内容不能为空"}];
|
||||
code:-1
|
||||
userInfo:@{NSLocalizedDescriptionKey: @"评论内容不能为空"}];
|
||||
if (completion) {
|
||||
completion(-1, error);
|
||||
completion(nil, -1, error);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -450,7 +450,9 @@ autoShowBusinessError:NO
|
||||
NSMutableDictionary *params = [NSMutableDictionary dictionary];
|
||||
params[@"companionId"] = @(companionId);
|
||||
params[@"content"] = content;
|
||||
params[@"rootId"] = @(rootId);
|
||||
if (rootId) {
|
||||
params[@"rootId"] = rootId;
|
||||
}
|
||||
if (parentId) {
|
||||
params[@"parentId"] = parentId;
|
||||
}
|
||||
@@ -467,17 +469,42 @@ autoShowBusinessError:NO
|
||||
if (error) {
|
||||
NSLog(@"[AiVM] /ai-companion/comment/add failed: %@", error.localizedDescription ?: @"");
|
||||
if (completion) {
|
||||
completion(-1, error);
|
||||
completion(nil, -1, error);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
NSLog(@"[AiVM] /ai-companion/comment/add response: %@", json);
|
||||
NSInteger code = [json[@"code"] integerValue];
|
||||
if (completion) {
|
||||
completion(code, nil);
|
||||
if (code != 0) {
|
||||
NSString *message = json[@"message"] ?: @"请求失败";
|
||||
NSError *bizError = [NSError errorWithDomain:@"AiVM"
|
||||
code:code
|
||||
userInfo:@{NSLocalizedDescriptionKey: message}];
|
||||
if (completion) {
|
||||
completion(nil, code, bizError);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}];
|
||||
|
||||
KBCommentItem *newItem = nil;
|
||||
id dataObj = json[@"data"];
|
||||
if ([dataObj isKindOfClass:[NSDictionary class]]) {
|
||||
newItem = [KBCommentItem mj_objectWithKeyValues:(NSDictionary *)dataObj];
|
||||
} else if ([dataObj isKindOfClass:[NSNumber class]]) {
|
||||
KBCommentItem *tmp = [[KBCommentItem alloc] init];
|
||||
tmp.commentId = [(NSNumber *)dataObj integerValue];
|
||||
tmp.companionId = companionId;
|
||||
tmp.content = content;
|
||||
tmp.parentId = parentId;
|
||||
tmp.rootId = rootId;
|
||||
newItem = tmp;
|
||||
}
|
||||
|
||||
if (completion) {
|
||||
completion(newItem, code, nil);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)fetchCommentsWithCompanionId:(NSInteger)companionId
|
||||
|
||||
Reference in New Issue
Block a user