feat: 新增Mock数据提供器用于开发测试
- 新增MockDataProvider提供模拟数据 - 支持用户、对话、回忆录、订单等模拟数据
This commit is contained in:
@@ -0,0 +1,358 @@
|
||||
package com.huaga.life_echo.data.mock
|
||||
|
||||
import com.huaga.life_echo.network.models.*
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
/**
|
||||
* Mock数据提供者
|
||||
* 当API调用失败时,返回测试数据以确保UI可以正常显示
|
||||
*/
|
||||
object MockDataProvider {
|
||||
|
||||
// 获取Mock对话列表
|
||||
fun getMockConversations(): List<ConversationListItemDto> {
|
||||
return listOf(
|
||||
ConversationListItemDto(
|
||||
id = "conv_001",
|
||||
title = "回忆录助手",
|
||||
avatarUrl = null,
|
||||
latestMessagePreview = "您好!我是您的回忆录助手,很高兴能陪您聊聊往事。您想从哪里开始呢?",
|
||||
latestMessageTime = System.currentTimeMillis() - 300000, // 5分钟前
|
||||
unreadCount = 0,
|
||||
isDefaultAssistant = true
|
||||
),
|
||||
ConversationListItemDto(
|
||||
id = "conv_002",
|
||||
title = "回忆录助手",
|
||||
avatarUrl = null,
|
||||
latestMessagePreview = "关于您的童年时光,能再详细说说吗?",
|
||||
latestMessageTime = System.currentTimeMillis() - 86400000, // 1天前
|
||||
unreadCount = 1,
|
||||
isDefaultAssistant = false
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
// 获取Mock消息列表
|
||||
fun getMockMessages(conversationId: String): List<MessageDto> {
|
||||
return listOf(
|
||||
MessageDto(
|
||||
id = "msg_001",
|
||||
conversationId = conversationId,
|
||||
content = "您好!我是您的回忆录助手,很高兴能陪您聊聊往事。😊",
|
||||
senderType = "assistant",
|
||||
timestamp = System.currentTimeMillis() - 3600000,
|
||||
messageType = "text"
|
||||
),
|
||||
MessageDto(
|
||||
id = "msg_002",
|
||||
conversationId = conversationId,
|
||||
content = "您想从哪里开始呢?可以聊聊童年、上学时光,或者任何您想分享的故事。",
|
||||
senderType = "assistant",
|
||||
timestamp = System.currentTimeMillis() - 3600000 + 1000,
|
||||
messageType = "text"
|
||||
),
|
||||
MessageDto(
|
||||
id = "msg_003",
|
||||
conversationId = conversationId,
|
||||
content = "我想聊聊我的童年",
|
||||
senderType = "user",
|
||||
timestamp = System.currentTimeMillis() - 1800000,
|
||||
messageType = "text"
|
||||
),
|
||||
MessageDto(
|
||||
id = "msg_004",
|
||||
conversationId = conversationId,
|
||||
content = "太好了!童年时光总是充满美好的回忆。能告诉我您是在哪里长大的吗?",
|
||||
senderType = "assistant",
|
||||
timestamp = System.currentTimeMillis() - 1800000 + 2000,
|
||||
messageType = "text"
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
// 获取Mock对话详情
|
||||
fun getMockConversationDetail(id: String): ConversationDetailDto {
|
||||
return ConversationDetailDto(
|
||||
id = id,
|
||||
title = "回忆录助手",
|
||||
avatarUrl = null,
|
||||
userId = "user_001",
|
||||
startedAt = System.currentTimeMillis() - 3600000,
|
||||
endedAt = null,
|
||||
durationSeconds = 0,
|
||||
summary = "关于童年时光的对话",
|
||||
currentTopic = "童年",
|
||||
conversationStage = "CHILDHOOD",
|
||||
messages = getMockMessages(id)
|
||||
)
|
||||
}
|
||||
|
||||
// 获取Mock章节列表
|
||||
fun getMockChapters(): List<ChapterDto> {
|
||||
return listOf(
|
||||
ChapterDto(
|
||||
id = "chapter_001",
|
||||
title = "童年与家庭",
|
||||
content = "我出生在一个普通的农村家庭,父母都是勤劳朴实的农民。\n\n父亲是村里的木匠,手艺精湛,邻里乡亲都愿意找他帮忙。",
|
||||
orderIndex = 1,
|
||||
status = "completed",
|
||||
category = "childhood",
|
||||
pageCount = 3,
|
||||
updatedAt = System.currentTimeMillis() - 86400000
|
||||
),
|
||||
ChapterDto(
|
||||
id = "chapter_002",
|
||||
title = "上学的日子",
|
||||
content = "上学的日子总是充满欢声笑语,虽然条件艰苦,但学习的快乐让我忘记了生活的艰辛。",
|
||||
orderIndex = 2,
|
||||
status = "partial",
|
||||
category = "education",
|
||||
pageCount = 2,
|
||||
updatedAt = System.currentTimeMillis() - 43200000
|
||||
),
|
||||
ChapterDto(
|
||||
id = "chapter_003",
|
||||
title = "工作与事业",
|
||||
content = "工作是我人生中重要的转折点,让我学会了承担责任,也让我明白了生活的意义。",
|
||||
orderIndex = 3,
|
||||
status = "pending",
|
||||
category = "career",
|
||||
pageCount = null,
|
||||
updatedAt = System.currentTimeMillis()
|
||||
),
|
||||
ChapterDto(
|
||||
id = "chapter_004",
|
||||
title = "爱情与婚姻",
|
||||
content = "爱情是人生中最美好的经历之一,它让我懂得了什么是真正的幸福。",
|
||||
orderIndex = 4,
|
||||
status = "pending",
|
||||
category = "family",
|
||||
pageCount = null,
|
||||
updatedAt = System.currentTimeMillis()
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
// 获取Mock书籍信息
|
||||
fun getMockBookInfo(): BookDto {
|
||||
return BookDto(
|
||||
id = "book_001",
|
||||
userId = "user_001",
|
||||
title = "这一生",
|
||||
subtitle = "我的回忆录",
|
||||
totalPages = 5,
|
||||
totalWords = 5000,
|
||||
updatedAt = System.currentTimeMillis(),
|
||||
lastUpdatedAt = System.currentTimeMillis() - 120000 // 2分钟前
|
||||
)
|
||||
}
|
||||
|
||||
// 获取Mock章节内容
|
||||
fun getMockChapterContent(id: String): ChapterContentDto {
|
||||
val chapters = getMockChapters()
|
||||
val chapter = chapters.find { it.id == id } ?: chapters[0]
|
||||
|
||||
return ChapterContentDto(
|
||||
id = chapter.id,
|
||||
title = chapter.title,
|
||||
content = chapter.content,
|
||||
orderIndex = chapter.orderIndex,
|
||||
status = chapter.status,
|
||||
category = chapter.category,
|
||||
pageCount = chapter.pageCount,
|
||||
updatedAt = chapter.updatedAt ?: System.currentTimeMillis(),
|
||||
quotes = if (chapter.category == "childhood") {
|
||||
listOf("\"日子虽然清苦, 但那时候的快乐是最纯粹的。\"")
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
// 获取Mock套餐列表
|
||||
fun getMockPlans(): List<PlanDto> {
|
||||
return listOf(
|
||||
PlanDto(
|
||||
id = "plan_free",
|
||||
name = "free",
|
||||
displayName = "免费体验版",
|
||||
price = 0.0,
|
||||
currency = "CNY",
|
||||
billingCycle = "monthly",
|
||||
benefits = listOf(
|
||||
PlanBenefitDto(
|
||||
id = "benefit_free_1",
|
||||
name = "基础对话",
|
||||
description = "每月3次对话",
|
||||
maxConversations = 3,
|
||||
features = listOf("基础对话功能", "基础回忆录整理")
|
||||
)
|
||||
),
|
||||
features = listOf("基础对话功能", "每月3次对话", "基础回忆录整理"),
|
||||
isActive = true,
|
||||
isCurrentPlan = true
|
||||
),
|
||||
PlanDto(
|
||||
id = "plan_premium",
|
||||
name = "premium",
|
||||
displayName = "高级版",
|
||||
price = 29.0,
|
||||
currency = "CNY",
|
||||
billingCycle = "monthly",
|
||||
benefits = listOf(
|
||||
PlanBenefitDto(
|
||||
id = "benefit_premium_1",
|
||||
name = "无限对话",
|
||||
description = "无限对话次数",
|
||||
maxConversations = null,
|
||||
features = listOf("无限对话次数", "完整回忆录导出", "PDF格式导出")
|
||||
)
|
||||
),
|
||||
features = listOf(
|
||||
"无限对话次数",
|
||||
"完整回忆录导出",
|
||||
"PDF格式导出",
|
||||
"优先客服支持",
|
||||
"数据云端同步"
|
||||
),
|
||||
isActive = true,
|
||||
isCurrentPlan = false
|
||||
),
|
||||
PlanDto(
|
||||
id = "plan_professional",
|
||||
name = "professional",
|
||||
displayName = "专业版",
|
||||
price = 99.0,
|
||||
currency = "CNY",
|
||||
billingCycle = "monthly",
|
||||
benefits = listOf(
|
||||
PlanBenefitDto(
|
||||
id = "benefit_pro_1",
|
||||
name = "高级功能",
|
||||
description = "所有高级功能",
|
||||
maxWords = null,
|
||||
maxChapters = null,
|
||||
maxConversations = null,
|
||||
features = listOf("AI智能整理", "多格式导出", "专属客服支持")
|
||||
)
|
||||
),
|
||||
features = listOf(
|
||||
"高级版所有功能",
|
||||
"AI智能整理",
|
||||
"多格式导出(PDF、Word、EPUB)",
|
||||
"专属客服支持",
|
||||
"无限云端存储",
|
||||
"多设备同步"
|
||||
),
|
||||
isActive = true,
|
||||
isCurrentPlan = false
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
// 获取Mock当前套餐
|
||||
fun getMockCurrentPlan(): PlanDto {
|
||||
return getMockPlans().first { it.isCurrentPlan }
|
||||
}
|
||||
|
||||
// 获取Mock订单列表
|
||||
fun getMockOrders(): List<OrderDto> {
|
||||
return listOf(
|
||||
OrderDto(
|
||||
id = "order_001",
|
||||
userId = "user_001",
|
||||
planId = "plan_premium",
|
||||
planName = "高级版",
|
||||
amount = 29.0,
|
||||
currency = "CNY",
|
||||
status = "paid",
|
||||
paymentMethod = "wechat",
|
||||
createdAt = System.currentTimeMillis() - 2592000000, // 30天前
|
||||
paidAt = System.currentTimeMillis() - 2592000000 + 1000,
|
||||
expiresAt = System.currentTimeMillis() + 2592000000 // 30天后
|
||||
),
|
||||
OrderDto(
|
||||
id = "order_002",
|
||||
userId = "user_001",
|
||||
planId = "plan_free",
|
||||
planName = "免费体验版",
|
||||
amount = 0.0,
|
||||
currency = "CNY",
|
||||
status = "paid",
|
||||
paymentMethod = null,
|
||||
createdAt = System.currentTimeMillis() - 86400000 * 60, // 60天前
|
||||
paidAt = System.currentTimeMillis() - 86400000 * 60,
|
||||
expiresAt = null
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
// 获取Mock用户资料
|
||||
fun getMockUserProfile(): UserProfileDto {
|
||||
return UserProfileDto(
|
||||
id = "user_001",
|
||||
phone = "138****8888",
|
||||
email = "user@example.com",
|
||||
nickname = "用户",
|
||||
avatarUrl = null,
|
||||
subscriptionType = "free",
|
||||
currentPlanId = "plan_free",
|
||||
currentPlanName = "免费体验版",
|
||||
createdAt = "2024-01-01T00:00:00Z",
|
||||
updatedAt = "2024-01-15T00:00:00Z"
|
||||
)
|
||||
}
|
||||
|
||||
// 获取Mock额度校验结果
|
||||
fun getMockQuotaCheck(): QuotaCheckDto {
|
||||
return QuotaCheckDto(
|
||||
hasQuota = true,
|
||||
remainingWords = 10000,
|
||||
remainingChapters = 10,
|
||||
remainingConversations = 2,
|
||||
message = "您还有2次对话机会"
|
||||
)
|
||||
}
|
||||
|
||||
// 获取Mock常见问题
|
||||
fun getMockFAQs(): List<FAQDto> {
|
||||
return listOf(
|
||||
FAQDto(
|
||||
id = "faq_001",
|
||||
question = "如何使用回忆录助手?",
|
||||
answer = "打开应用后,点击对话列表中的「回忆录助手」,开始与AI对话。您可以分享您的故事,AI会帮您整理成回忆录。",
|
||||
category = "使用指南",
|
||||
orderIndex = 1
|
||||
),
|
||||
FAQDto(
|
||||
id = "faq_002",
|
||||
question = "如何导出回忆录?",
|
||||
answer = "在回忆录页面,点击「导出数据」按钮,选择导出格式(PDF、Word等),即可导出您的回忆录。",
|
||||
category = "使用指南",
|
||||
orderIndex = 2
|
||||
),
|
||||
FAQDto(
|
||||
id = "faq_003",
|
||||
question = "免费版和付费版有什么区别?",
|
||||
answer = "免费版每月可进行3次对话,基础回忆录整理。付费版提供无限对话、完整导出、优先客服等功能。",
|
||||
category = "套餐说明",
|
||||
orderIndex = 3
|
||||
),
|
||||
FAQDto(
|
||||
id = "faq_004",
|
||||
question = "如何升级套餐?",
|
||||
answer = "在个人中心页面,点击「升级套餐」,选择您想要的套餐,完成支付即可升级。",
|
||||
category = "套餐说明",
|
||||
orderIndex = 4
|
||||
),
|
||||
FAQDto(
|
||||
id = "faq_005",
|
||||
question = "数据安全吗?",
|
||||
answer = "我们采用行业标准的数据加密技术,确保您的数据安全。您可以随时导出数据,也可以随时删除账户。",
|
||||
category = "隐私安全",
|
||||
orderIndex = 5
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user