TSGeneralPicModel.swift 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. //
  2. // TSActionInfoModel.swift
  3. // AIRingtone
  4. //
  5. // Created by 100Years on 2025/3/5.
  6. //
  7. import ObjectMapper
  8. class TSActionInfoModel: 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:TSActionInfoRequestModel = TSActionInfoRequestModel()
  27. var response:TSActionInfoResponseModel = TSActionInfoResponseModel()
  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<TSActionInfoRequestModel>())
  39. response <- (map["response"],JsonStringTransform<TSActionInfoResponseModel>())
  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 TSActionInfoRequestModel : TSBaseModel {
  49. var prompt:String = ""
  50. var promptSort:String = ""
  51. //生成图用的
  52. var width:Int = 0
  53. var height:Int = 0
  54. //生成音乐用的
  55. var duration:Int = 0
  56. override func mapping(map: ObjectMapper.Map) {
  57. prompt <- map["prompt"]
  58. promptSort <- map["promptSort"]
  59. width <- map["width"]
  60. height <- map["height"]
  61. duration <- map["duration"]
  62. }
  63. }
  64. class TSActionInfoResponseModel : TSBaseModel {
  65. var vip:Bool = false
  66. //生成图片
  67. var resultUrl:String = ""
  68. //生成音乐用的
  69. var coverUrl:String = ""
  70. var title:String = ""
  71. var musicUrl:String = ""
  72. override func mapping(map: ObjectMapper.Map) {
  73. resultUrl <- map["resultUrl"]
  74. vip <- map["vip"]
  75. coverUrl <- map["coverUrl"]
  76. title <- map["title"]
  77. musicUrl <- map["musicUrl"]
  78. }
  79. }