新增接口
This commit is contained in:
@@ -426,6 +426,68 @@ autoShowBusinessError:NO
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)deleteChatHistoryWithId:(NSInteger)historyId
|
||||
completion:(void (^)(BOOL, NSError * _Nullable))completion {
|
||||
if (historyId <= 0) {
|
||||
NSError *error = [NSError errorWithDomain:@"AiVM"
|
||||
code:-1
|
||||
userInfo:@{NSLocalizedDescriptionKey : @"invalid historyId"}];
|
||||
if (completion) {
|
||||
completion(NO, error);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
NSDictionary *params = @{
|
||||
@"id": @(historyId)
|
||||
};
|
||||
|
||||
NSLog(@"[AiVM] /chat/history/delete request: %@", params);
|
||||
[[KBNetworkManager shared]
|
||||
POST:@"/chat/history/delete"
|
||||
jsonBody:params
|
||||
headers:nil
|
||||
autoShowBusinessError:NO
|
||||
completion:^(NSDictionary *_Nullable json,
|
||||
NSURLResponse *_Nullable response,
|
||||
NSError *_Nullable error) {
|
||||
if (error) {
|
||||
NSLog(@"[AiVM] /chat/history/delete failed: %@", error.localizedDescription ?: @"");
|
||||
if (completion) {
|
||||
completion(NO, error);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
NSLog(@"[AiVM] /chat/history/delete response: %@", json);
|
||||
if (![json isKindOfClass:[NSDictionary class]]) {
|
||||
NSError *parseError = [NSError errorWithDomain:@"AiVM"
|
||||
code:-1
|
||||
userInfo:@{NSLocalizedDescriptionKey : @"数据格式错误"}];
|
||||
if (completion) {
|
||||
completion(NO, parseError);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
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(NO, bizError);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (completion) {
|
||||
completion(YES, nil);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - 评论相关接口
|
||||
|
||||
- (void)addCommentWithCompanionId:(NSInteger)companionId
|
||||
|
||||
Reference in New Issue
Block a user