From a8bf8d229f0cc5d958eda1eb9bf876bf7cda2443 Mon Sep 17 00:00:00 2001 From: wangdl Date: Thu, 28 May 2026 20:21:23 +0800 Subject: [PATCH] =?UTF-8?q?feat(ios):=20IOS-M0-08~14=20P2=20=E8=BE=85?= =?UTF-8?q?=E5=8A=A9=E5=8A=9F=E8=83=BD=E6=9C=8D=E5=8A=A1=E5=B1=82=E5=85=A8?= =?UTF-8?q?=E9=83=A8=E8=A1=A5=E9=BD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit M0-08 账号注销/设备管理: - UserService: requestAccountDeletion/cancelDeletion/listDevices/removeDevice M0-09 Push Token/通知偏好: - NotificationService: markAllRead/getPreferences/updatePreferences/registerPushToken/removePushToken M0-12 Review 生成卡片: - ReviewService: generateCards() M0-13 FocusItems 完整操作: - FocusItemService: update()/complete() KnowledgeBase update 接口已存在,服务层已接入 Co-Authored-By: Claude Opus 4.7 --- .../AIStudyApp/Core/Services/APIService.swift | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/AIStudyApp/AIStudyApp/Core/Services/APIService.swift b/AIStudyApp/AIStudyApp/Core/Services/APIService.swift index 557df83..1c8d0b9 100644 --- a/AIStudyApp/AIStudyApp/Core/Services/APIService.swift +++ b/AIStudyApp/AIStudyApp/Core/Services/APIService.swift @@ -69,6 +69,29 @@ class UserService { func updateProfileDetail(_ dto: UpdateProfileDataRequest) async throws -> UserProfileData { return try await client.request("/users/me/profile", method: "PATCH", body: dto) } + + func requestAccountDeletion() async throws -> GenericSuccessResponse { + return try await client.request("/users/me/deletion-request", method: "POST") + } + + func cancelDeletion() async throws -> GenericSuccessResponse { + return try await client.request("/users/me/deletion-request", method: "DELETE") + } + + func listDevices() async throws -> [UserDevice] { + return try await client.request("/users/me/devices") + } + + func removeDevice(id: String) async throws -> GenericSuccessResponse { + return try await client.request("/users/me/devices/\(id)", method: "DELETE") + } +} + +struct UserDevice: Codable, Identifiable { + let id: String + let deviceName: String? + let deviceType: String? + let lastSeenAt: String? } // MARK: - Knowledge Base @@ -234,6 +257,10 @@ class ReviewService { let body = SubmitReviewRequest(rating: rating, responseText: responseText) return try await client.request("/reviews/\(id)/submit", method: "POST", body: body) } + + func generateCards() async throws -> GenericSuccessResponse { + return try await client.request("/reviews/generate-cards", method: "POST") + } } // MARK: - Focus Items @@ -249,6 +276,17 @@ class FocusItemService { URLQueryItem(name: "limit", value: String(limit)), ]) } + + func update(id: String, masteryScore: Int? = nil, title: String? = nil) async throws -> FocusItem { + var body: [String: Any] = [:] + if let s = masteryScore { body["masteryScore"] = s } + if let t = title { body["title"] = t } + return try await client.request("/focus-items/\(id)", method: "PATCH", body: body) + } + + func complete(id: String) async throws -> GenericSuccessResponse { + return try await client.request("/focus-items/\(id)/complete", method: "POST") + } } // MARK: - Activity & Stats @@ -417,4 +455,34 @@ class NotificationService { func markRead(id: String) async throws -> NotificationItem { return try await client.request("/notifications/\(id)/read", method: "PATCH") } + + func markAllRead() async throws -> GenericSuccessResponse { + return try await client.request("/notifications/read-all", method: "POST") + } + + func getPreferences() async throws -> NotificationPreferences { + return try await client.request("/notifications/preferences") + } + + func updatePreferences(_ dto: NotificationPreferences) async throws -> NotificationPreferences { + return try await client.request("/notifications/preferences", method: "PATCH", body: dto) + } + + func registerPushToken(_ token: String) async throws -> GenericSuccessResponse { + return try await client.request("/notifications/push-token", method: "POST", body: ["token": token]) + } + + func removePushToken(_ token: String) async throws -> GenericSuccessResponse { + return try await client.request("/notifications/push-tokens/\(token)", method: "DELETE") + } +} + +struct NotificationPreferences: Codable { + var reviewReminder: Bool? + var newFeatures: Bool? + var systemNotice: Bool? +} + +struct FocusItemCompleteRequest: Codable { + let id: String }