|
@@ -421,7 +421,9 @@ extension SwiftMoyaNetWorkManager {
|
|
private func getResponseStatusCode(response:Response, isCustomAlert:Bool , completion: @escaping successCallback) -> Void {
|
|
private func getResponseStatusCode(response:Response, isCustomAlert:Bool , completion: @escaping successCallback) -> Void {
|
|
let json = try? JSON(response.mapJSON())
|
|
let json = try? JSON(response.mapJSON())
|
|
if response.statusCode == 200 {
|
|
if response.statusCode == 200 {
|
|
- NXLLog("\nstatusCode=\(response.statusCode)\njson=\n\(json!.description)");
|
|
|
|
|
|
+ let url = String(describing: response.request!.url!)
|
|
|
|
+ NXLLog("\nurl=\(url)\nstatusCode=\(response.statusCode)\njson=\n\(json!.description)")
|
|
|
|
+
|
|
let json = JSON(parseJSON: json!.description)
|
|
let json = JSON(parseJSON: json!.description)
|
|
let rootModel = RootModel(JSONString: json.description)
|
|
let rootModel = RootModel(JSONString: json.description)
|
|
let data = JSON(json["data"]).description
|
|
let data = JSON(json["data"]).description
|
|
@@ -443,7 +445,8 @@ extension SwiftMoyaNetWorkManager {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}else if response.statusCode == 401 {
|
|
}else if response.statusCode == 401 {
|
|
- NXLLog("\nstatusCode=\(response.statusCode)\njson=\n\(json!.description)");
|
|
|
|
|
|
+ let url = String(describing: response.request!.url!)
|
|
|
|
+ NXLLog("\nurl=\(url)\nstatusCode=\(response.statusCode)\njson=\n\(json!.description)")
|
|
let infoModel = InfoModel(JSONString: json?.description ?? "")
|
|
let infoModel = InfoModel(JSONString: json?.description ?? "")
|
|
kAppDelegate.setLoginController()
|
|
kAppDelegate.setLoginController()
|
|
SwiftProgressHUD.shared().showText(infoModel!.message ?? "登录过期,请重新登录")
|
|
SwiftProgressHUD.shared().showText(infoModel!.message ?? "登录过期,请重新登录")
|
|
@@ -452,8 +455,8 @@ extension SwiftMoyaNetWorkManager {
|
|
falseCallback()
|
|
falseCallback()
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- NXLLog("\nstatusCode=\(response.statusCode)\nerror=\n\(response.description)");
|
|
|
|
- SwiftProgressHUD.shared().showText(response.description)
|
|
|
|
|
|
+ let url = String(describing: response.request!.url!)
|
|
|
|
+ NXLLog("\nurl=\(url)\nstatusCode=\(response.statusCode)\nerror=\n\(response.description)");
|
|
|
|
|
|
if let falseCallback = self.falseCallback {
|
|
if let falseCallback = self.falseCallback {
|
|
falseCallback()
|
|
falseCallback()
|
|
@@ -470,7 +473,8 @@ extension SwiftMoyaNetWorkManager {
|
|
private func getResponseValueStatusCode(response:Response, isCustomAlert:Bool , completion: @escaping successCallback) -> Void {
|
|
private func getResponseValueStatusCode(response:Response, isCustomAlert:Bool , completion: @escaping successCallback) -> Void {
|
|
let json = try? JSON(response.mapJSON())
|
|
let json = try? JSON(response.mapJSON())
|
|
if response.statusCode == 200 {
|
|
if response.statusCode == 200 {
|
|
- NXLLog("\nstatusCode=\(response.statusCode)\njson=\n\(json!.description)");
|
|
|
|
|
|
+ let url = String(describing: response.request!.url!)
|
|
|
|
+ NXLLog("\nurl=\(url)\nstatusCode=\(response.statusCode)\njson=\n\(json!.description)")
|
|
let json = JSON(parseJSON: json!.description)
|
|
let json = JSON(parseJSON: json!.description)
|
|
let rootModel = RootModel(JSONString: json.description)
|
|
let rootModel = RootModel(JSONString: json.description)
|
|
let data = JSON(json["data"]).description
|
|
let data = JSON(json["data"]).description
|
|
@@ -492,7 +496,8 @@ extension SwiftMoyaNetWorkManager {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}else if response.statusCode == 401 {
|
|
}else if response.statusCode == 401 {
|
|
- NXLLog("\nstatusCode=\(response.statusCode)\njson=\n\(json!.description)");
|
|
|
|
|
|
+ let url = String(describing: response.request!.url!)
|
|
|
|
+ NXLLog("\nurl=\(url)\nstatusCode=\(response.statusCode)\njson=\n\(json!.description)")
|
|
let infoModel = InfoModel(JSONString: json?.description ?? "")
|
|
let infoModel = InfoModel(JSONString: json?.description ?? "")
|
|
kAppDelegate.setLoginController()
|
|
kAppDelegate.setLoginController()
|
|
SwiftProgressHUD.shared().showText(infoModel!.message ?? "登录过期,请重新登录")
|
|
SwiftProgressHUD.shared().showText(infoModel!.message ?? "登录过期,请重新登录")
|
|
@@ -501,7 +506,8 @@ extension SwiftMoyaNetWorkManager {
|
|
falseCallback()
|
|
falseCallback()
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- NXLLog("\nstatusCode=\(response.statusCode)\nerror=\n\(response.description)");
|
|
|
|
|
|
+ let url = String(describing: response.request!.url!)
|
|
|
|
+ NXLLog("\nurl=\(url)\nstatusCode=\(response.statusCode)\nerror=\n\(response.description)");
|
|
SwiftProgressHUD.shared().showText(response.description)
|
|
SwiftProgressHUD.shared().showText(response.description)
|
|
|
|
|
|
if let falseCallback = self.falseCallback {
|
|
if let falseCallback = self.falseCallback {
|
|
@@ -519,7 +525,8 @@ extension SwiftMoyaNetWorkManager {
|
|
private func getResponseArrayStatusCode(response:Response, isCustomAlert:Bool , completion: @escaping successCallArrayback) -> Void {
|
|
private func getResponseArrayStatusCode(response:Response, isCustomAlert:Bool , completion: @escaping successCallArrayback) -> Void {
|
|
let json = try? JSON(response.mapJSON())
|
|
let json = try? JSON(response.mapJSON())
|
|
if response.statusCode == 200 {
|
|
if response.statusCode == 200 {
|
|
- NXLLog("\nstatusCode=\(response.statusCode)\njson=\n\(json!.description)");
|
|
|
|
|
|
+ let url = String(describing: response.request!.url!)
|
|
|
|
+ NXLLog("\nurl=\(url)\nstatusCode=\(response.statusCode)\njson=\n\(json!.description)")
|
|
let json = JSON(parseJSON: json!.description)
|
|
let json = JSON(parseJSON: json!.description)
|
|
let rootModel = RootModel(JSONString: json.description)
|
|
let rootModel = RootModel(JSONString: json.description)
|
|
let data = JSON(json["data"]).description
|
|
let data = JSON(json["data"]).description
|
|
@@ -542,7 +549,8 @@ extension SwiftMoyaNetWorkManager {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}else if response.statusCode == 401 {
|
|
}else if response.statusCode == 401 {
|
|
- NXLLog("\nstatusCode=\(response.statusCode)\njson=\n\(json!.description)");
|
|
|
|
|
|
+ let url = String(describing: response.request!.url!)
|
|
|
|
+ NXLLog("\nurl=\(url)\nstatusCode=\(response.statusCode)\njson=\n\(json!.description)")
|
|
let infoModel = InfoModel(JSONString: json?.description ?? "")
|
|
let infoModel = InfoModel(JSONString: json?.description ?? "")
|
|
kAppDelegate.setLoginController()
|
|
kAppDelegate.setLoginController()
|
|
SwiftProgressHUD.shared().showText(infoModel!.message ?? "登录过期,请重新登录")
|
|
SwiftProgressHUD.shared().showText(infoModel!.message ?? "登录过期,请重新登录")
|
|
@@ -551,7 +559,8 @@ extension SwiftMoyaNetWorkManager {
|
|
falseCallback()
|
|
falseCallback()
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- NXLLog("\nstatusCode=\(response.statusCode)\nerror=\n\(response.description)");
|
|
|
|
|
|
+ let url = String(describing: response.request!.url!)
|
|
|
|
+ NXLLog("\nurl=\(url)\nstatusCode=\(response.statusCode)\nerror=\n\(response.description)");
|
|
SwiftProgressHUD.shared().showText(response.description)
|
|
SwiftProgressHUD.shared().showText(response.description)
|
|
|
|
|
|
if let falseCallback = self.falseCallback {
|
|
if let falseCallback = self.falseCallback {
|
|
@@ -570,36 +579,37 @@ extension PrimitiveSequence where TraitType == SingleTrait, ElementType == Respo
|
|
do {
|
|
do {
|
|
let json = try JSON(response.mapJSON())
|
|
let json = try JSON(response.mapJSON())
|
|
if response.statusCode == 200 {
|
|
if response.statusCode == 200 {
|
|
- NXLLog("\nstatusCode=\(response.statusCode)\njson=\n\(json.description)");
|
|
|
|
|
|
+ NXLLog("\nurl=\(String(describing: response.request!.url!))\nstatusCode=\(response.statusCode)\njson=\n\(json.description)");
|
|
|
|
|
|
let json = JSON(parseJSON: json.description)
|
|
let json = JSON(parseJSON: json.description)
|
|
let rootModel = RootModel(JSONString: json.description)
|
|
let rootModel = RootModel(JSONString: json.description)
|
|
let data = JSON(json["data"]).description
|
|
let data = JSON(json["data"]).description
|
|
rootModel?.data = data
|
|
rootModel?.data = data
|
|
if rootModel!.code == 0 {
|
|
if rootModel!.code == 0 {
|
|
|
|
+
|
|
let mapper = T(JSONString: rootModel!.data ?? "")
|
|
let mapper = T(JSONString: rootModel!.data ?? "")
|
|
return Single<T?>.just(mapper)
|
|
return Single<T?>.just(mapper)
|
|
}else if rootModel!.code == 1 {
|
|
}else if rootModel!.code == 1 {
|
|
- SwiftProgressHUD.shared().showText(rootModel!.msg ?? "信息有误!!!", textAlignment: .left)
|
|
|
|
return Single<T?>.just(nil)
|
|
return Single<T?>.just(nil)
|
|
}else {
|
|
}else {
|
|
- NXLLog("\nstatusCode=\(response.statusCode)\nerror=\n\(response.description)");
|
|
|
|
- SwiftProgressHUD.shared().showText(response.description)
|
|
|
|
return Single<T?>.just(nil)
|
|
return Single<T?>.just(nil)
|
|
}
|
|
}
|
|
}else if response.statusCode == 401 {
|
|
}else if response.statusCode == 401 {
|
|
- NXLLog("\nstatusCode=\(response.statusCode)\njson=\n\(json.description)");
|
|
|
|
|
|
+ let url = String(describing: response.request!.url!)
|
|
|
|
+ NXLLog("\nurl=\(url)\nstatusCode=\(response.statusCode)\njson=\n\(json.description)")
|
|
let infoModel = InfoModel(JSONString: json.description)
|
|
let infoModel = InfoModel(JSONString: json.description)
|
|
SwiftProgressHUD.shared().showText(infoModel!.message ?? "登录过期,请重新登录")
|
|
SwiftProgressHUD.shared().showText(infoModel!.message ?? "登录过期,请重新登录")
|
|
kAppDelegate.setLoginController()
|
|
kAppDelegate.setLoginController()
|
|
return Single<T?>.just(nil)
|
|
return Single<T?>.just(nil)
|
|
- }else { NXLLog("\nstatusCode=\(response.statusCode)\nerror=\n\(response.description)");
|
|
|
|
- SwiftProgressHUD.shared().showText(response.description)
|
|
|
|
|
|
+ }else {
|
|
|
|
+ let url = String(describing: response.request!.url!)
|
|
|
|
+ NXLLog("\nurl=\(url)\nstatusCode=\(response.statusCode)\nerror=\n\(response.description)");
|
|
return Single<T?>.just(nil)
|
|
return Single<T?>.just(nil)
|
|
}
|
|
}
|
|
|
|
|
|
} catch {
|
|
} catch {
|
|
- NXLLog("\nstatusCode=\(response.statusCode)\nerror=\n\(response.description)");
|
|
|
|
|
|
+ let url = String(describing: response.request!.url!)
|
|
|
|
+ NXLLog("\nurl=\(url)\nstatusCode=\(response.statusCode)\nerror=\n\(response.description)")
|
|
SwiftProgressHUD.shared().showText(response.description)
|
|
SwiftProgressHUD.shared().showText(response.description)
|
|
return Single<T?>.just(nil)
|
|
return Single<T?>.just(nil)
|
|
}
|
|
}
|
|
@@ -612,36 +622,40 @@ extension PrimitiveSequence where TraitType == SingleTrait, ElementType == Respo
|
|
do {
|
|
do {
|
|
let json = try JSON(response.mapJSON())
|
|
let json = try JSON(response.mapJSON())
|
|
if response.statusCode == 200 {
|
|
if response.statusCode == 200 {
|
|
- NXLLog("\nstatusCode=\(response.statusCode)\njson=\n\(json.description)");
|
|
|
|
|
|
|
|
|
|
+ let url = String(describing: response.request!.url!)
|
|
|
|
+ NXLLog("\nurl=\(url)\nstatusCode=\(response.statusCode)\njson=\n\(json.description)")
|
|
|
|
+
|
|
let json = JSON(parseJSON: json.description)
|
|
let json = JSON(parseJSON: json.description)
|
|
let rootModel = RootModel(JSONString: json.description)
|
|
let rootModel = RootModel(JSONString: json.description)
|
|
let data = JSON(json["data"]).description
|
|
let data = JSON(json["data"]).description
|
|
rootModel?.data = data
|
|
rootModel?.data = data
|
|
if rootModel!.code == 0 {
|
|
if rootModel!.code == 0 {
|
|
|
|
+
|
|
let mapper = Mapper<T>().mapArray(JSONString: rootModel!.data!)
|
|
let mapper = Mapper<T>().mapArray(JSONString: rootModel!.data!)
|
|
return Single<[T]?>.just(mapper)
|
|
return Single<[T]?>.just(mapper)
|
|
}else if rootModel!.code == 1 {
|
|
}else if rootModel!.code == 1 {
|
|
SwiftProgressHUD.shared().showText(rootModel!.msg ?? "信息有误!!!", textAlignment: .left)
|
|
SwiftProgressHUD.shared().showText(rootModel!.msg ?? "信息有误!!!", textAlignment: .left)
|
|
return Single<[T]?>.just(nil)
|
|
return Single<[T]?>.just(nil)
|
|
- }else {
|
|
|
|
- NXLLog("\nstatusCode=\(response.statusCode)\nerror=\n\(response.description)");
|
|
|
|
- SwiftProgressHUD.shared().showText(response.description)
|
|
|
|
|
|
+ }else { SwiftProgressHUD.shared().showText(response.description)
|
|
return Single<[T]?>.just(nil)
|
|
return Single<[T]?>.just(nil)
|
|
}
|
|
}
|
|
}else if response.statusCode == 401 {
|
|
}else if response.statusCode == 401 {
|
|
- NXLLog("\nstatusCode=\(response.statusCode)\njson=\n\(json.description)");
|
|
|
|
|
|
+ let url = String(describing: response.request!.url!)
|
|
|
|
+ NXLLog("\nurl=\(url)\nstatusCode=\(response.statusCode)\njson=\n\(json.description)")
|
|
let infoModel = InfoModel(JSONString: json.description)
|
|
let infoModel = InfoModel(JSONString: json.description)
|
|
SwiftProgressHUD.shared().showText(infoModel!.message ?? "登录过期,请重新登录")
|
|
SwiftProgressHUD.shared().showText(infoModel!.message ?? "登录过期,请重新登录")
|
|
kAppDelegate.setLoginController()
|
|
kAppDelegate.setLoginController()
|
|
return Single<[T]?>.just(nil)
|
|
return Single<[T]?>.just(nil)
|
|
- }else { NXLLog("\nstatusCode=\(response.statusCode)\nerror=\n\(response.description)");
|
|
|
|
- SwiftProgressHUD.shared().showText(response.description)
|
|
|
|
|
|
+ }else {
|
|
|
|
+ let url = String(describing: response.request!.url!)
|
|
|
|
+ NXLLog("\nurl=\(url)\nstatusCode=\(response.statusCode)\nerror=\n\(response.description)");
|
|
return Single<[T]?>.just(nil)
|
|
return Single<[T]?>.just(nil)
|
|
}
|
|
}
|
|
|
|
|
|
} catch {
|
|
} catch {
|
|
- NXLLog("\nstatusCode=\(response.statusCode)\nerror=\n\(response.description)");
|
|
|
|
|
|
+ let url = String(describing: response.request!.url!)
|
|
|
|
+ NXLLog("\nurl=\(url)\nstatusCode=\(response.statusCode)\nerror=\n\(response.description)")
|
|
SwiftProgressHUD.shared().showText(response.description)
|
|
SwiftProgressHUD.shared().showText(response.description)
|
|
return Single<[T]?>.just(nil)
|
|
return Single<[T]?>.just(nil)
|
|
}
|
|
}
|