更新个人主页
This commit is contained in:
18
app/src/main/java/com/aiosman/riderpro/data/DictService.kt
Normal file
18
app/src/main/java/com/aiosman/riderpro/data/DictService.kt
Normal file
@@ -0,0 +1,18 @@
|
||||
package com.aiosman.riderpro.data
|
||||
|
||||
import com.aiosman.riderpro.data.api.ApiClient
|
||||
import com.aiosman.riderpro.data.api.DictItem
|
||||
|
||||
interface DictService {
|
||||
/**
|
||||
* 获取字典项
|
||||
*/
|
||||
suspend fun getDictByKey(key: String): DictItem
|
||||
}
|
||||
|
||||
class DictServiceImpl : DictService {
|
||||
override suspend fun getDictByKey(key: String): DictItem {
|
||||
val resp = ApiClient.api.getDict(key)
|
||||
return resp.body()?.data ?: throw Exception("failed to get dict")
|
||||
}
|
||||
}
|
||||
@@ -119,6 +119,15 @@ data class AppConfig(
|
||||
val trtcAppId: Int,
|
||||
)
|
||||
|
||||
data class DictItem(
|
||||
@SerializedName("key")
|
||||
val key: String,
|
||||
@SerializedName("value")
|
||||
val value: String,
|
||||
@SerializedName("desc")
|
||||
val desc: String,
|
||||
)
|
||||
|
||||
interface RiderProAPI {
|
||||
@POST("register")
|
||||
suspend fun register(@Body body: RegisterRequestBody): Response<Unit>
|
||||
@@ -322,4 +331,9 @@ interface RiderProAPI {
|
||||
|
||||
@GET("app/info")
|
||||
suspend fun getAppConfig(): Response<DataContainer<AppConfig>>
|
||||
|
||||
@GET("dict")
|
||||
suspend fun getDict(
|
||||
@Query("key") key: String
|
||||
): Response<DataContainer<DictItem>>
|
||||
}
|
||||
Reference in New Issue
Block a user