Files

120 lines
3.1 KiB
Swift
Raw Permalink 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.
import Foundation
/// 计划类型(周/月/年)。
public enum PlanType: String, CaseIterable, Hashable, Sendable {
case weekly
case monthly
case yearly
public var label: String {
switch self {
case .weekly: return "周计划"
case .monthly: return "月计划"
case .yearly: return "年计划"
}
}
}
/// 我提交的计划记录。
public struct MyPlanRecord: Hashable, Sendable {
public let status: String
public let submittedTime: String
public let content: String
public let attachments: [String]
public init(status: String, submittedTime: String, content: String, attachments: [String]) {
self.status = status
self.submittedTime = submittedTime
self.content = content
self.attachments = attachments
}
}
/// 小组成员(计划视角)。
public struct PlanMember: Identifiable, Hashable, Sendable {
public let id: String
public let name: String
public let filled: Bool
public init(id: String, name: String, filled: Bool) {
self.id = id
self.name = name
self.filled = filled
}
}
/// 小组计划统计(含成员)。
public struct PlanGroup: Identifiable, Hashable, Sendable {
public let id: String
public let name: String
public let checkedCount: Int
public let memberCount: Int
public let members: [PlanMember]
public init(id: String, name: String, checkedCount: Int, memberCount: Int, members: [PlanMember]) {
self.id = id
self.name = name
self.checkedCount = checkedCount
self.memberCount = memberCount
self.members = members
}
}
/// 计划页聚合数据。
public struct PlanRecord: Hashable, Sendable {
public let type: PlanType
public let periodKey: String
public let canSubmit: Bool
public let message: String?
public let myChecked: Bool
public let myRecord: MyPlanRecord?
public let groups: [PlanGroup]
public let unassignedCount: Int
public init(
type: PlanType,
periodKey: String,
canSubmit: Bool,
message: String?,
myChecked: Bool,
myRecord: MyPlanRecord?,
groups: [PlanGroup],
unassignedCount: Int
) {
self.type = type
self.periodKey = periodKey
self.canSubmit = canSubmit
self.message = message
self.myChecked = myChecked
self.myRecord = myRecord
self.groups = groups
self.unassignedCount = unassignedCount
}
}
/// 提交计划页数据。
public struct PlanSubmitData: Hashable, Sendable {
public let content: String
public let attachments: [String]
public let checked: Bool
public let canSubmit: Bool
public let message: String?
public let history: [MyPlanRecord]
public init(
content: String,
attachments: [String],
checked: Bool,
canSubmit: Bool,
message: String?,
history: [MyPlanRecord]
) {
self.content = content
self.attachments = attachments
self.checked = checked
self.canSubmit = canSubmit
self.message = message
self.history = history
}
}