Module.swift 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. //
  2. // Module.swift
  3. // O2Platform
  4. //
  5. // Created by 刘振兴 on 16/7/28.
  6. // Copyright © 2016年 zoneland. All rights reserved.
  7. //
  8. import Foundation
  9. import ObjectMapper
  10. class Module:Mappable{
  11. var createTime:String?
  12. var updateTime:String?
  13. var id:String?
  14. var name:String?
  15. var alias:String?
  16. var description:String?
  17. var application:String?
  18. required init?(map: Map) {
  19. }
  20. func mapping(map: Map) {
  21. createTime <- map["createTime"]
  22. updateTime <- map["updateTime"]
  23. id <- map["id"]
  24. name <- map["name"]
  25. alias <- map["alias"]
  26. description <- map["description"]
  27. application <- map["application"]
  28. }
  29. }
  30. struct HotpicEntity:Mappable{
  31. var application:String = "CMS|BBS"
  32. var infoId:String!
  33. var title:String!
  34. init?(map: Map) {
  35. }
  36. mutating func mapping(map: Map) {
  37. application<-map["application"]
  38. infoId<-map["infoId"]
  39. title<-map["title"]
  40. }
  41. }
  42. //
  43. // TaskImageshowEntity.swift
  44. // Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
  45. //滚动图片实体
  46. class TaskImageshowEntity : NSObject, NSCoding, Mappable{
  47. var application : String?
  48. var createTime : String?
  49. var creator : String?
  50. var distributeFactor : Int?
  51. var id : String?
  52. var infoId : String?
  53. var picUrl : String?
  54. var sequence : String?
  55. var title : String?
  56. var updateTime : String?
  57. var url : String?
  58. var picId:String?
  59. class func newInstance(map: Map) -> Mappable?{
  60. return TaskImageshowEntity()
  61. }
  62. required init?(map: Map){}
  63. private override init(){}
  64. func mapping(map: Map)
  65. {
  66. application <- map["application"]
  67. createTime <- map["createTime"]
  68. creator <- map["creator"]
  69. distributeFactor <- map["distributeFactor"]
  70. id <- map["id"]
  71. infoId <- map["infoId"]
  72. picUrl <- map["picUrl"]
  73. sequence <- map["sequence"]
  74. title <- map["title"]
  75. updateTime <- map["updateTime"]
  76. url <- map["url"]
  77. picId <- map["picId"]
  78. }
  79. /**
  80. * NSCoding required initializer.
  81. * Fills the data from the passed decoder
  82. */
  83. @objc required init(coder aDecoder: NSCoder)
  84. {
  85. application = aDecoder.decodeObject(forKey: "application") as? String
  86. createTime = aDecoder.decodeObject(forKey: "createTime") as? String
  87. creator = aDecoder.decodeObject(forKey: "creator") as? String
  88. distributeFactor = aDecoder.decodeObject(forKey: "distributeFactor") as? Int
  89. id = aDecoder.decodeObject(forKey: "id") as? String
  90. infoId = aDecoder.decodeObject(forKey: "infoId") as? String
  91. picUrl = aDecoder.decodeObject(forKey: "picUrl") as? String
  92. sequence = aDecoder.decodeObject(forKey: "sequence") as? String
  93. title = aDecoder.decodeObject(forKey: "title") as? String
  94. updateTime = aDecoder.decodeObject(forKey: "updateTime") as? String
  95. url = aDecoder.decodeObject(forKey: "url") as? String
  96. picId = aDecoder.decodeBool(forKey: "picId") as? String
  97. }
  98. /**
  99. * NSCoding required method.
  100. * Encodes mode properties into the decoder
  101. */
  102. @objc func encode(with aCoder: NSCoder)
  103. {
  104. if application != nil{
  105. aCoder.encode(application, forKey: "application")
  106. }
  107. if createTime != nil{
  108. aCoder.encode(createTime, forKey: "createTime")
  109. }
  110. if creator != nil{
  111. aCoder.encode(creator, forKey: "creator")
  112. }
  113. if distributeFactor != nil{
  114. aCoder.encode(distributeFactor, forKey: "distributeFactor")
  115. }
  116. if id != nil{
  117. aCoder.encode(id, forKey: "id")
  118. }
  119. if infoId != nil{
  120. aCoder.encode(infoId, forKey: "infoId")
  121. }
  122. if picUrl != nil{
  123. aCoder.encode(picUrl, forKey: "picUrl")
  124. }
  125. if sequence != nil{
  126. aCoder.encode(sequence, forKey: "sequence")
  127. }
  128. if title != nil{
  129. aCoder.encode(title, forKey: "title")
  130. }
  131. if updateTime != nil{
  132. aCoder.encode(updateTime, forKey: "updateTime")
  133. }
  134. if url != nil{
  135. aCoder.encode(url, forKey: "url")
  136. }
  137. if picId != nil{
  138. aCoder.encode(picId, forKey: "picId")
  139. }
  140. }
  141. }
  142. //任务分页分页模型
  143. struct CommonPageModel {
  144. var pageNumber:Int = 0
  145. var pageSize:Int = 20
  146. var pageTotal:Int = 0
  147. var nextPageId:String = "(0)"
  148. init() {
  149. }
  150. init(_ pageSize:Int) {
  151. self.pageSize = pageSize
  152. }
  153. mutating func setPageTotal(_ pageTotal:Int){
  154. self.pageTotal = pageTotal
  155. }
  156. mutating func nextPage(){
  157. if pageTotal > 0 && pageNumber * pageSize < pageTotal {
  158. pageNumber += 1
  159. }else{
  160. }
  161. }
  162. func toDictionary()->Dictionary<String,String>{
  163. return ["##id##":nextPageId,"##count##":pageSize.toString]
  164. }
  165. func isLast() -> Bool {
  166. return pageNumber * pageSize >= pageTotal
  167. }
  168. }