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:
dongliang
2026-04-27 17:04:39 +09:30
parent 5d34120153
commit df2e36da91
2 changed files with 4 additions and 4 deletions

View File

@@ -15,7 +15,7 @@ interface CommonApi {
/** 绑定确认 */
@POST("watch/bindWatchConfirm")
suspend fun bindWatchConfirm(@Body params: Map<String, Any>): ApiResponse<Any>
suspend fun bindWatchConfirm(@Body params: HashMap<String, Any>): ApiResponse<Any>
/** 根据 IMEI 查询手表绑定信息(返回用户数据则已绑定,否则未绑定) */
@GET("watch/getWatchByImei")
@@ -27,9 +27,9 @@ interface CommonApi {
/** 上报设备状态电量、蓝牙、NFC等 */
@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")
suspend fun reportLog(@Body params: Map<String, Any>): ApiResponse<Any>
suspend fun reportLog(@Body params: HashMap<String, Any>): ApiResponse<Any>
}

View File

@@ -141,7 +141,7 @@ class BindFragment : BaseFragment<FragmentBindBinding>() {
// 调用 API 确认绑定,然后导航到首页
viewLifecycleOwner.lifecycleScope.launch {
val params = mapOf<String, Any>(
val params = hashMapOf<String, Any>(
"imei" to devicePrefs.imei,
"userId" to bindInfo.userId
)