Initial commit: suixinkan_ios UIKit rewrite project.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-26 14:33:31 +08:00
commit 9edf993432
297 changed files with 47151 additions and 0 deletions

View File

@ -0,0 +1,127 @@
//
// LocationReportModels.swift
// suixinkan
//
// Created by Codex on 2026/6/24.
//
import Foundation
/// 线
enum LocationReportType: Int, CaseIterable, Identifiable {
case all = 0
case immediate = 1
case marked = 2
case onlineStatus = 3
var id: Int { rawValue }
///
var title: String {
switch self {
case .all: "全部"
case .immediate: "立即上报"
case .marked: "标记点"
case .onlineStatus: "在线状态"
}
}
}
///
struct LocationCoordinate: Equatable {
var latitude: Double
var longitude: Double
}
///
struct LocationReportSubmitResponse: Decodable, Equatable {
let staffId: String
let expired: Int
let status: Int
enum CodingKeys: String, CodingKey {
case staffId = "staff_id"
case expired
case status
}
///
init(staffId: String, expired: Int, status: Int) {
self.staffId = staffId
self.expired = expired
self.status = status
}
///
init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
staffId = try container.decodeLossyString(forKey: .staffId)
expired = try container.decodeLossyInt(forKey: .expired) ?? 0
status = try container.decodeLossyInt(forKey: .status) ?? 0
}
}
///
struct LocationReportHistoryItem: Decodable, Equatable, Identifiable {
let id: Int
let staffId: Int
let type: Int
let latitude: String
let longitude: String
let address: String
let ip: String
let remark: String
let createdAt: String
enum CodingKeys: String, CodingKey {
case id
case staffId = "staff_id"
case type
case latitude
case longitude
case address
case ip
case remark
case createdAt = "created_at"
}
///
init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
id = try container.decodeLossyInt(forKey: .id) ?? 0
staffId = try container.decodeLossyInt(forKey: .staffId) ?? 0
type = try container.decodeLossyInt(forKey: .type) ?? 0
latitude = try container.decodeLossyString(forKey: .latitude)
longitude = try container.decodeLossyString(forKey: .longitude)
address = try container.decodeLossyString(forKey: .address)
ip = try container.decodeLossyString(forKey: .ip)
remark = try container.decodeLossyString(forKey: .remark)
createdAt = try container.decodeLossyString(forKey: .createdAt)
}
///
var typeTitle: String {
LocationReportType(rawValue: type)?.title ?? "未知"
}
}
private extension KeyedDecodingContainer {
/// String Bool
func decodeLossyString(forKey key: Key) throws -> String {
if let value = try? decodeIfPresent(String.self, forKey: key) { return value }
if let value = try? decodeIfPresent(Int.self, forKey: key) { return String(value) }
if let value = try? decodeIfPresent(Double.self, forKey: key) { return String(value) }
if let value = try? decodeIfPresent(Bool.self, forKey: key) { return value ? "1" : "0" }
return ""
}
/// StringDouble Int Int
func decodeLossyInt(forKey key: Key) throws -> Int? {
if let value = try? decodeIfPresent(Int.self, forKey: key) { return value }
if let value = try? decodeIfPresent(Double.self, forKey: key) { return Int(value) }
if let value = try? decodeIfPresent(String.self, forKey: key) {
return Int(value.trimmingCharacters(in: .whitespacesAndNewlines))
}
return nil
}
}