Files
rider-pro-android-app/app/src/main/java/com/aiosman/ravenow/data/DictService.kt

29 lines
807 B
Kotlin
Raw Normal View History

2024-11-17 20:07:42 +08:00
package com.aiosman.ravenow.data
2024-09-29 23:17:59 +08:00
2024-11-17 20:07:42 +08:00
import com.aiosman.ravenow.data.api.ApiClient
import com.aiosman.ravenow.data.api.DictItem
2024-09-29 23:17:59 +08:00
2024-10-04 23:37:38 +08:00
2024-09-29 23:17:59 +08:00
interface DictService {
/**
* 获取字典项
*/
suspend fun getDictByKey(key: String): DictItem
2024-12-01 21:27:39 +08:00
/**
* 获取字典列表
*/
suspend fun getDistList(keys: List<String>): List<DictItem>
2024-09-29 23:17:59 +08:00
}
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")
}
2024-12-01 21:27:39 +08:00
override suspend fun getDistList(keys: List<String>): List<DictItem> {
val resp = ApiClient.api.getDicts(keys.joinToString(","))
return resp.body()?.list ?: throw Exception("failed to get dict list")
}
2024-09-29 23:17:59 +08:00
}