From d1b3ac160a07ba18204bc341f0b88f5adfa22a9c Mon Sep 17 00:00:00 2001 From: wangdl Date: Sat, 30 May 2026 09:06:36 +0800 Subject: [PATCH] =?UTF-8?q?fix(ios):=20QuizGenerateRequest=20Codable=20?= =?UTF-8?q?=E6=9B=BF=E4=BB=A3=20[String:=20Any]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.7 --- AIStudyApp/AIStudyApp/Core/Models/APIModels.swift | 5 +++++ AIStudyApp/AIStudyApp/Core/Services/APIService.swift | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/AIStudyApp/AIStudyApp/Core/Models/APIModels.swift b/AIStudyApp/AIStudyApp/Core/Models/APIModels.swift index ef5ca52..16e2cd2 100644 --- a/AIStudyApp/AIStudyApp/Core/Models/APIModels.swift +++ b/AIStudyApp/AIStudyApp/Core/Models/APIModels.swift @@ -446,6 +446,11 @@ struct QuizAnswer: Codable, Identifiable { let question: QuizQuestion? } +struct QuizGenerateRequest: Codable { + let knowledgeBaseId: String + let questionCount: Int +} + struct QuizSubmitRequest: Codable { let attemptId: String let answers: [QuizAnswerItem] diff --git a/AIStudyApp/AIStudyApp/Core/Services/APIService.swift b/AIStudyApp/AIStudyApp/Core/Services/APIService.swift index 0608133..fb82647 100644 --- a/AIStudyApp/AIStudyApp/Core/Services/APIService.swift +++ b/AIStudyApp/AIStudyApp/Core/Services/APIService.swift @@ -453,7 +453,8 @@ class QuizService { private let client = APIClient.shared func generate(knowledgeBaseId: String, questionCount: Int = 5) async throws -> Quiz { - return try await client.request("/quizzes", method: "POST", body: ["knowledgeBaseId": knowledgeBaseId, "questionCount": questionCount] as [String: Any]) + let body = QuizGenerateRequest(knowledgeBaseId: knowledgeBaseId, questionCount: questionCount) + return try await client.request("/quizzes", method: "POST", body: body) } func list(knowledgeBaseId: String? = nil) async throws -> [Quiz] {