Files
suixinkan_uikit/suixinkan/Features/Home/Models/PermissionApplyModels.swift
汉秋 efb3925257 完善首页权限申请流程与队列播报体验。
对齐 Android 无权限强制弹窗、角色下拉与申请页交互,补充 UIButton configuration 适配,并增强景区排队 TTS 与相关单元测试。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-14 13:46:45 +08:00

126 lines
3.5 KiB
Swift

//
// PermissionApplyModels.swift
// suixinkan
//
import Foundation
///
enum PermissionApplyDestination: Equatable {
case apply
case status(applyCode: String)
}
///
enum PermissionDeletionTarget: Equatable {
case role(name: String)
case scenic(id: Int, name: String)
/// Android
var dialogTitle: String {
switch self {
case .role: "是否删除该角色"
case .scenic: "是否删除该景区"
}
}
/// Android
var dialogMessage: String {
switch self {
case .role(let name): "您确定要删除\(name)角色吗?"
case .scenic(_, let name): "您确定要删除\(name)吗?"
}
}
}
///
struct RoleApplyPendingResponse: Decodable, Equatable {
let code: String
let roleId: Int
let roleName: String
let scenicList: [RoleApplyScenicItem]
let status: Int
let statusLabel: String
let createdAt: String
let auditNote: String
let auditedAt: String?
let auditedBy: String?
enum CodingKeys: String, CodingKey {
case code
case roleId = "role_id"
case roleName = "role_name"
case scenicList = "scenic_list"
case status
case statusLabel = "status_label"
case createdAt = "created_at"
case auditNote = "audit_note"
case auditedAt = "audited_at"
case auditedBy = "audited_by"
}
init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
code = try container.decodeIfPresent(String.self, forKey: .code) ?? ""
roleId = try container.decodeIfPresent(Int.self, forKey: .roleId) ?? 0
roleName = try container.decodeIfPresent(String.self, forKey: .roleName) ?? ""
scenicList = try container.decodeIfPresent([RoleApplyScenicItem].self, forKey: .scenicList) ?? []
status = try container.decodeIfPresent(Int.self, forKey: .status) ?? 0
statusLabel = try container.decodeIfPresent(String.self, forKey: .statusLabel) ?? ""
createdAt = try container.decodeIfPresent(String.self, forKey: .createdAt) ?? ""
auditNote = try container.decodeIfPresent(String.self, forKey: .auditNote) ?? ""
auditedAt = try container.decodeIfPresent(String.self, forKey: .auditedAt)
auditedBy = try container.decodeIfPresent(String.self, forKey: .auditedBy)
}
}
///
struct RoleApplyScenicItem: Decodable, Equatable {
let id: Int
let name: String
}
///
struct ScenicListAllResponse: Decodable, Equatable {
let total: Int
let list: [ScenicListItem]
init(total: Int = 0, list: [ScenicListItem] = []) {
self.total = total
self.list = list
}
}
///
struct ScenicListItem: Decodable, Equatable {
let id: Int
let name: String
}
///
struct RoleApplySubmitRequest: Encodable {
let scenicId: [Int]
let roleId: Int
enum CodingKeys: String, CodingKey {
case scenicId = "scenic_id"
case roleId = "role_id"
}
}
///
struct RoleOption: Equatable, Hashable {
let id: Int
let name: String
let description: String
var isSelected: Bool
}
///
struct ScenicOption: Equatable, Hashable {
let id: Int
let name: String
var isSelected: Bool
var isDisabled: Bool
}