TSGeneralPicModel.swift 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. //
  2. // TSGeneralPicModel.swift
  3. // AIRingtone
  4. //
  5. // Created by 100Years on 2025/3/5.
  6. //
  7. import ObjectMapper
  8. class TSGeneralPicModel: TSBaseModel {
  9. enum ModelType:Int {
  10. case normal
  11. case example
  12. }
  13. enum ActionStatus:String ,Equatable {
  14. case success = "success"//成功
  15. case pending = "pending"//等待
  16. case running = "running"//运行
  17. case failed = "failed"//失败
  18. static func from(_ string: String) -> ActionStatus {
  19. return ActionStatus(rawValue: string) ?? .failed
  20. }
  21. }
  22. var modelType:ModelType = .normal
  23. var id:Int = 0
  24. var actionType:String = ""
  25. var comments:String = ""
  26. var request:TSGeneralPicRequestModel = TSGeneralPicRequestModel()
  27. var response:TSGeneralPicResponseModel = TSGeneralPicResponseModel()
  28. var createdTimestamp:Int = 0
  29. var status:String = ""
  30. var costTime:Int = 0
  31. var percent:Float = 0.0
  32. var actionStatus:ActionStatus = .failed
  33. override func mapping(map: ObjectMapper.Map) {
  34. modelType <- map["modelType"]
  35. id <- map["id"]
  36. actionType <- map["actionType"]
  37. comments <- map["comments"]
  38. request <- (map["request"],JsonStringTransform<TSGeneralPicRequestModel>())
  39. response <- (map["response"],JsonStringTransform<TSGeneralPicResponseModel>())
  40. createdTimestamp <- map["createdTimestamp"]
  41. status <- map["status"]
  42. costTime <- map["costTime"]
  43. percent <- map["percent"]
  44. actionStatus <- map["actionStatus"]
  45. actionStatus = ActionStatus.from(status)
  46. }
  47. }
  48. class TSGeneralPicRequestModel : TSBaseModel {
  49. var prompt:String = ""
  50. var promptSort:String = ""
  51. var width:Int = 0
  52. var height:Int = 0
  53. override func mapping(map: ObjectMapper.Map) {
  54. prompt <- map["prompt"]
  55. promptSort <- map["promptSort"]
  56. width <- map["width"]
  57. height <- map["height"]
  58. }
  59. }
  60. class TSGeneralPicResponseModel : TSBaseModel {
  61. var resultUrl:String = ""
  62. var vip:Bool = false
  63. override func mapping(map: ObjectMapper.Map) {
  64. resultUrl <- map["resultUrl"]
  65. vip <- map["vip"]
  66. }
  67. }