|
| 1 | + |
| 2 | +import Foundation |
| 3 | +import BSON |
| 4 | + |
| 5 | +public enum AttachmentType: String, Codable { |
| 6 | + case file, image, audio, video |
| 7 | +} |
| 8 | + |
| 9 | +public struct AttachmentInOutPut: Codable { |
| 10 | + |
| 11 | + public var id: ObjectId? |
| 12 | + public var type: AttachmentType |
| 13 | + public var userId: ObjectId? |
| 14 | + public var swapId: ObjectId? |
| 15 | + public var conversationId: ObjectId? |
| 16 | + public var imageUrlString: String? |
| 17 | + public var audioUrlString: String? |
| 18 | + public var videoUrlString: String? |
| 19 | + public var fileUrlString: String? |
| 20 | + public var createdAt: Date? |
| 21 | + public var updatedAt: Date? |
| 22 | + public var deletedAt: Date? |
| 23 | + |
| 24 | + public init( |
| 25 | + id: ObjectId? = nil, |
| 26 | + type: AttachmentType, |
| 27 | + userId: ObjectId? = nil, |
| 28 | + swapId: ObjectId? = nil, |
| 29 | + conversationId: ObjectId? = nil, |
| 30 | + imageUrlString: String? = nil, |
| 31 | + audioUrlString: String? = nil, |
| 32 | + videoUrlString: String? = nil, |
| 33 | + fileUrlString: String? = nil, |
| 34 | + createdAt: Date? = nil, |
| 35 | + updatedAt: Date? = nil, |
| 36 | + deletedAt: Date? = nil |
| 37 | + ) { |
| 38 | + self.id = id |
| 39 | + self.type = type |
| 40 | + self.userId = userId |
| 41 | + self.swapId = swapId |
| 42 | + self.imageUrlString = imageUrlString |
| 43 | + self.audioUrlString = audioUrlString |
| 44 | + self.videoUrlString = videoUrlString |
| 45 | + self.fileUrlString = fileUrlString |
| 46 | + self.createdAt = createdAt |
| 47 | + self.updatedAt = updatedAt |
| 48 | + self.deletedAt = deletedAt |
| 49 | + } |
| 50 | + |
| 51 | +} |
| 52 | + |
| 53 | +extension AttachmentInOutPut: Identifiable {} |
| 54 | + |
| 55 | +extension AttachmentInOutPut: Equatable { |
| 56 | + public static func < (lhs: AttachmentInOutPut, rhs: AttachmentInOutPut) -> Bool { |
| 57 | + guard let lhsDate = lhs.updatedAt, let rhsDate = rhs.createdAt else { return false } |
| 58 | + return lhsDate > rhsDate |
| 59 | + } |
| 60 | +} |
| 61 | + |
| 62 | +extension AttachmentInOutPut: Hashable {} |
0 commit comments