feat: 增加网络请求模块

This commit is contained in:
xiaoyan 2023-01-03 17:03:36 +08:00
parent cf712a6b86
commit c95096d4fd
3 changed files with 49 additions and 0 deletions

View File

@ -100,4 +100,7 @@ dependencies {
}
// https://github.com/nhaarman/supertooltips
implementation 'com.nhaarman.supertooltips:library:3.0.0'
// https://square.github.io/retrofit/
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
}

View File

@ -0,0 +1,23 @@
package com.navinfo.volvo.http
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
class NavinfoVolvoCall {
private val retrofit by lazy {
Retrofit.Builder().baseUrl("http://ec2-52-81-73-5.cn-north-1.compute.amazonaws.com.cn:8088/")
.addConverterFactory(GsonConverterFactory.create())
.build()
}
companion object {
private var instance: NavinfoVolvoCall? = null
get() {
if (field == null) {
field = NavinfoVolvoCall()
}
return field
}
}
}

View File

@ -0,0 +1,23 @@
package com.navinfo.volvo.http
import retrofit2.http.Body
import retrofit2.http.Multipart
import retrofit2.http.POST
import retrofit2.http.Part
import java.io.File
interface NavinfoVolvoService {
@POST("/navi/cardDelivery/insertCardByApp")
fun insertCardByApp(@Body insertData: MutableMap<String, String>)
@POST("/navi/cardDelivery/updateCardByApp")
fun updateCardByApp(@Body updateData: MutableMap<String, String>)
@POST("/navi/cardDelivery/queryCardListByApp")
fun queryCardListByApp(@Body queryData: MutableMap<String, String>)
@POST("/navi/cardDelivery/deleteCardByApp")
fun deleteCardByApp(@Body deleteData: MutableMap<String, String>)
@POST("/img/upload")
@Multipart
fun uploadAttachment(@Part("picture") attachmentFile: File)
@POST("/img/download")
fun downLoadAttachment(@Body downloadData: MutableMap<String, String>)
}