feat(ios): IOS-M0-08~14 P2 辅助功能服务层全部补齐

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 <noreply@anthropic.com>
This commit is contained in:
wangdl 2026-05-28 20:21:23 +08:00
parent bd635f4af1
commit a8bf8d229f

View File

@ -69,6 +69,29 @@ class UserService {
func updateProfileDetail(_ dto: UpdateProfileDataRequest) async throws -> UserProfileData { func updateProfileDetail(_ dto: UpdateProfileDataRequest) async throws -> UserProfileData {
return try await client.request("/users/me/profile", method: "PATCH", body: dto) 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 // MARK: - Knowledge Base
@ -234,6 +257,10 @@ class ReviewService {
let body = SubmitReviewRequest(rating: rating, responseText: responseText) let body = SubmitReviewRequest(rating: rating, responseText: responseText)
return try await client.request("/reviews/\(id)/submit", method: "POST", body: body) 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 // MARK: - Focus Items
@ -249,6 +276,17 @@ class FocusItemService {
URLQueryItem(name: "limit", value: String(limit)), 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 // MARK: - Activity & Stats
@ -417,4 +455,34 @@ class NotificationService {
func markRead(id: String) async throws -> NotificationItem { func markRead(id: String) async throws -> NotificationItem {
return try await client.request("/notifications/\(id)/read", method: "PATCH") 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
} }