处理vip逻辑

This commit is contained in:
2026-02-04 21:49:28 +08:00
parent b73f225d15
commit 35b1fc0f1e
8 changed files with 99 additions and 19 deletions

View File

@@ -14,8 +14,10 @@ NS_ASSUME_NONNULL_BEGIN
@interface KBChatResponse : NSObject
@property (nonatomic, copy, nullable) NSString *text;
@property (nonatomic, copy, nullable) NSString *audioId;
@property (nonatomic, copy, nullable) NSString *errorMessage;
@property (nonatomic, copy, nullable) NSString *message;
@property (nonatomic, assign) BOOL success;
@property (nonatomic, assign) NSInteger code;
@end
/// 音频响应模型

View File

@@ -7,6 +7,7 @@
#import "KBNetworkManager.h"
#import "KBConfig.h"
#import <AVFoundation/AVFoundation.h>
#import <MJExtension/MJExtension.h>
@implementation KBChatResponse
@end
@@ -46,7 +47,7 @@
if (completion) {
KBChatResponse *response = [[KBChatResponse alloc] init];
response.success = NO;
response.errorMessage = @"内容为空";
response.message = @"内容为空";
completion(response);
}
return;
@@ -66,24 +67,24 @@
headers:nil
completion:^(NSDictionary *json, NSURLResponse *response, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
KBChatResponse *chatResponse = [[KBChatResponse alloc] init];
KBChatResponse *chatResponse = [KBChatResponse mj_objectWithKeyValues:json];
if (error) {
chatResponse.success = NO;
chatResponse.errorMessage = error.localizedDescription ?: @"请求失败";
// chatResponse.errorMessage = error.localizedDescription ?: @"请求失败";
if (completion) completion(chatResponse);
return;
}
//
chatResponse.text = [self p_parseTextFromJSON:json];
// audioId
chatResponse.audioId = [self p_parseAudioIdFromJSON:json];
// //
// chatResponse.text = [self p_parseTextFromJSON:json];
// // audioId
// chatResponse.audioId = [self p_parseAudioIdFromJSON:json];
chatResponse.success = (chatResponse.text.length > 0);
if (!chatResponse.success) {
chatResponse.errorMessage = @"未获取到回复内容";
}
// chatResponse.success = (chatResponse.text.length > 0);
// if (!chatResponse.success) {
// chatResponse.errorMessage = @"未获取到回复内容";
// }
if (completion) completion(chatResponse);
});