O2AuthenticationModels.swift 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017
  1. //
  2. // O2AuthenticationModels.swift
  3. // O2OA_SDK_Framwork
  4. //
  5. // Created by FancyLou on 2018/11/7.
  6. //
  7. import Foundation
  8. import HandyJSON
  9. // MARK: - 绑定collect服务器相关的models
  10. /// 注册节点请求的model
  11. public class O2NodeReqModel: DataModel {
  12. required public init() {}
  13. public var description: String {
  14. return toJSONString(prettyPrint: true) ?? ""
  15. }
  16. @objc var mobile:String?
  17. @objc var value:String?
  18. @objc var meta:String?
  19. }
  20. /// 注册节点返回的model
  21. public class O2NodeResModel: NSObject, DataModel, NSCoding {
  22. public func encode(with aCoder: NSCoder) {
  23. if value != nil {
  24. aCoder.encode(value, forKey: "value")
  25. }
  26. }
  27. public required init?(coder aDecoder: NSCoder) {
  28. value = aDecoder.decodeObject(forKey: "value") as? Bool
  29. }
  30. required public override init() {}
  31. public override var description: String {
  32. return toJSONString(prettyPrint: true) ?? ""
  33. }
  34. var value:Bool?
  35. }
  36. // 短信验证码返回
  37. public class O2MobileCodeResModel: NSObject, DataModel, NSCoding {
  38. public func encode(with aCoder: NSCoder) {
  39. if answer != nil {
  40. aCoder.encode(answer, forKey: "answer")
  41. }
  42. }
  43. public required init?(coder aDecoder: NSCoder) {
  44. answer = aDecoder.decodeObject(forKey: "answer") as? String
  45. }
  46. required public override init() {}
  47. public override var description: String {
  48. return toJSONString(prettyPrint: true) ?? ""
  49. }
  50. @objc var answer: String?
  51. }
  52. /// 中心服务器节点Model
  53. public protocol IO2BindUnitModel: HandyJSON, CustomStringConvertible {
  54. var id:String? { get set }
  55. var pinyin:String? { get set }
  56. var pinyinInitial:String? { get set }
  57. var httpProtocol:String? { get set }
  58. var name:String? { get set }
  59. var centerHost:String? { get set }
  60. var centerContext:String? { get set }
  61. var centerPort:Int? { get set }
  62. var urlMapping: String? { get set }
  63. }
  64. open class O2BindUnitModel: NSObject, DataModel, NSCoding, IO2BindUnitModel {
  65. @objc open var id:String?
  66. @objc open var pinyin:String?
  67. @objc open var pinyinInitial:String?
  68. @objc open var httpProtocol:String?
  69. @objc open var name:String?
  70. @objc open var centerHost:String?
  71. @objc open var centerContext:String?
  72. open var centerPort:Int?
  73. @objc open var urlMapping: String?
  74. /// 代理地址配置
  75. /// 如: {"qywx.o2oa.net:80":"qywx.o2oa.net/dev/web", "qywx.o2oa.net:20020":"qywx.o2oa.net/dev/app", "qywx.o2oa.net:20030":"qywx.o2oa.net/dev/center"}
  76. public func urlMappingDecode() -> Dictionary<String, Any>? {
  77. if urlMapping != nil && !urlMapping!.isBlank {
  78. if let jsonData = urlMapping?.data(using: .utf8) {
  79. do {
  80. let dc = try JSONSerialization.jsonObject(with: jsonData, options: .mutableContainers)
  81. return dc as? Dictionary<String, Any>
  82. } catch _ {
  83. print("json 转化 出错")
  84. }
  85. }
  86. }
  87. return nil
  88. }
  89. ///
  90. /// 将服务器地址替换成 urlMapping地址
  91. public func transUrl2Mapping(url: String) -> String? {
  92. var result: String? = nil
  93. if url.isEmpty {
  94. return result
  95. }
  96. if let d = urlMappingDecode() {
  97. if !d.isEmpty {
  98. d.keys.forEach { (key) in
  99. if url.contains(key) {
  100. if let v = d[key] as? String {
  101. result = url.replacingOccurrences(of: key, with: v)
  102. }
  103. }
  104. }
  105. }
  106. }
  107. return result
  108. }
  109. public func encode(with aCoder: NSCoder) {
  110. if id != nil {
  111. aCoder.encode(id, forKey: "id")
  112. }
  113. if pinyin != nil {
  114. aCoder.encode(pinyin, forKey: "pinyin")
  115. }
  116. if httpProtocol != nil {
  117. aCoder.encode(httpProtocol, forKey: "httpProtocol")
  118. }
  119. if pinyinInitial != nil {
  120. aCoder.encode(pinyinInitial, forKey: "pinyinInitial")
  121. }
  122. if name != nil {
  123. aCoder.encode(name, forKey: "name")
  124. }
  125. if centerHost != nil {
  126. aCoder.encode(centerHost, forKey: "centerHost")
  127. }
  128. if centerContext != nil {
  129. aCoder.encode(centerContext, forKey: "centerContext")
  130. }
  131. if centerPort != nil {
  132. aCoder.encode(centerPort, forKey: "centerPort")
  133. }
  134. if urlMapping != nil {
  135. aCoder.encode(urlMapping, forKey: "urlMapping")
  136. }
  137. }
  138. public required init?(coder aDecoder: NSCoder) {
  139. id = aDecoder.decodeObject(forKey: "id") as? String
  140. pinyin = aDecoder.decodeObject(forKey: "pinyin") as? String
  141. httpProtocol = aDecoder.decodeObject(forKey: "httpProtocol") as? String
  142. pinyinInitial = aDecoder.decodeObject(forKey: "pinyinInitial") as? String
  143. name = aDecoder.decodeObject(forKey: "name") as? String
  144. centerHost = aDecoder.decodeObject(forKey: "centerHost") as? String
  145. centerContext = aDecoder.decodeObject(forKey: "centerContext") as? String
  146. centerPort = aDecoder.decodeObject(forKey: "centerPort") as? Int
  147. urlMapping = aDecoder.decodeObject(forKey: "urlMapping") as? String
  148. }
  149. required public override init() {}
  150. open override var description: String {
  151. return toJSONString(prettyPrint: true) ?? ""
  152. }
  153. }
  154. /// 手机绑定节点的对象
  155. public protocol IO2BindDeviceModel: HandyJSON, CustomStringConvertible {
  156. //选择的节点名称
  157. var unit:String? { get set }
  158. //手机号码
  159. var mobile:String? { get set }
  160. //验证码
  161. var code:String? { get set }
  162. //设备推送的token
  163. var name:String? { get set }
  164. //设备类型
  165. var deviceType:String { get set }
  166. }
  167. open class O2BindDeviceModel: NSObject, DataModel, NSCoding,IO2BindDeviceModel {
  168. //选择的节点名称
  169. @objc open var unit:String?
  170. //手机号码
  171. @objc open var mobile:String?
  172. //验证码
  173. @objc open var code:String?
  174. //设备推送的token
  175. @objc open var name:String?
  176. //设备类型
  177. @objc open var deviceType:String = "ios"
  178. public func encode(with aCoder: NSCoder) {
  179. if unit != nil {
  180. aCoder.encode(unit, forKey: "unit")
  181. }
  182. if mobile != nil {
  183. aCoder.encode(mobile, forKey: "mobile")
  184. }
  185. if code != nil {
  186. aCoder.encode(code, forKey: "code")
  187. }
  188. if name != nil {
  189. aCoder.encode(name, forKey: "name")
  190. }
  191. aCoder.encode(deviceType, forKey: "deviceType")
  192. }
  193. public required init?(coder aDecoder: NSCoder) {
  194. unit = aDecoder.decodeObject(forKey: "unit") as? String
  195. mobile = aDecoder.decodeObject(forKey: "mobile") as? String
  196. code = aDecoder.decodeObject(forKey: "code") as? String
  197. name = aDecoder.decodeObject(forKey: "name") as? String
  198. deviceType = aDecoder.decodeObject(forKey: "deviceType") as! String
  199. }
  200. required public override init() {}
  201. open override var description: String {
  202. return toJSONString(prettyPrint: true) ?? ""
  203. }
  204. }
  205. //MARK: - 中心服务器相关对象
  206. /// api服务模块信息对象
  207. public protocol IO2APIServerModel: HandyJSON, CustomStringConvertible {
  208. var httpProtocol:String? { get set }
  209. var host:String? { get set }
  210. var name:String? { get set }
  211. var context:String? { get set }
  212. var port:Int? { get set }
  213. }
  214. open class O2APIServerModel: NSObject, DataModel, NSCoding, IO2APIServerModel {
  215. @objc open var httpProtocol:String?
  216. @objc open var host:String?
  217. @objc open var name:String?
  218. @objc open var context:String?
  219. open var port:Int?
  220. public func encode(with aCoder: NSCoder) {
  221. if httpProtocol != nil {
  222. aCoder.encode(httpProtocol, forKey: "httpProtocol")
  223. }
  224. if name != nil {
  225. aCoder.encode(name, forKey: "name")
  226. }
  227. if host != nil {
  228. aCoder.encode(host, forKey: "host")
  229. }
  230. if context != nil {
  231. aCoder.encode(context, forKey: "context")
  232. }
  233. if port != nil {
  234. aCoder.encode(port, forKey: "port")
  235. }
  236. }
  237. public required init?(coder aDecoder: NSCoder) {
  238. httpProtocol = aDecoder.decodeObject(forKey: "httpProtocol") as? String
  239. name = aDecoder.decodeObject(forKey: "name") as? String
  240. host = aDecoder.decodeObject(forKey: "host") as? String
  241. context = aDecoder.decodeObject(forKey: "context") as? String
  242. port = aDecoder.decodeObject(forKey: "port") as? Int
  243. }
  244. required public override init() {}
  245. open override var description: String {
  246. return toJSONString(prettyPrint: true) ?? ""
  247. }
  248. }
  249. /// web服务器信息对象
  250. public protocol IO2WebServerModel: HandyJSON, CustomStringConvertible {
  251. var httpProtocol:String? { get set }
  252. var host:String? { get set }
  253. var port:Int? { get set }
  254. }
  255. open class O2WebServerModel: NSObject, DataModel, NSCoding, IO2WebServerModel {
  256. @objc open var httpProtocol:String?
  257. @objc open var host:String?
  258. open var port:Int?
  259. public func encode(with aCoder: NSCoder) {
  260. if httpProtocol != nil {
  261. aCoder.encode(httpProtocol, forKey: "httpProtocol")
  262. }
  263. if host != nil {
  264. aCoder.encode(host, forKey: "host")
  265. }
  266. if port != nil {
  267. aCoder.encode(port, forKey: "port")
  268. }
  269. }
  270. public required init?(coder aDecoder: NSCoder) {
  271. httpProtocol = aDecoder.decodeObject(forKey: "httpProtocol") as? String
  272. host = aDecoder.decodeObject(forKey: "host") as? String
  273. port = aDecoder.decodeObject(forKey: "port") as? Int
  274. }
  275. required public override init() {}
  276. open override var description: String {
  277. return toJSONString(prettyPrint: true) ?? ""
  278. }
  279. }
  280. /// 中心服务器信息对象
  281. public protocol IO2CenterServerModel: HandyJSON, CustomStringConvertible {
  282. var assembles:[String: O2APIServerModel]? { get set }
  283. var webServer: O2WebServerModel? { get set }
  284. var tokenName: String? { get set }
  285. }
  286. open class O2CenterServerModel: NSObject, DataModel, NSCoding, IO2CenterServerModel {
  287. @objc open var assembles:[String: O2APIServerModel]?
  288. @objc open var webServer: O2WebServerModel?
  289. @objc open var tokenName: String? // tokenName是可修改的 x-token是默认值
  290. public func encode(with aCoder: NSCoder) {
  291. if assembles != nil {
  292. aCoder.encode(assembles, forKey: "assembles")
  293. }
  294. if webServer != nil {
  295. aCoder.encode(webServer, forKey: "webServer")
  296. }
  297. if tokenName != nil {
  298. aCoder.encode(tokenName, forKey: "tokenName")
  299. }
  300. }
  301. public required init?(coder aDecoder: NSCoder) {
  302. assembles = aDecoder.decodeObject(forKey: "assembles") as? [String : O2APIServerModel]
  303. webServer = aDecoder.decodeObject(forKey: "webServer") as? O2WebServerModel
  304. tokenName = aDecoder.decodeObject(forKey: "tokenName") as? String
  305. }
  306. required public override init() {}
  307. open override var description: String {
  308. return toJSONString(prettyPrint: true) ?? ""
  309. }
  310. }
  311. //MARK: - 登录认证相关的对象
  312. // 登录模式
  313. public class O2LoginMode: HandyJSON, CustomStringConvertible, NSCoding {
  314. var captchaLogin: Bool? //图片验证码登录
  315. var codeLogin: Bool? //短信验证码登录
  316. var bindLogin: Bool?
  317. var faceLogin: Bool?
  318. public func encode(with aCoder: NSCoder) {
  319. if captchaLogin != nil {
  320. aCoder.encode(captchaLogin, forKey: "captchaLogin")
  321. }
  322. if codeLogin != nil {
  323. aCoder.encode(codeLogin, forKey: "codeLogin")
  324. }
  325. if bindLogin != nil {
  326. aCoder.encode(bindLogin, forKey: "bindLogin")
  327. }
  328. if faceLogin != nil {
  329. aCoder.encode(faceLogin, forKey: "faceLogin")
  330. }
  331. }
  332. public required init?(coder aDecoder: NSCoder) {
  333. captchaLogin = aDecoder.decodeObject(forKey: "captchaLogin") as? Bool
  334. codeLogin = aDecoder.decodeObject(forKey: "codeLogin") as? Bool
  335. bindLogin = aDecoder.decodeObject(forKey: "bindLogin") as? Bool
  336. faceLogin = aDecoder.decodeObject(forKey: "faceLogin") as? Bool
  337. }
  338. required public init() {}
  339. public var description: String {
  340. return toJSONString(prettyPrint: true) ?? ""
  341. }
  342. }
  343. // 图片验证码
  344. public class O2LoginCaptchaImgData: HandyJSON, CustomStringConvertible, NSCoding {
  345. var id: String?
  346. var image: String? //图片验证码 base64
  347. public func encode(with aCoder: NSCoder) {
  348. if image != nil {
  349. aCoder.encode(image, forKey: "image")
  350. }
  351. if id != nil {
  352. aCoder.encode(id, forKey: "id")
  353. }
  354. }
  355. public required init?(coder aDecoder: NSCoder) {
  356. id = aDecoder.decodeObject(forKey: "id") as? String
  357. image = aDecoder.decodeObject(forKey: "image") as? String
  358. }
  359. required public init() {}
  360. public var description: String {
  361. return toJSONString(prettyPrint: true) ?? ""
  362. }
  363. }
  364. ///
  365. /// 登录的form对象
  366. /// 支持用户名密码登录 可以包含图片验证码
  367. ///
  368. public class O2LoginWithCaptchaForm: HandyJSON, CustomStringConvertible, NSCoding {
  369. var credential: String? // 用户名
  370. var password: String? // 密码
  371. var captcha: String? // 图片认证编号id
  372. var captchaAnswer: String? // 图片认证码
  373. var isEncrypted: String? // 是否启用加密 "y"
  374. public func encode(with aCoder: NSCoder) {
  375. if credential != nil {
  376. aCoder.encode(credential, forKey: "credential")
  377. }
  378. if password != nil {
  379. aCoder.encode(password, forKey: "password")
  380. }
  381. if captcha != nil {
  382. aCoder.encode(captcha, forKey: "captcha")
  383. }
  384. if captchaAnswer != nil {
  385. aCoder.encode(captchaAnswer, forKey: "captchaAnswer")
  386. }
  387. if isEncrypted != nil {
  388. aCoder.encode(isEncrypted, forKey: "isEncrypted")
  389. }
  390. }
  391. public required init?(coder aDecoder: NSCoder) {
  392. credential = aDecoder.decodeObject(forKey: "credential") as? String
  393. password = aDecoder.decodeObject(forKey: "password") as? String
  394. captcha = aDecoder.decodeObject(forKey: "captcha") as? String
  395. captchaAnswer = aDecoder.decodeObject(forKey: "captchaAnswer") as? String
  396. isEncrypted = aDecoder.decodeObject(forKey: "isEncrypted") as? String
  397. }
  398. required public init() {}
  399. public var description: String {
  400. return toJSONString(prettyPrint: true) ?? ""
  401. }
  402. }
  403. /// 当前登录用户对象信息
  404. public protocol IO2LoginAccountModel: HandyJSON, CustomStringConvertible {
  405. var changePasswordTime : String? { get set }
  406. var controllerList : [AnyObject]? { get set }
  407. var createTime : String? { get set }
  408. var distinguishedName : String? { get set }
  409. var employee : String? { get set }
  410. var genderType : String? { get set }
  411. var icon : String? { get set }
  412. var id : String? { get set }
  413. var lastLoginAddress : String? { get set }
  414. var lastLoginClient : String? { get set }
  415. var lastLoginTime : String? { get set }
  416. var mail : String? { get set }
  417. var mobile : String? { get set }
  418. var name : String? { get set }
  419. var passwordExpired : Bool? { get set }
  420. var pinyin : String? { get set }
  421. var pinyinInitial : String? { get set }
  422. var qq : String? { get set }
  423. var roleList : [AnyObject]? { get set }
  424. var token : String? { get set }
  425. var tokenType : String? { get set }
  426. var unique : String? { get set }
  427. var updateTime : String? { get set }
  428. var weixin : String? { get set }
  429. }
  430. open class O2LoginAccountModel: NSObject, DataModel, NSCoding, IO2LoginAccountModel {
  431. @objc open var changePasswordTime : String?
  432. @objc open var controllerList : [AnyObject]?
  433. @objc open var createTime : String?
  434. @objc open var distinguishedName : String?
  435. @objc open var employee : String?
  436. @objc open var genderType : String?
  437. @objc open var icon : String?
  438. @objc open var id : String?
  439. @objc open var lastLoginAddress : String?
  440. @objc open var lastLoginClient : String?
  441. @objc open var lastLoginTime : String?
  442. @objc open var mail : String?
  443. @objc open var mobile : String?
  444. @objc open var name : String?
  445. open var passwordExpired : Bool?
  446. @objc open var pinyin : String?
  447. @objc open var pinyinInitial : String?
  448. @objc open var qq : String?
  449. @objc open var roleList : [AnyObject]?
  450. @objc open var token : String?
  451. @objc open var tokenType : String?
  452. @objc open var unique : String?
  453. @objc open var updateTime : String?
  454. @objc open var weixin : String?
  455. @objc open var signature: String?
  456. public func encode(with aCoder: NSCoder) {
  457. if changePasswordTime != nil{
  458. aCoder.encode(changePasswordTime, forKey: "changePasswordTime")
  459. }
  460. if controllerList != nil{
  461. aCoder.encode(controllerList, forKey: "controllerList")
  462. }
  463. if createTime != nil{
  464. aCoder.encode(createTime, forKey: "createTime")
  465. }
  466. if distinguishedName != nil{
  467. aCoder.encode(distinguishedName, forKey: "distinguishedName")
  468. }
  469. if employee != nil{
  470. aCoder.encode(employee, forKey: "employee")
  471. }
  472. if genderType != nil{
  473. aCoder.encode(genderType, forKey: "genderType")
  474. }
  475. if icon != nil{
  476. aCoder.encode(icon, forKey: "icon")
  477. }
  478. if id != nil{
  479. aCoder.encode(id, forKey: "id")
  480. }
  481. if lastLoginAddress != nil{
  482. aCoder.encode(lastLoginAddress, forKey: "lastLoginAddress")
  483. }
  484. if lastLoginClient != nil{
  485. aCoder.encode(lastLoginClient, forKey: "lastLoginClient")
  486. }
  487. if lastLoginTime != nil{
  488. aCoder.encode(lastLoginTime, forKey: "lastLoginTime")
  489. }
  490. if mail != nil{
  491. aCoder.encode(mail, forKey: "mail")
  492. }
  493. if mobile != nil{
  494. aCoder.encode(mobile, forKey: "mobile")
  495. }
  496. if name != nil{
  497. aCoder.encode(name, forKey: "name")
  498. }
  499. if passwordExpired != nil{
  500. aCoder.encode(passwordExpired, forKey: "passwordExpired")
  501. }
  502. if pinyin != nil{
  503. aCoder.encode(pinyin, forKey: "pinyin")
  504. }
  505. if pinyinInitial != nil{
  506. aCoder.encode(pinyinInitial, forKey: "pinyinInitial")
  507. }
  508. if qq != nil{
  509. aCoder.encode(qq, forKey: "qq")
  510. }
  511. if roleList != nil{
  512. aCoder.encode(roleList, forKey: "roleList")
  513. }
  514. if token != nil{
  515. aCoder.encode(token, forKey: "token")
  516. }
  517. if tokenType != nil{
  518. aCoder.encode(tokenType, forKey: "tokenType")
  519. }
  520. if unique != nil{
  521. aCoder.encode(unique, forKey: "unique")
  522. }
  523. if updateTime != nil{
  524. aCoder.encode(updateTime, forKey: "updateTime")
  525. }
  526. if weixin != nil{
  527. aCoder.encode(weixin, forKey: "weixin")
  528. }
  529. if signature != nil {
  530. aCoder.encode(signature, forKey: "signature")
  531. }
  532. }
  533. public required init?(coder aDecoder: NSCoder) {
  534. changePasswordTime = aDecoder.decodeObject(forKey: "changePasswordTime") as? String
  535. controllerList = aDecoder.decodeObject(forKey: "controllerList") as? [AnyObject]
  536. createTime = aDecoder.decodeObject(forKey: "createTime") as? String
  537. distinguishedName = aDecoder.decodeObject(forKey: "distinguishedName") as? String
  538. employee = aDecoder.decodeObject(forKey: "employee") as? String
  539. genderType = aDecoder.decodeObject(forKey: "genderType") as? String
  540. icon = aDecoder.decodeObject(forKey: "icon") as? String
  541. id = aDecoder.decodeObject(forKey: "id") as? String
  542. lastLoginAddress = aDecoder.decodeObject(forKey: "lastLoginAddress") as? String
  543. lastLoginClient = aDecoder.decodeObject(forKey: "lastLoginClient") as? String
  544. lastLoginTime = aDecoder.decodeObject(forKey: "lastLoginTime") as? String
  545. mail = aDecoder.decodeObject(forKey: "mail") as? String
  546. mobile = aDecoder.decodeObject(forKey: "mobile") as? String
  547. name = aDecoder.decodeObject(forKey: "name") as? String
  548. passwordExpired = aDecoder.decodeObject(forKey: "passwordExpired") as? Bool
  549. pinyin = aDecoder.decodeObject(forKey: "pinyin") as? String
  550. pinyinInitial = aDecoder.decodeObject(forKey: "pinyinInitial") as? String
  551. qq = aDecoder.decodeObject(forKey: "qq") as? String
  552. roleList = aDecoder.decodeObject(forKey: "roleList") as? [AnyObject]
  553. token = aDecoder.decodeObject(forKey: "token") as? String
  554. tokenType = aDecoder.decodeObject(forKey: "tokenType") as? String
  555. unique = aDecoder.decodeObject(forKey: "unique") as? String
  556. updateTime = aDecoder.decodeObject(forKey: "updateTime") as? String
  557. weixin = aDecoder.decodeObject(forKey: "weixin") as? String
  558. signature = aDecoder.decodeObject(forKey: "signature") as? String
  559. }
  560. required public override init() {}
  561. open override var description: String {
  562. return toJSONString(prettyPrint: true) ?? ""
  563. }
  564. }
  565. //MARK: - customStyle 移动端样式配置相关对象
  566. /// 自定义图片对象
  567. public protocol IO2CustomImageModel: HandyJSON, CustomStringConvertible {
  568. var name : String? { get set }
  569. var value : String? { get set }
  570. }
  571. open class O2CustomImageModel: NSObject, DataModel, NSCoding, IO2CustomImageModel {
  572. @objc open var name : String?
  573. @objc open var value : String? // base64 图片
  574. public func encode(with aCoder: NSCoder) {
  575. if name != nil {
  576. aCoder.encode(name, forKey: "name")
  577. }
  578. if value != nil {
  579. aCoder.encode(value, forKey: "value")
  580. }
  581. }
  582. public required init?(coder aDecoder: NSCoder) {
  583. name = aDecoder.decodeObject(forKey: "name") as? String
  584. value = aDecoder.decodeObject(forKey: "value") as? String
  585. }
  586. required public override init() {}
  587. open override var description: String {
  588. return toJSONString(prettyPrint: true) ?? ""
  589. }
  590. }
  591. public protocol IO2CustomIosModel: HandyJSON, CustomStringConvertible {
  592. var category : String? { get set }
  593. var storyboard : String? { get set }
  594. var subcategory : String? { get set }
  595. var vcname : String? { get set }
  596. }
  597. open class O2CustomIosModel: NSObject, DataModel, NSCoding, IO2CustomIosModel {
  598. @objc open var category : String?
  599. @objc open var storyboard : String?
  600. @objc open var subcategory : String?
  601. @objc open var vcname : String?
  602. public func encode(with aCoder: NSCoder) {
  603. if category != nil {
  604. aCoder.encode(category, forKey: "category")
  605. }
  606. if storyboard != nil {
  607. aCoder.encode(storyboard, forKey: "storyboard")
  608. }
  609. if subcategory != nil {
  610. aCoder.encode(subcategory, forKey: "subcategory")
  611. }
  612. if vcname != nil {
  613. aCoder.encode(vcname, forKey: "vcname")
  614. }
  615. }
  616. public required init?(coder aDecoder: NSCoder) {
  617. category = aDecoder.decodeObject(forKey: "category") as? String
  618. storyboard = aDecoder.decodeObject(forKey: "storyboard") as? String
  619. subcategory = aDecoder.decodeObject(forKey: "subcategory") as? String
  620. vcname = aDecoder.decodeObject(forKey: "vcname") as? String
  621. }
  622. required public override init() {}
  623. open override var description: String {
  624. return toJSONString(prettyPrint: true) ?? ""
  625. }
  626. }
  627. public protocol IO2CustomNativeAppModel: HandyJSON, CustomStringConvertible {
  628. var enable : Bool? { get set }
  629. var iOS : O2CustomIosModel? { get set }
  630. var id : Int? { get set }
  631. var key : String? { get set }
  632. var name : String? { get set }
  633. }
  634. open class O2CustomNativeAppModel: NSObject, DataModel, NSCoding, IO2CustomNativeAppModel {
  635. open var enable : Bool?
  636. @objc open var iOS : O2CustomIosModel?
  637. open var id : Int?
  638. @objc open var key : String?
  639. @objc open var name : String?
  640. public func encode(with aCoder: NSCoder) {
  641. if enable != nil {
  642. aCoder.encode(enable, forKey: "enable")
  643. }
  644. if iOS != nil {
  645. aCoder.encode(iOS, forKey: "iOS")
  646. }
  647. if id != nil {
  648. aCoder.encode(id, forKey: "id")
  649. }
  650. if key != nil {
  651. aCoder.encode(key, forKey: "key")
  652. }
  653. if name != nil {
  654. aCoder.encode(name, forKey: "name")
  655. }
  656. }
  657. public required init?(coder aDecoder: NSCoder) {
  658. enable = aDecoder.decodeObject(forKey: "enable") as? Bool
  659. iOS = aDecoder.decodeObject(forKey: "iOS") as? O2CustomIosModel
  660. id = aDecoder.decodeObject(forKey: "id") as? Int
  661. key = aDecoder.decodeObject(forKey: "key") as? String
  662. name = aDecoder.decodeObject(forKey: "name") as? String
  663. }
  664. required public override init() {}
  665. open override var description: String {
  666. return toJSONString(prettyPrint: true) ?? ""
  667. }
  668. }
  669. public protocol IO2CustomPortalAppModel: HandyJSON, CustomStringConvertible {
  670. var alias : String? { get set }
  671. var createTime : String? { get set }
  672. var creatorPerson : String? { get set }
  673. var descriptionField : String? { get set }
  674. var enable : Bool? { get set }
  675. var firstPage : String? { get set }
  676. var id : String? { get set }
  677. var lastUpdatePerson : String? { get set }
  678. var lastUpdateTime : String? { get set }
  679. var name : String? { get set }
  680. var portalCategory : String? { get set }
  681. var updateTime : String? { get set }
  682. }
  683. open class O2CustomPortalAppModel: NSObject, DataModel, NSCoding, IO2CustomPortalAppModel {
  684. @objc open var alias : String?
  685. @objc open var createTime : String?
  686. @objc open var creatorPerson : String?
  687. @objc open var descriptionField : String?
  688. open var enable : Bool?
  689. @objc open var firstPage : String?
  690. @objc open var id : String?
  691. @objc open var lastUpdatePerson : String?
  692. @objc open var lastUpdateTime : String?
  693. @objc open var name : String?
  694. @objc open var portalCategory : String?
  695. @objc open var updateTime : String?
  696. public func encode(with aCoder: NSCoder) {
  697. if alias != nil {
  698. aCoder.encode(alias, forKey: "alias")
  699. }
  700. if createTime != nil {
  701. aCoder.encode(createTime, forKey: "createTime")
  702. }
  703. if creatorPerson != nil {
  704. aCoder.encode(creatorPerson, forKey: "creatorPerson")
  705. }
  706. if descriptionField != nil {
  707. aCoder.encode(descriptionField, forKey: "descriptionField")
  708. }
  709. if enable != nil {
  710. aCoder.encode(enable, forKey: "enable")
  711. }
  712. if firstPage != nil {
  713. aCoder.encode(firstPage, forKey: "firstPage")
  714. }
  715. if id != nil {
  716. aCoder.encode(id, forKey: "id")
  717. }
  718. if lastUpdatePerson != nil {
  719. aCoder.encode(lastUpdatePerson, forKey: "lastUpdatePerson")
  720. }
  721. if lastUpdateTime != nil {
  722. aCoder.encode(lastUpdateTime, forKey: "lastUpdateTime")
  723. }
  724. if name != nil {
  725. aCoder.encode(name, forKey: "name")
  726. }
  727. if portalCategory != nil {
  728. aCoder.encode(portalCategory, forKey: "portalCategory")
  729. }
  730. if updateTime != nil {
  731. aCoder.encode(updateTime, forKey: "updateTime")
  732. }
  733. }
  734. public required init?(coder aDecoder: NSCoder) {
  735. alias = aDecoder.decodeObject(forKey: "alias") as? String
  736. createTime = aDecoder.decodeObject(forKey: "createTime") as? String
  737. creatorPerson = aDecoder.decodeObject(forKey: "creatorPerson") as? String
  738. descriptionField = aDecoder.decodeObject(forKey: "descriptionField") as? String
  739. enable = aDecoder.decodeObject(forKey: "enable") as? Bool
  740. firstPage = aDecoder.decodeObject(forKey: "firstPage") as? String
  741. id = aDecoder.decodeObject(forKey: "id") as? String
  742. lastUpdatePerson = aDecoder.decodeObject(forKey: "lastUpdatePerson") as? String
  743. lastUpdateTime = aDecoder.decodeObject(forKey: "lastUpdateTime") as? String
  744. name = aDecoder.decodeObject(forKey: "name") as? String
  745. portalCategory = aDecoder.decodeObject(forKey: "portalCategory") as? String
  746. updateTime = aDecoder.decodeObject(forKey: "updateTime") as? String
  747. }
  748. required public override init() {}
  749. open override var description: String {
  750. return toJSONString(prettyPrint: true) ?? ""
  751. }
  752. }
  753. /// 样式配置对象
  754. public protocol IO2CustomStyleModel: HandyJSON, CustomStringConvertible {
  755. var images : [O2CustomImageModel]? { get set }
  756. var indexPortal : String? { get set }
  757. var indexType : String? { get set }
  758. var nativeAppList : [O2CustomNativeAppModel]? { get set }
  759. var portalList : [O2CustomPortalAppModel]? { get set }
  760. var simpleMode: Bool? { get set } /// 简易模式
  761. }
  762. open class O2CustomStyleModel: NSObject, DataModel, NSCoding, IO2CustomStyleModel {
  763. @objc open var images : [O2CustomImageModel]?
  764. @objc open var indexPortal : String?
  765. @objc open var indexType : String?
  766. @objc open var contactPermissionView: String? = O2.CUSTOM_STYLE_CONTACT_PERMISSION_DEFAULT
  767. @objc open var nativeAppList : [O2CustomNativeAppModel]?
  768. @objc open var portalList : [O2CustomPortalAppModel]?
  769. open var simpleMode: Bool?
  770. @objc public func encode(with aCoder: NSCoder) {
  771. if images != nil {
  772. aCoder.encode(images, forKey: "images")
  773. }
  774. if indexPortal != nil {
  775. aCoder.encode(indexPortal, forKey: "indexPortal")
  776. }
  777. if indexType != nil {
  778. aCoder.encode(indexType, forKey: "indexType")
  779. }
  780. if contactPermissionView != nil {
  781. aCoder.encode(contactPermissionView, forKey: "contactPermissionView")
  782. }
  783. if nativeAppList != nil {
  784. aCoder.encode(nativeAppList, forKey: "nativeAppList")
  785. }
  786. if portalList != nil {
  787. aCoder.encode(portalList, forKey: "portalList")
  788. }
  789. if simpleMode != nil {
  790. aCoder.encode(simpleMode, forKey: "simpleMode")
  791. }
  792. }
  793. @objc public required init?(coder aDecoder: NSCoder) {
  794. images = aDecoder.decodeObject(forKey: "images") as? [O2CustomImageModel]
  795. indexPortal = aDecoder.decodeObject(forKey: "indexPortal") as? String
  796. indexType = aDecoder.decodeObject(forKey: "indexType") as? String
  797. contactPermissionView = aDecoder.decodeObject(forKey: "contactPermissionView") as? String
  798. nativeAppList = aDecoder.decodeObject(forKey: "nativeAppList") as? [O2CustomNativeAppModel]
  799. portalList = aDecoder.decodeObject(forKey: "portalList") as? [O2CustomPortalAppModel]
  800. simpleMode = aDecoder.decodeObject(forKey: "simpleMode") as? Bool
  801. }
  802. required public override init() {}
  803. open override var description: String {
  804. return toJSONString(prettyPrint: true) ?? ""
  805. }
  806. }
  807. /// 移动端应用对象, 服务器提供移动端 可以展现的应用列表
  808. public protocol IO2AppModel: HandyJSON, CustomStringConvertible {
  809. var id : String? { get set } // native应用里面的key portal应用里面的id
  810. var name: String? { get set }
  811. var portalUrl: String? { get set } // portal应用的访问地址
  812. var portalCategory : String? { get set } //
  813. var type: String? { get set } //分类 native portal
  814. var enable : Bool? { get set } // 是否启用
  815. }
  816. open class O2AppModel: NSObject, DataModel, NSCoding, IO2AppModel {
  817. @objc open var id: String?
  818. @objc open var name: String?
  819. @objc open var portalUrl: String?
  820. @objc open var portalCategory: String?
  821. @objc open var type: String?
  822. open var enable: Bool?
  823. required public override init() {}
  824. open override var description: String {
  825. return toJSONString(prettyPrint: true) ?? ""
  826. }
  827. @objc public func encode(with aCoder: NSCoder) {
  828. if id != nil {
  829. aCoder.encode(id, forKey: "id")
  830. }
  831. if name != nil {
  832. aCoder.encode(name, forKey: "name")
  833. }
  834. if portalUrl != nil {
  835. aCoder.encode(portalUrl, forKey: "portalUrl")
  836. }
  837. if portalCategory != nil {
  838. aCoder.encode(portalCategory, forKey: "portalCategory")
  839. }
  840. if type != nil {
  841. aCoder.encode(type, forKey: "type")
  842. }
  843. if enable != nil {
  844. aCoder.encode(enable, forKey: "enable")
  845. }
  846. }
  847. @objc public required init?(coder aDecoder: NSCoder) {
  848. id = aDecoder.decodeObject(forKey: "id") as? String
  849. name = aDecoder.decodeObject(forKey: "name") as? String
  850. portalUrl = aDecoder.decodeObject(forKey: "portalUrl") as? String
  851. portalCategory = aDecoder.decodeObject(forKey: "portalCategory") as? String
  852. type = aDecoder.decodeObject(forKey: "type") as? String
  853. enable = aDecoder.decodeObject(forKey: "enable") as? Bool
  854. }
  855. }