实现了 Agent 和 Profile 数据类,添加了 AddAgent 界面

This commit is contained in:
weber
2025-07-31 15:22:34 +08:00
parent 6ec732b996
commit 29d2bb753f
28 changed files with 1181 additions and 72 deletions

View File

@@ -0,0 +1,98 @@
package com.aiosman.ravenow.data
import com.aiosman.ravenow.data.api.ApiClient
import com.aiosman.ravenow.entity.AgentEntity
import com.aiosman.ravenow.entity.ProfileEntity
import com.google.gson.annotations.SerializedName
data class Agent(
@SerializedName("author")
val author: String,
@SerializedName("avatar")
val avatar: String,
@SerializedName("breakMode")
val breakMode: Boolean,
@SerializedName("createdAt")
val createdAt: String,
@SerializedName("desc")
val desc: String,
@SerializedName("id")
val id: Int,
@SerializedName("isPublic")
val isPublic: Boolean,
@SerializedName("openId")
val openId: String,
@SerializedName("profile")
val profile: Profile,
@SerializedName("title")
val title: String,
@SerializedName("updatedAt")
val updatedAt: String,
@SerializedName("useCount")
val useCount: Int
) {
fun toAgentEntity(): AgentEntity {
return AgentEntity(
id = id,
title = title,
desc = desc,
createdAt = createdAt,
updatedAt = updatedAt,
avatar = "${ApiClient.BASE_SERVER}$avatar",
author = author,
isPublic = isPublic,
openId = openId,
breakMode = breakMode,
useCount = useCount,
profile = profile.toProfileEntity(),
)
}
}
data class Profile(
@SerializedName("aiAccount")
val aiAccount: Boolean,
@SerializedName("avatar")
val avatar: String,
@SerializedName("banner")
val banner: String,
@SerializedName("bio")
val bio: String,
@SerializedName("chatAIId")
val chatAIId: String,
@SerializedName("id")
val id: Int,
@SerializedName("nickname")
val nickname: String,
@SerializedName("trtcUserId")
val trtcUserId: String,
@SerializedName("username")
val username: String
){
fun toProfileEntity(): ProfileEntity {
return ProfileEntity(
id = id,
username = username,
nickname = nickname,
avatar = "${ApiClient.BASE_SERVER}$avatar",
bio = bio,
banner = "${ApiClient.BASE_SERVER}$banner",
trtcUserId = trtcUserId,
chatAIId = chatAIId,
aiAccount = aiAccount
)
}
}
interface AgentService {
/**
* 获取智能体列表
*/
suspend fun getAgent(
pageNumber: Int,
pageSize: Int = 20
): ListContainer<AgentEntity>
}