新增接口,界面
This commit is contained in:
68
keyBoard/Class/AiTalk/M/KBPersonaModel.m
Normal file
68
keyBoard/Class/AiTalk/M/KBPersonaModel.m
Normal file
@@ -0,0 +1,68 @@
|
||||
//
|
||||
// KBPersonaModel.m
|
||||
// keyBoard
|
||||
//
|
||||
// Created by Kiro on 2026/1/26.
|
||||
//
|
||||
|
||||
#import "KBPersonaModel.h"
|
||||
#import <MJExtension/MJExtension.h>
|
||||
|
||||
@implementation KBPersonaModel
|
||||
|
||||
#pragma mark - MJExtension 配置
|
||||
|
||||
// 字段映射
|
||||
+ (NSDictionary *)mj_replacedKeyFromPropertyName {
|
||||
return @{
|
||||
@"personaId": @"id"
|
||||
};
|
||||
}
|
||||
|
||||
// 转换完成后的处理
|
||||
- (void)mj_keyValuesDidFinishConvertingToObject {
|
||||
// 容错处理:如果字段为 null,设置默认值
|
||||
if (!self.name) self.name = @"";
|
||||
if (!self.avatarUrl) self.avatarUrl = @"";
|
||||
if (!self.coverImageUrl) self.coverImageUrl = @"";
|
||||
if (!self.gender) self.gender = @"";
|
||||
if (!self.ageRange) self.ageRange = @"";
|
||||
if (!self.shortDesc) self.shortDesc = @"";
|
||||
if (!self.introText) self.introText = @"";
|
||||
if (!self.personalityTags) self.personalityTags = @"";
|
||||
if (!self.speakingStyle) self.speakingStyle = @"";
|
||||
if (!self.systemPrompt) self.systemPrompt = @"";
|
||||
if (!self.createdAt) self.createdAt = @"";
|
||||
if (!self.updatedAt) self.updatedAt = @"";
|
||||
}
|
||||
|
||||
#pragma mark - 扩展属性
|
||||
|
||||
- (NSArray<NSString *> *)tagsArray {
|
||||
if (self.personalityTags.length == 0) {
|
||||
return @[];
|
||||
}
|
||||
// 去除空格并分割
|
||||
NSString *trimmed = [self.personalityTags stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
|
||||
NSArray *tags = [trimmed componentsSeparatedByString:@","];
|
||||
|
||||
// 过滤空字符串
|
||||
NSMutableArray *result = [NSMutableArray array];
|
||||
for (NSString *tag in tags) {
|
||||
NSString *trimmedTag = [tag stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
|
||||
if (trimmedTag.length > 0) {
|
||||
[result addObject:trimmedTag];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
- (BOOL)isEnabled {
|
||||
return self.status == KBPersonaStatusEnabled;
|
||||
}
|
||||
|
||||
- (BOOL)isPublic {
|
||||
return self.visibility == KBPersonaVisibilityPublic;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user