fix(inbound): 修复API响应码类型不匹配问题
- 将InboundApiResponse中的code字段从Int类型改为String?类型 - 更新isSuccess方法判断逻辑,由code == 200改为code == "00000" - 修改错误处理中返回的响应码格式,统一使用字符串"-1"
This commit is contained in:
@@ -7,9 +7,9 @@ import com.google.gson.annotations.SerializedName
|
||||
* 与旧 ApiResponse 区别:code 为 Int,200 表示成功
|
||||
*/
|
||||
data class InboundApiResponse<T>(
|
||||
@SerializedName("code") val code: Int = -1,
|
||||
@SerializedName("code") val code: String? = null,
|
||||
@SerializedName("msg") val msg: String? = null,
|
||||
@SerializedName("data") val data: T? = null
|
||||
) {
|
||||
fun isSuccess(): Boolean = code == 200
|
||||
fun isSuccess(): Boolean = code == "00000"
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ class InboundRepository @Inject constructor(
|
||||
is IOException -> "网络IO错误: ${e.message}"
|
||||
else -> "未知错误: ${e.message}"
|
||||
}
|
||||
InboundApiResponse(code = -1, msg = msg)
|
||||
InboundApiResponse(code = "-1", msg = msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user