|
@@ -189,10 +189,10 @@ extension PrimitiveSequence where TraitType == SingleTrait, ElementType == Respo
|
|
|
if response.statusCode == 200 {
|
|
|
NXLLog("\nurl=\(String(describing: response.request!.url!))\nstatusCode=\(response.statusCode)\njson=\n\(json.description)");
|
|
|
|
|
|
- let baseModel = BaseModel.fromDictionary(dictionary: json.dictionary ?? Dictionary())
|
|
|
+ let baseModel = BaseModel.init(json: json)
|
|
|
if baseModel.code == 0 {
|
|
|
-// let object = try JSON(data: baseModel.data).object
|
|
|
- return Single<Any?>.just(nil)
|
|
|
+ let object = baseModel.data
|
|
|
+ return Single<Any?>.just(object)
|
|
|
}else if baseModel.code == 1 {
|
|
|
SwiftProgressHUD.shared().showText(baseModel.msg ?? "信息有误!!!")
|
|
|
return Single<Any?>.just(nil)
|
|
@@ -231,10 +231,10 @@ extension PrimitiveSequence where TraitType == SingleTrait, ElementType == Respo
|
|
|
if response.statusCode == 200 {
|
|
|
NXLLog("\nurl=\(String(describing: response.request!.url!))\nstatusCode=\(response.statusCode)\njson=\n\(json.description)");
|
|
|
|
|
|
- let baseModel = BaseModel.fromDictionary(dictionary: json.dictionary ?? Dictionary())
|
|
|
+ let baseModel = BaseModel.init(json: json)
|
|
|
if baseModel.code == 0 {
|
|
|
-// let object =
|
|
|
- return Single<T?>.just(nil)
|
|
|
+ let object = T(json: JSON(baseModel.data))
|
|
|
+ return Single<T?>.just(object)
|
|
|
}else if baseModel.code == 1 {
|
|
|
SwiftProgressHUD.shared().showText(baseModel.msg ?? "信息有误!!!")
|
|
|
return Single<T?>.just(nil)
|
|
@@ -276,10 +276,10 @@ extension PrimitiveSequence where TraitType == SingleTrait, ElementType == Respo
|
|
|
let url = String(describing: response.request!.url!)
|
|
|
NXLLog("\nurl=\(url)\nstatusCode=\(response.statusCode)\njson=\n\(json.description)")
|
|
|
|
|
|
- let baseModel = BaseModel.fromDictionary(dictionary: json.dictionary ?? Dictionary())
|
|
|
+ let baseModel = BaseModel.init(json: json)
|
|
|
if baseModel.code == 0 {
|
|
|
-// let objects = try JSON(data: baseModel.data).arrayObject as! [T]
|
|
|
- return Single<[T]?>.just(nil)
|
|
|
+ let objects = JSON(baseModel.data).arrayObject as! [T]
|
|
|
+ return Single<[T]?>.just(objects)
|
|
|
}else if baseModel.code == 1 {
|
|
|
SwiftProgressHUD.shared().showText(baseModel.msg ?? "信息有误!!!", textAlignment: .left)
|
|
|
return Single<[T]?>.just(nil)
|