2022-01-04 22:28:18 +08:00
|
|
|
//
|
|
|
|
// Result.swift
|
|
|
|
// PushDeer
|
|
|
|
//
|
|
|
|
// Created by HEXT on 2022/1/4.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
|
|
|
|
/// 每个API接口的标准返回结构
|
|
|
|
struct ApiResult<T : Codable> : Codable{
|
|
|
|
let code: Int
|
|
|
|
/// 错误提示, code != 0 时才有
|
|
|
|
let error: String?
|
|
|
|
/// 返回内容, code == 0 时才有
|
|
|
|
let content: T?
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TokenContent: Codable{
|
|
|
|
let token: String
|
|
|
|
}
|
|
|
|
|
2022-01-10 00:26:29 +08:00
|
|
|
struct UserInfoContent: Codable{
|
|
|
|
let id: Int
|
2022-02-27 23:02:58 +08:00
|
|
|
let name: String?
|
2022-01-30 01:02:44 +08:00
|
|
|
let email: String?
|
2022-02-27 23:02:58 +08:00
|
|
|
let apple_id: String?
|
2022-01-10 00:26:29 +08:00
|
|
|
let wechat_id: String?
|
|
|
|
let level: Int
|
|
|
|
let created_at: String
|
|
|
|
let updated_at: String
|
2022-09-14 00:14:19 +08:00
|
|
|
let simple_token: String?
|
2022-01-10 00:26:29 +08:00
|
|
|
}
|
|
|
|
|
2022-01-04 22:28:18 +08:00
|
|
|
struct DeviceItem: Codable, Identifiable{
|
|
|
|
let id: Int
|
|
|
|
let uid: String
|
2022-01-15 22:13:23 +08:00
|
|
|
var name: String
|
2022-01-04 22:28:18 +08:00
|
|
|
let type: String
|
|
|
|
let device_id: String
|
|
|
|
let is_clip: Int
|
|
|
|
}
|
|
|
|
|
|
|
|
struct DeviceContent: Codable{
|
|
|
|
let devices: [DeviceItem]
|
|
|
|
}
|
|
|
|
|
|
|
|
struct KeyContent: Codable{
|
|
|
|
let keys: [KeyItem]
|
|
|
|
}
|
|
|
|
|
|
|
|
struct KeyItem: Codable, Identifiable{
|
|
|
|
let id: Int
|
2022-01-15 22:13:23 +08:00
|
|
|
var name: String
|
2022-01-10 00:26:29 +08:00
|
|
|
let uid: String
|
2022-01-04 22:28:18 +08:00
|
|
|
let key: String
|
2022-01-10 00:26:29 +08:00
|
|
|
let created_at: String
|
2022-01-04 22:28:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
struct MessageContent: Codable{
|
|
|
|
let messages: [MessageItem]
|
|
|
|
}
|
|
|
|
|
|
|
|
struct MessageItem: Codable, Identifiable{
|
|
|
|
let id: Int
|
|
|
|
let uid: String
|
|
|
|
let text: String
|
|
|
|
let desp: String
|
|
|
|
let type: String
|
2022-01-15 22:13:23 +08:00
|
|
|
let pushkey_name: String
|
2022-01-10 00:26:29 +08:00
|
|
|
let created_at: String
|
2022-01-04 22:28:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
struct ActionContent: Codable{
|
|
|
|
let message: String
|
|
|
|
}
|
2022-01-10 00:26:29 +08:00
|
|
|
|
2022-02-27 23:02:58 +08:00
|
|
|
struct ResultContent: Codable{
|
2022-01-10 00:26:29 +08:00
|
|
|
let result: Array<String>
|
|
|
|
}
|
|
|
|
|
2022-09-14 00:14:19 +08:00
|
|
|
|
|
|
|
struct STokenContent: Codable{
|
|
|
|
let stoken: String?
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-10 00:26:29 +08:00
|
|
|
let dateFormatter = DateFormatter()
|
|
|
|
|
|
|
|
extension KeyItem {
|
|
|
|
var createdDateStr: String {
|
|
|
|
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSSSSZ"
|
|
|
|
let createdDate = dateFormatter.date(from: self.created_at)
|
|
|
|
dateFormatter.dateFormat = "yyyy/MM/dd"
|
|
|
|
return dateFormatter.string(from: createdDate ?? Date())
|
|
|
|
}
|
|
|
|
}
|