fix: Retrofit @Body 参数改为 HashMap 修复泛型擦除问题
Map<String, Any> 在 Kotlin 编译后变为 Map<String, ?>, Retrofit 不支持通配符类型。 改为 HashMap<String, Any> 是具体类,不存在泛型擦除问题。 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -15,7 +15,7 @@ interface CommonApi {
|
|||||||
|
|
||||||
/** 绑定确认 */
|
/** 绑定确认 */
|
||||||
@POST("watch/bindWatchConfirm")
|
@POST("watch/bindWatchConfirm")
|
||||||
suspend fun bindWatchConfirm(@Body params: Map<String, Any>): ApiResponse<Any>
|
suspend fun bindWatchConfirm(@Body params: HashMap<String, Any>): ApiResponse<Any>
|
||||||
|
|
||||||
/** 根据 IMEI 查询手表绑定信息(返回用户数据则已绑定,否则未绑定) */
|
/** 根据 IMEI 查询手表绑定信息(返回用户数据则已绑定,否则未绑定) */
|
||||||
@GET("watch/getWatchByImei")
|
@GET("watch/getWatchByImei")
|
||||||
@@ -27,9 +27,9 @@ interface CommonApi {
|
|||||||
|
|
||||||
/** 上报设备状态(电量、蓝牙、NFC等) */
|
/** 上报设备状态(电量、蓝牙、NFC等) */
|
||||||
@POST("watch/setWatchStatusByImeiFormWatch")
|
@POST("watch/setWatchStatusByImeiFormWatch")
|
||||||
suspend fun reportDeviceStatus(@Body params: Map<String, Any>): ApiResponse<Any>
|
suspend fun reportDeviceStatus(@Body params: HashMap<String, Any>): ApiResponse<Any>
|
||||||
|
|
||||||
/** 上报日志 */
|
/** 上报日志 */
|
||||||
@POST("watchTestLog")
|
@POST("watchTestLog")
|
||||||
suspend fun reportLog(@Body params: Map<String, Any>): ApiResponse<Any>
|
suspend fun reportLog(@Body params: HashMap<String, Any>): ApiResponse<Any>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ class BindFragment : BaseFragment<FragmentBindBinding>() {
|
|||||||
|
|
||||||
// 调用 API 确认绑定,然后导航到首页
|
// 调用 API 确认绑定,然后导航到首页
|
||||||
viewLifecycleOwner.lifecycleScope.launch {
|
viewLifecycleOwner.lifecycleScope.launch {
|
||||||
val params = mapOf<String, Any>(
|
val params = hashMapOf<String, Any>(
|
||||||
"imei" to devicePrefs.imei,
|
"imei" to devicePrefs.imei,
|
||||||
"userId" to bindInfo.userId
|
"userId" to bindInfo.userId
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user