CMSModel.swift 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. //
  2. // CMSModel.swift
  3. // Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
  4. import Foundation
  5. import ObjectMapper
  6. class CMSModel : NSObject, NSCoding, Mappable{
  7. var applyType : String?
  8. var content : [CMSContentModel]?
  9. var title : String?
  10. class func newInstance(map: Map) -> Mappable?{
  11. return CMSModel()
  12. }
  13. required init?(map: Map){}
  14. private override init(){}
  15. func mapping(map: Map)
  16. {
  17. applyType <- map["apply_type"]
  18. content <- map["content"]
  19. title <- map["title"]
  20. }
  21. /**
  22. * NSCoding required initializer.
  23. * Fills the data from the passed decoder
  24. */
  25. @objc required init(coder aDecoder: NSCoder)
  26. {
  27. applyType = aDecoder.decodeObject(forKey: "apply_type") as? String
  28. content = aDecoder.decodeObject(forKey: "content") as? [CMSContentModel]
  29. title = aDecoder.decodeObject(forKey: "title") as? String
  30. }
  31. /**
  32. * NSCoding required method.
  33. * Encodes mode properties into the decoder
  34. */
  35. @objc func encode(with aCoder: NSCoder)
  36. {
  37. if applyType != nil{
  38. aCoder.encode(applyType, forKey: "apply_type")
  39. }
  40. if content != nil{
  41. aCoder.encode(content, forKey: "content")
  42. }
  43. if title != nil{
  44. aCoder.encode(title, forKey: "title")
  45. }
  46. }
  47. }
  48. class CMSContentModel : NSObject, NSCoding, Mappable{
  49. var areaType : String?
  50. var rule : [CMSRuleModel]?
  51. class func newInstance(map: Map) -> Mappable?{
  52. return CMSContentModel()
  53. }
  54. required init?(map: Map){}
  55. private override init(){}
  56. func mapping(map: Map)
  57. {
  58. areaType <- map["area_type"]
  59. rule <- map["rule"]
  60. }
  61. /**
  62. * NSCoding required initializer.
  63. * Fills the data from the passed decoder
  64. */
  65. @objc required init(coder aDecoder: NSCoder)
  66. {
  67. areaType = aDecoder.decodeObject(forKey: "area_type") as? String
  68. rule = aDecoder.decodeObject(forKey: "rule") as? [CMSRuleModel]
  69. }
  70. /**
  71. * NSCoding required method.
  72. * Encodes mode properties into the decoder
  73. */
  74. @objc func encode(with aCoder: NSCoder)
  75. {
  76. if areaType != nil{
  77. aCoder.encode(areaType, forKey: "area_type")
  78. }
  79. if rule != nil{
  80. aCoder.encode(rule, forKey: "rule")
  81. }
  82. }
  83. }
  84. class CMSRuleModel : NSObject, Mappable{
  85. var linkType : Int?
  86. var linkUrl : String?
  87. var showNum : Int?
  88. var title : String?
  89. var url : String?
  90. var id : Int?
  91. var productId : String?
  92. var rule : CMSRuleModel?
  93. var showType : Int?
  94. var subjectId : String?
  95. class func newInstance(map: Map) -> Mappable?{
  96. return CMSRuleModel()
  97. }
  98. required init?(map: Map){}
  99. private override init(){}
  100. func mapping(map: Map)
  101. {
  102. linkType <- map["link_type"]
  103. linkUrl <- map["link_url"]
  104. showNum <- map["show_num"]
  105. title <- map["title"]
  106. url <- map["url"]
  107. id <- map["id"]
  108. productId <- map["product_id"]
  109. rule <- map["rule"]
  110. showType <- map["show_type"]
  111. subjectId <- map["subject_id"]
  112. }
  113. // let transform = TransformOf<String, Int>(fromJSON: { (value: Int?) -> String? in
  114. // // 将值从 Int? 变换为 String?
  115. // if let value = value {
  116. // return String(value)
  117. // }
  118. // return nil
  119. // }, toJSON: { (value: String?) -> Int? in
  120. // // 将值从 String? 变换为 Int?
  121. // return Int(value!)
  122. // })
  123. }