实现了 Agent 和 Profile 数据类,添加了 AddAgent 界面
This commit is contained in:
98
app/src/main/java/com/aiosman/ravenow/data/AgentService.kt
Normal file
98
app/src/main/java/com/aiosman/ravenow/data/AgentService.kt
Normal 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>
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user