新增接口,界面
This commit is contained in:
96
keyBoard/Class/AiTalk/M/KBPersonaModel.h
Normal file
96
keyBoard/Class/AiTalk/M/KBPersonaModel.h
Normal file
@@ -0,0 +1,96 @@
|
||||
//
|
||||
// KBPersonaModel.h
|
||||
// keyBoard
|
||||
//
|
||||
// Created by Kiro on 2026/1/26.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/// 人设状态
|
||||
typedef NS_ENUM(NSInteger, KBPersonaStatus) {
|
||||
KBPersonaStatusDisabled = 0, // 禁用
|
||||
KBPersonaStatusEnabled = 1 // 启用
|
||||
};
|
||||
|
||||
/// 人设可见性
|
||||
typedef NS_ENUM(NSInteger, KBPersonaVisibility) {
|
||||
KBPersonaVisibilityPrivate = 0, // 私有
|
||||
KBPersonaVisibilityPublic = 1 // 公开
|
||||
};
|
||||
|
||||
/// 人设模型
|
||||
@interface KBPersonaModel : NSObject
|
||||
|
||||
/// 人设 ID
|
||||
@property (nonatomic, assign) NSInteger personaId;
|
||||
|
||||
/// 人设名称
|
||||
@property (nonatomic, copy) NSString *name;
|
||||
|
||||
/// 头像 URL
|
||||
@property (nonatomic, copy) NSString *avatarUrl;
|
||||
|
||||
/// 封面图 URL
|
||||
@property (nonatomic, copy) NSString *coverImageUrl;
|
||||
|
||||
/// 性别
|
||||
@property (nonatomic, copy) NSString *gender;
|
||||
|
||||
/// 年龄范围
|
||||
@property (nonatomic, copy) NSString *ageRange;
|
||||
|
||||
/// 简短描述
|
||||
@property (nonatomic, copy) NSString *shortDesc;
|
||||
|
||||
/// 介绍文本
|
||||
@property (nonatomic, copy) NSString *introText;
|
||||
|
||||
/// 性格标签(逗号分隔的字符串)
|
||||
@property (nonatomic, copy) NSString *personalityTags;
|
||||
|
||||
/// 说话风格
|
||||
@property (nonatomic, copy) NSString *speakingStyle;
|
||||
|
||||
/// 系统提示词
|
||||
@property (nonatomic, copy) NSString *systemPrompt;
|
||||
|
||||
/// 状态(0-禁用,1-启用)
|
||||
@property (nonatomic, assign) KBPersonaStatus status;
|
||||
|
||||
/// 可见性(0-私有,1-公开)
|
||||
@property (nonatomic, assign) KBPersonaVisibility visibility;
|
||||
|
||||
/// 排序顺序
|
||||
@property (nonatomic, assign) NSInteger sortOrder;
|
||||
|
||||
/// 热度分数
|
||||
@property (nonatomic, assign) NSInteger popularityScore;
|
||||
|
||||
/// 创建时间
|
||||
@property (nonatomic, copy) NSString *createdAt;
|
||||
|
||||
/// 更新时间
|
||||
@property (nonatomic, copy) NSString *updatedAt;
|
||||
|
||||
#pragma mark - 扩展属性
|
||||
|
||||
/// 性格标签数组(从 personalityTags 解析)
|
||||
@property (nonatomic, strong, readonly) NSArray<NSString *> *tagsArray;
|
||||
|
||||
/// 是否启用
|
||||
@property (nonatomic, assign, readonly) BOOL isEnabled;
|
||||
|
||||
/// 是否公开
|
||||
@property (nonatomic, assign, readonly) BOOL isPublic;
|
||||
|
||||
/// 开场白
|
||||
@property (nonatomic, copy) NSString *prologue;
|
||||
/// 开场白URL
|
||||
@property (nonatomic, copy) NSString *prologueAudio;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
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
|
||||
45
keyBoard/Class/AiTalk/M/KBPersonaPageModel.h
Normal file
45
keyBoard/Class/AiTalk/M/KBPersonaPageModel.h
Normal file
@@ -0,0 +1,45 @@
|
||||
//
|
||||
// KBPersonaPageModel.h
|
||||
// keyBoard
|
||||
//
|
||||
// Created by Kiro on 2026/1/26.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "KBPersonaModel.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/// 排序规则
|
||||
@interface KBOrderRule : NSObject
|
||||
@property (nonatomic, copy) NSString *column; // 排序字段
|
||||
@property (nonatomic, assign) BOOL asc; // 是否升序
|
||||
@end
|
||||
|
||||
/// 分页数据模型
|
||||
@interface KBPersonaPageModel : NSObject
|
||||
|
||||
/// 人设列表
|
||||
@property (nonatomic, strong) NSArray<KBPersonaModel *> *records;
|
||||
|
||||
/// 总记录数
|
||||
@property (nonatomic, assign) NSInteger total;
|
||||
|
||||
/// 每页大小
|
||||
@property (nonatomic, assign) NSInteger size;
|
||||
|
||||
/// 当前页码
|
||||
@property (nonatomic, assign) NSInteger current;
|
||||
|
||||
/// 排序规则
|
||||
@property (nonatomic, strong, nullable) NSArray<KBOrderRule *> *orders;
|
||||
|
||||
/// 总页数
|
||||
@property (nonatomic, assign) NSInteger pages;
|
||||
|
||||
/// 是否还有更多数据
|
||||
@property (nonatomic, assign, readonly) BOOL hasMore;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
39
keyBoard/Class/AiTalk/M/KBPersonaPageModel.m
Normal file
39
keyBoard/Class/AiTalk/M/KBPersonaPageModel.m
Normal file
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// KBPersonaPageModel.m
|
||||
// keyBoard
|
||||
//
|
||||
// Created by Kiro on 2026/1/26.
|
||||
//
|
||||
|
||||
#import "KBPersonaPageModel.h"
|
||||
#import <MJExtension/MJExtension.h>
|
||||
|
||||
@implementation KBOrderRule
|
||||
@end
|
||||
|
||||
@implementation KBPersonaPageModel
|
||||
|
||||
#pragma mark - MJExtension 配置
|
||||
|
||||
// 数组内元素类型
|
||||
+ (NSDictionary *)mj_objectClassInArray {
|
||||
return @{
|
||||
@"records": [KBPersonaModel class],
|
||||
@"orders": [KBOrderRule class]
|
||||
};
|
||||
}
|
||||
|
||||
// 转换完成后的处理
|
||||
- (void)mj_keyValuesDidFinishConvertingToObject {
|
||||
if (!self.records) {
|
||||
self.records = @[];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - 扩展属性
|
||||
|
||||
- (BOOL)hasMore {
|
||||
return self.current < self.pages;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user