jsdw_ios/QuickLocation/Model/GroupModel.swift

170 lines
3.9 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.

//
// GroupModel.swift
// QuickLocation
//
// Created by 八条 on 2026/5/30.
//
import ObjectMapper
import RxDataSources
struct UserGroupResponse: BaseModelProtocol {
// 状态码
var code: String?
// 消息
var message: String?
//
var model: GroupModel?
init?(map: Map) {}
mutating func mapping(map: Map) {
code <- map["code"]
message <- map["msg"]
model <- map["data"]
}
}
struct RecommandGroupResponse: BaseModelProtocol {
// 状态码
var code: String?
// 消息
var message: String?
//
var list: [GroupInfoModel] = []
init?(map: Map) {}
mutating func mapping(map: Map) {
code <- map["code"]
message <- map["msg"]
list <- map["data"]
}
}
struct GroupModel: Mappable {
/// 当前选中的圈子
var default_group_key: String = ""
///
var has_unread_email: Bool = false
/// 圈子是否有人SOS
var is_anyone_sos: Bool = false
/// 圈子列表
var groups: [GroupInfoModel] = []
/// 当前选中圈子里的成员列表
var select_group_employee: [GroupMemberModel] = []
var score: Int = 0
init?(map: Map) {
}
mutating func mapping(map: Map) {
default_group_key <- map["default_group_key"]
has_unread_email <- map["has_unread_email"]
is_anyone_sos <- map["is_anyone_sos"]
score <- map["score"]
groups <- map["groups"]
select_group_employee <- map["select_group_employee"]
}
}
struct GroupInfoModel: Mappable, Equatable {
///
var group_key: String = ""
///
var is_owner: Bool = false
/// 圈子名字
var name: String = ""
/// 圈子icon
var icon_index: Int = 1
var groupIcon: UIImage {
UIImage(named: "GroupIcon/\(icon_index)") ?? UIImage()
}
/// 人数
var people_no: Int = 0
///
var description: String = ""
/// 会员等级
var level: String = ""
init?(map: Map) {
}
mutating func mapping(map: Map) {
group_key <- map["group_key"]
is_owner <- map["is_owner"]
name <- map["name"]
icon_index <- map["icon_index"]
level <- map["level"]
people_no <- (map["people_no"], kStrTransformInt)
}
}
extension GroupInfoModel: IdentifiableType {
public typealias Identity = String
public var identity: String {
return group_key
}
}
struct GroupMemberModel: Mappable, Equatable {
///
var user_id: String = ""
/// 头像,对应本地图标
var head_pic: String = "1"
/// 用户头像
var userIcon: UIImage {
UIImage(named: "UserIcon/\(head_pic)") ?? UIImage()
}
/// 昵称
var nick_name: String = ""
/// 会员等级 1普通 2白银 3永久 4钻石
var level: Int = 1
var vipIcon: UIImage {
if level != 2 || level != 4 {
return UIImage(named: "VipIcon/1") ?? UIImage()
}
return UIImage(named: "VipIcon/\(level)") ?? UIImage()
}
/// 是否在线
var is_online: Bool = false
/// 设备电量
var battery: String = ""
/// 最后在线时间
var last_active_time: Int = 0
/// 最后位置
var last_position: String = ""
var lastLocation: String {
guard last_position.contains(":") else { return "" }
let arr = last_position.components(separatedBy: ":")
return arr.last ?? ""
}
init?(map: Map) {
}
mutating func mapping(map: Map) {
user_id <- map["user_id"]
head_pic <- map["head_pic"]
level <- (map["level"], kStrTransformInt)
nick_name <- map["nick_name"]
battery <- map["battery"]
last_position <- map["last_position"]
is_online <- map["is_online"]
}
}
extension GroupMemberModel: IdentifiableType {
public typealias Identity = String
public var identity: String {
return user_id
}
}