diff --git a/ktor/src/main/kotlin/ink/snowflake/server/model/database/AISessionsTable.kt b/ktor/src/main/kotlin/ink/snowflake/server/model/database/AISessionsTable.kt new file mode 100644 index 0000000..46f436d --- /dev/null +++ b/ktor/src/main/kotlin/ink/snowflake/server/model/database/AISessionsTable.kt @@ -0,0 +1,12 @@ +package ink.snowflake.server.model.database + +import org.jetbrains.exposed.v1.core.dao.id.UUIDTable +import org.jetbrains.exposed.v1.datetime.timestampWithTimeZone + +// 定义 AI 表 +object AISessionsTable : UUIDTable("ai_chat_sessions") { + val userId = uuid("user_id") + val title = varchar("title", 255).nullable() + val createdAt = timestampWithTimeZone("created_at") + val updatedAt = timestampWithTimeZone("updated_at") +} diff --git a/ktor/src/main/kotlin/ink/snowflake/server/model/response/SessionListResponse.kt b/ktor/src/main/kotlin/ink/snowflake/server/model/response/SessionListResponse.kt new file mode 100644 index 0000000..7fe83d7 --- /dev/null +++ b/ktor/src/main/kotlin/ink/snowflake/server/model/response/SessionListResponse.kt @@ -0,0 +1,10 @@ +package ink.snowflake.server.model.response + +import kotlinx.serialization.Contextual +import kotlinx.serialization.Serializable +import java.util.UUID + +@Serializable +data class SessionListResponse( + @Contextual val id: UUID, val title: String?, val updatedAt: String +) diff --git a/ktor/src/main/kotlin/ink/snowflake/server/utils/Log/UnauthorizedException.kt b/ktor/src/main/kotlin/ink/snowflake/server/utils/Log/UnauthorizedException.kt new file mode 100644 index 0000000..9bb352c --- /dev/null +++ b/ktor/src/main/kotlin/ink/snowflake/server/utils/Log/UnauthorizedException.kt @@ -0,0 +1,4 @@ +package ink.snowflake.server.utils.Log + +// 这里暂时没用,因为调用的地方,也就是从token获取id,一定是被authenticate包裹的,也就是传入的token一定是有用的,没用的会直接被返回401 +class UnauthorizedException(message: String) : RuntimeException(message)