jsdw_ios/QuickLocation/Section/Schedule/ScheduleModel.swift

154 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.

//
// 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 group_name: String = ""
/// 圈子key
// var group_key: String = ""
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"]
// group_name <- map["groups.group_name"]
// group_key <- map["groups.group_key"]
}
}
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 eventText: String = ""
/// 节点顺序
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"]
eventText <- map["events.text"]
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
}
}