wake-ios/wake/Models/BlindModels.swift

132 lines
3.8 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import Foundation
// MARK: - Blind Box Media Type
enum BlindBoxMediaType {
case video
case image
case all
}
// MARK: - Blind Box List
struct BlindList: Codable, Identifiable {
// API
let id: String
let boxCode: String
let userId: String
let name: String
let boxType: String
let features: String?
let resultFile: FileInfo?
let status: String
let workflowInstanceId: String?
let videoGenerateTime: String?
let createTime: String
let coverFile: FileInfo?
let description: String?
struct FileInfo: Codable {
let id: String
let fileName: String?
let url: String?
// 使
// AnyCodable/JSONValue
let metadata: [String: String]?
enum CodingKeys: String, CodingKey {
case id
case fileName = "file_name"
case url
case metadata
}
}
enum CodingKeys: String, CodingKey {
case id
case boxCode = "box_code"
case userId = "user_id"
case name
case boxType = "box_type"
case features
case resultFile = "result_file"
case status
case workflowInstanceId = "workflow_instance_id"
case videoGenerateTime = "video_generate_time"
case createTime = "create_time"
case coverFile = "cover_file"
case description
}
}
// MARK: - Blind Box Count
struct BlindCount: Codable {
let availableQuantity: Int
enum CodingKeys: String, CodingKey {
case availableQuantity = "available_quantity"
}
}
// MARK: - Blind Box Data
struct BlindBoxData: Codable {
let id: Int64
let boxCode: String
let userId: Int64
let name: String
let boxType: String
let features: String?
let url: String?
let status: String
let workflowInstanceId: String?
//
let videoGenerateTime: String?
let createTime: String
let description: String?
enum CodingKeys: String, CodingKey {
case id
case boxCode = "box_code"
case userId = "user_id"
case name
case boxType = "box_type"
case features
case url
case status
case workflowInstanceId = "workflow_instance_id"
case videoGenerateTime = "video_generate_time"
case createTime = "create_time"
case description
}
init(id: Int64, boxCode: String, userId: Int64, name: String, boxType: String, features: String?, url: String?, status: String, workflowInstanceId: String?, videoGenerateTime: String?, createTime: String, description: String?) {
self.id = id
self.boxCode = boxCode
self.userId = userId
self.name = name
self.boxType = boxType
self.features = features
self.url = url
self.status = status
self.workflowInstanceId = workflowInstanceId
self.videoGenerateTime = videoGenerateTime
self.createTime = createTime
self.description = description
}
init(from listItem: BlindList) {
self.init(
id: Int64(listItem.id) ?? 0,
boxCode: listItem.boxCode,
userId: Int64(listItem.userId) ?? 0,
name: listItem.name,
boxType: listItem.boxType,
features: listItem.features,
url: listItem.resultFile?.url,
status: listItem.status,
workflowInstanceId: listItem.workflowInstanceId,
videoGenerateTime: listItem.videoGenerateTime,
createTime: listItem.createTime,
description: listItem.description
)
}
}