import Foundation import GeneralUtils class CongTruong: Mappable { var id: Int? var companyName: String? var constructionName: String? var noCaptured: Int?, noRemain: Int? var shootItems: [ShootItem]? var signboard: Int? func getShootItemsName(isWillshoot: Bool) -> String? { guard let shootItems = shootItems else { return nil } var result = ""; for item in shootItems { if (isWillshoot && item.willShoot != nil && item.willShoot! > 0) || !isWillshoot { if let name = item.name { if result.length > 0 { result = result + ", " } result = result + name; } if result.length > 100 { return result; } } } return result; } // region: ========== Mappable init() {} required init?(map: Map) {} func mapping(map: Map) { id <- map["id"] companyName <- map["companyName"] constructionName <- map["constructionName"] noCaptured <- map["noCaptured"] noRemain <- map["noRemain"] shootItems <- map["shootingItems"] signboard <- map["signBoard"] } //endregion }