|
@@ -20,18 +20,11 @@ class JsonResponseBodyConverter<T>(
|
|
) : Converter<ResponseBody, T?> {
|
|
) : Converter<ResponseBody, T?> {
|
|
@Throws(IOException::class)
|
|
@Throws(IOException::class)
|
|
override fun convert(value: ResponseBody): T? {
|
|
override fun convert(value: ResponseBody): T? {
|
|
- var response = value.string()
|
|
|
|
|
|
+ val response = value.string()
|
|
try {
|
|
try {
|
|
val jsonObject = JSONObject(response)
|
|
val jsonObject = JSONObject(response)
|
|
val status = jsonObject.getBoolean("status")
|
|
val status = jsonObject.getBoolean("status")
|
|
- response = if (!status) {
|
|
|
|
- if (type.toString().contains("List") || type.toString().contains("ArrayList")) {
|
|
|
|
- jsonObject.put("data", JSONArray())
|
|
|
|
- } else {
|
|
|
|
- jsonObject.put("data", JSONObject())
|
|
|
|
- }
|
|
|
|
- jsonObject.toString()
|
|
|
|
- } else {
|
|
|
|
|
|
+ if (!status) {
|
|
throw SwagoException(jsonObject.getInt("code"), jsonObject.getString("msg"))
|
|
throw SwagoException(jsonObject.getInt("code"), jsonObject.getString("msg"))
|
|
}
|
|
}
|
|
|
|
|