jsdw_ios/QuickLocation/Section/Schedule/ScheduleModel.swift

232 lines
5.6 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.

//
// ScheduleModel.swift
// QuickLocation
//
// Created by on 2026/6/23.
//
import ObjectMapper
import RxDataSources
//
struct ScheduleListResponse: BaseModelProtocol, ListModelType {
var pagination: PaginationModel?
//
var pageIndex = 1
//
var pageSize = 20
//
var count = 0
//
var page_count = -99
//
var code: String?
//
var message: String?
//
var list: [ScheduleModel] = []
init() {}
init?(map: Map) {
}
mutating func mapping(map: Map) {
code <- map["code"]
message <- map["msg"]
list <- map["data"]
count = list.count
pagination = PaginationModel(pageIndex: pageIndex,
pageSize: pageSize,
totalNum: count,
totalPage: page_count)
}
}
struct ScheduleModel: Mappable, Equatable {
var uuid: String = UUID().uuidString
/// id
var id: String = ""
/// id
var creator_id: String = ""
///
var nick_name: String = ""
var head_pic: String = ""
///
var userIcon: UIImage {
UIImage(named: "UserIcon/\(head_pic)") ?? UIImage()
}
///
var timestamp: Int64 = 0
///
var is_follow: Bool = false
///
var is_own: Bool = false
///
var points: [SchedulePointModel] = []
///
var groups: [ScheduleGroupModel] = []
init?(map: Map) {
}
mutating func mapping(map: Map) {
id <- map["id"]
creator_id <- map["creator_id"]
nick_name <- map["nick_name"]
head_pic <- map["head_pic"]
timestamp <- map["timestamp"]
is_follow <- map["is_follow"]
is_own <- map["is_own"]
points <- map["points"]
groups <- map["groups"]
}
}
extension ScheduleModel: IdentifiableType {
public typealias Identity = String
public var identity: String {
return id
}
}
///
struct SchedulePointModel: Mappable, Equatable {
/// id
var id: String = ""
/// 0 1 2
var type: Int = 0
///
var expected_timestamp: Int64 = 0
///
var longitude: Double?
///
var latitude: Double?
///
var province: String = ""
var district: String = ""
var country: String = ""
var street: String = ""
var city: String = ""
var formatted_address: String = ""
///
var remark: String = ""
///
var events: [SchedulePointEventModel] = []
///
var sequence: Int = 0
init?(map: Map) {
}
mutating func mapping(map: Map) {
id <- map["id"]
type <- map["type"]
expected_timestamp <- map["expected_timestamp"]
longitude <- map["location.longitude"]
latitude <- map["location.latitude"]
remark <- map["remark"]
events <- map["events"]
province <- map["address.province"]
district <- map["address.district"]
country <- map["address.country"]
street <- map["address.street"]
city <- map["address.city"]
formatted_address <- map["address.formatted_address"]
sequence <- map["sequence"]
}
}
extension SchedulePointModel: IdentifiableType {
public typealias Identity = String
public var identity: String {
return id
}
}
extension SchedulePointModel {
/// SchedulePointItem
func toSchedulePointItem() -> SchedulePointItem {
var item = SchedulePointItem()
item.locationName = formatted_address
item.address = formatted_address
item.latitude = latitude ?? 0
item.longitude = longitude ?? 0
item.province = province
item.city = city
item.district = district
item.street = street
item.country = country
item.formatted_address = formatted_address
if expected_timestamp > 0 {
item.expectedTime = Date(timeIntervalSince1970: TimeInterval(expected_timestamp) / 1000)
}
item.remark = remark
return item
}
}
///
struct SchedulePointEventModel: Mappable, Equatable {
var uuid: String = UUID().uuidString
///
var text: String = ""
///
var arrival_timestamp: Int64 = 0
///
var user_id: String = ""
var nick_name: String = ""
var point_id: String = ""
init?(map: Map) {
}
mutating func mapping(map: Map) {
text <- map["text"]
arrival_timestamp <- map["arrival_timestamp"]
user_id <- map[user_id]
nick_name <- map["nick_name"]
point_id <- map["point_id"]
}
}
extension SchedulePointEventModel: IdentifiableType {
public typealias Identity = String
public var identity: String {
return uuid
}
}
///
struct ScheduleGroupModel: Mappable, Equatable {
var uuid: String = UUID().uuidString
/// id
var group_key: String = ""
///
var group_name: String = ""
init?(map: Map) {
}
mutating func mapping(map: Map) {
group_key <- map["group_key"]
group_name <- map["group_name"]
}
}
extension ScheduleGroupModel: IdentifiableType {
public typealias Identity = String
public var identity: String {
return uuid
}
}