Files
suixinkan_uikit/suixinkan/Features/Home/Models/RolePermissionModels.swift
汉秋 3b17b7f7f0 Implement permission-driven home tab aligned with Android.
Load role-permission on first visit to drive menus, role-based layout, store card, and location reporting with account-scoped persistence and unit tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-06 17:27:54 +08:00

144 lines
3.1 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.

//
// RolePermissionModels.swift
// suixinkan
//
import Foundation
/// Android `RolePermissionResponse`
struct RolePermissionResponse: Codable, Equatable, Sendable {
let role: RoleInfo
let scenic: [ScenicInfo]
init(role: RoleInfo, scenic: [ScenicInfo] = []) {
self.role = role
self.scenic = scenic
}
}
///
struct RoleInfo: Codable, Equatable, Sendable {
let id: Int
let name: String
let roleCode: String
let notes: String?
let permission: [PermissionItem]
enum CodingKeys: String, CodingKey {
case id
case name
case roleCode = "role_code"
case notes
case permission
}
init(
id: Int = 0,
name: String = "",
roleCode: String = "",
notes: String? = nil,
permission: [PermissionItem] = []
) {
self.id = id
self.name = name
self.roleCode = roleCode
self.notes = notes
self.permission = permission
}
}
///
struct PermissionItem: Codable, Equatable, Sendable {
let id: Int
let pid: Int
let name: String
let uri: String
let iconSrc: String?
let children: [PermissionItem]?
enum CodingKeys: String, CodingKey {
case id
case pid
case name
case uri
case iconSrc = "icon_src"
case children
}
init(
id: Int = 0,
pid: Int = 0,
name: String = "",
uri: String = "",
iconSrc: String? = nil,
children: [PermissionItem]? = nil
) {
self.id = id
self.pid = pid
self.name = name
self.uri = uri
self.iconSrc = iconSrc
self.children = children
}
}
///
struct ScenicInfo: Codable, Equatable, Sendable, Hashable {
let id: Int
let name: String
let status: Int
let location: ScenicLocationInfo?
let coverImg: String?
enum CodingKeys: String, CodingKey {
case id
case name
case status
case location
case coverImg = "cover_img"
}
init(
id: Int = 0,
name: String = "",
status: Int = 0,
location: ScenicLocationInfo? = nil,
coverImg: String? = nil
) {
self.id = id
self.name = name
self.status = status
self.location = location
self.coverImg = coverImg
}
}
///
struct ScenicLocationInfo: Codable, Equatable, Sendable, Hashable {
let lng: Double
let lat: Double
let address: String
}
/// 使
struct HomePermissionItem: Codable, Equatable, Sendable, Hashable {
let id: String
let name: String
let uri: String
let pid: Int
init(id: String, name: String, uri: String, pid: Int = 0) {
self.id = id
self.name = name
self.uri = uri
self.pid = pid
}
init(from item: PermissionItem) {
self.id = String(item.id)
self.name = item.name
self.uri = item.uri
self.pid = item.pid
}
}