添加注释和日志,添加自采添加物品添加后删除图片
This commit is contained in:
@@ -21,7 +21,6 @@ abstract class BaseRepository {
|
||||
// 对于HTTP异常,尝试从响应体中获取错误信息
|
||||
val errorBody = e.response()?.errorBody()?.string()
|
||||
val errorMsg = if (!errorBody.isNullOrEmpty()) {
|
||||
// 可以尝试解析errorBody为JSON获取更详细的错误信息
|
||||
errorBody
|
||||
} else {
|
||||
"HTTP Error: ${e.code()} - ${e.message()}"
|
||||
|
||||
@@ -15,12 +15,15 @@ import com.sw.inbound.model.response.SupplierResponse
|
||||
import com.sw.inbound.model.response.User
|
||||
import com.sw.inbound.network.api.ApiService
|
||||
import com.sw.inbound.utils.ContextUtils
|
||||
import com.sw.inbound.utils.ImageUtils
|
||||
import com.sw.inbound.utils.FileUtils
|
||||
import okhttp3.MultipartBody
|
||||
import okhttp3.RequestBody
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
* 远程数据处理
|
||||
*/
|
||||
class RemoteRepository @Inject constructor(
|
||||
private val apiService: ApiService
|
||||
) : BaseRepository() {
|
||||
@@ -86,11 +89,11 @@ class RemoteRepository @Inject constructor(
|
||||
)
|
||||
|
||||
val part =
|
||||
ImageUtils.genRequestPart(context = ContextUtils.getAppContext(), imageUri = uri)
|
||||
FileUtils.genRequestPart(context = ContextUtils.getAppContext(), imageUri = uri)
|
||||
if (part == null) {
|
||||
ApiResponse(code = -1, msg = "解析图片失败", data = "")
|
||||
} else {
|
||||
apiService.uploadImage(codeRequestBody, file = part)
|
||||
apiService.uploadImage(code = codeRequestBody, file = part)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user