2024-09-29 23:17:59 +08:00
|
|
|
package com.aiosman.riderpro.data
|
|
|
|
|
|
|
|
|
|
import com.aiosman.riderpro.data.api.ApiClient
|
|
|
|
|
import com.aiosman.riderpro.data.api.DictItem
|
|
|
|
|
|
2024-10-04 23:37:38 +08:00
|
|
|
|
2024-09-29 23:17:59 +08:00
|
|
|
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")
|
|
|
|
|
}
|
|
|
|
|
}
|