Sync migrated iOS modules

This commit is contained in:
2026-06-22 15:35:12 +08:00
parent ace9c94359
commit 484566d27e
48 changed files with 4455 additions and 15 deletions

View File

@ -32,6 +32,34 @@ struct ListPayload<T: Decodable>: Decodable {
}
}
/// total + data list
struct DataListPayload<T: Decodable>: Decodable {
let total: Int
let data: [T]
/// JSON
enum CodingKeys: String, CodingKey {
case total
case data
case list
}
///
init(total: Int, data: [T]) {
self.total = total
self.data = data
}
/// data/list total
init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
total = try container.decodeLossyInt(forKey: .total) ?? 0
data = try container.decodeIfPresent([T].self, forKey: .data)
?? container.decodeIfPresent([T].self, forKey: .list)
?? []
}
}
private extension KeyedDecodingContainer {
/// IntDouble
func decodeLossyInt(forKey key: Key) throws -> Int? {