refactor(api): 重构人脸数据添加接口参数结构
- 将 addUserFace 接口从表单参数改为请求体参数 - 新增 FeatureBody 数据类封装人脸特征和图片URL - 更新 RemoteRepository 中的人脸数据添加方法实现 - 优化参数传递方式,提高代码可读性 - 移除 @FormUrlEncoded 注解,改用 @Body 注解 - 调整方法参数命名,统一使用 imageUrl 命名规范
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
package com.sw.platecabinet.model.request
|
||||
|
||||
data class FeatureBody(
|
||||
val url:String,
|
||||
val featureChar:String
|
||||
)
|
||||
@@ -2,6 +2,7 @@ package com.sw.platecabinet.network.api
|
||||
|
||||
import com.sw.platecabinet.GlobalData
|
||||
import com.sw.platecabinet.model.DeviceConfigV2
|
||||
import com.sw.platecabinet.model.request.FeatureBody
|
||||
import com.sw.platecabinet.model.response.ApiResponse
|
||||
import com.sw.platecabinet.model.response.UserFaceModel
|
||||
import com.sw.platecabinet.model.response.UserFaceModelV2
|
||||
@@ -46,11 +47,9 @@ interface ApiServiceV2 {
|
||||
* 添加人脸数据
|
||||
*/
|
||||
@POST
|
||||
@FormUrlEncoded
|
||||
suspend fun addUserFace(
|
||||
@Url url: String = "${GlobalData.appBaseUrl}/nutrition/neglect/user/add-by-face",
|
||||
@Field("featureChar") faceData: String,
|
||||
@Field("url") imageUr: String
|
||||
@Body faceData: FeatureBody
|
||||
): ApiResponse<UserFaceModelV2?>
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.sw.platecabinet.repository
|
||||
|
||||
import com.sw.platecabinet.model.DeviceConfigV2
|
||||
import com.sw.platecabinet.model.request.FeatureBody
|
||||
import com.sw.platecabinet.model.response.ApiResponse
|
||||
import com.sw.platecabinet.model.response.UserFaceModel
|
||||
import com.sw.platecabinet.model.response.UserFaceModelV2
|
||||
@@ -25,8 +26,7 @@ class RemoteRepositoryV2 constructor(
|
||||
return safeApiCall {
|
||||
apiService.getUserFaceCache(
|
||||
param = mapOf(
|
||||
"pageNum" to pageNum,
|
||||
"pageSize" to pageSize
|
||||
"pageNum" to pageNum, "pageSize" to pageSize
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -34,16 +34,12 @@ class RemoteRepositoryV2 constructor(
|
||||
|
||||
|
||||
suspend fun getFaceIncrementList(
|
||||
pageNum: Long,
|
||||
pageSize: Long = 100L,
|
||||
timestamp: Long
|
||||
pageNum: Long, pageSize: Long = 100L, timestamp: Long
|
||||
): ApiResponse<List<UserFaceModelV2>?> {
|
||||
return safeApiCall {
|
||||
apiService.getFaceIncrementList(
|
||||
param = mapOf(
|
||||
"pageNum" to pageNum,
|
||||
"pageSize" to pageSize,
|
||||
"timestamp" to timestamp
|
||||
"pageNum" to pageNum, "pageSize" to pageSize, "timestamp" to timestamp
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -53,8 +49,14 @@ class RemoteRepositoryV2 constructor(
|
||||
return safeApiCall { apiService.getDeviceConfig() }
|
||||
}
|
||||
|
||||
suspend fun addUserFace(faceData: String, imageUr: String): ApiResponse<UserFaceModelV2?> {
|
||||
return safeApiCall { apiService.addUserFace(faceData = faceData, imageUr = imageUr) }
|
||||
suspend fun addUserFace(faceData: String, imageUrl: String): ApiResponse<UserFaceModelV2?> {
|
||||
return safeApiCall {
|
||||
apiService.addUserFace(
|
||||
faceData = FeatureBody(
|
||||
url = imageUrl, featureChar = faceData
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun uploadImage(file: File): ApiResponse<String?> {
|
||||
|
||||
Reference in New Issue
Block a user