refactor(net): 注释掉设备令牌和配置相关功能
- 注释掉 getDeviceToken 方法及其相关逻辑 - 注释掉 getDeviceConfig 方法及其相关逻辑 - 注释掉 getAccessToken 方法及其相关逻辑 - 保留了 UiState 相关的状态流定义 - 维持了其他网络请求方法的正常功能
This commit is contained in:
@@ -30,53 +30,53 @@ class NetViewModel : ViewModel() {
|
||||
private val _updateOverdueStateUiState = MutableStateFlow<UiState>(UiState.Initial)
|
||||
val updateOverdueStateUiState: StateFlow<UiState> = _updateOverdueStateUiState
|
||||
|
||||
fun getDeviceToken(deviceId: String) {
|
||||
viewModelScope.launch {
|
||||
_getDeviceTokenUiState.value = UiState.Loading
|
||||
runCatching {
|
||||
val response = apiService.getDeviceToken(qrcodeId = deviceId)
|
||||
if (response.isSuccess()) {
|
||||
_getDeviceTokenUiState.value = UiState.Success(response)
|
||||
} else {
|
||||
_getDeviceTokenUiState.value = UiState.Error(response.msg ?: "请求失败")
|
||||
}
|
||||
}.onFailure {
|
||||
_getDeviceTokenUiState.value = UiState.Error(it.message ?: "请求异常")
|
||||
}
|
||||
}
|
||||
}
|
||||
// fun getDeviceToken(deviceId: String) {
|
||||
// viewModelScope.launch {
|
||||
// _getDeviceTokenUiState.value = UiState.Loading
|
||||
// runCatching {
|
||||
// val response = apiService.getDeviceToken(qrcodeId = deviceId)
|
||||
// if (response.isSuccess()) {
|
||||
// _getDeviceTokenUiState.value = UiState.Success(response)
|
||||
// } else {
|
||||
// _getDeviceTokenUiState.value = UiState.Error(response.msg ?: "请求失败")
|
||||
// }
|
||||
// }.onFailure {
|
||||
// _getDeviceTokenUiState.value = UiState.Error(it.message ?: "请求异常")
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
fun getDeviceConfig(deviceId: String, deviceToken: String) {
|
||||
viewModelScope.launch {
|
||||
_getDeviceConfigUiState.value = UiState.Loading
|
||||
runCatching {
|
||||
val response = apiService.getDeviceInfo(equipmentCode = deviceId)
|
||||
if (response.isSuccess()) {
|
||||
_getDeviceConfigUiState.value = UiState.Success(response)
|
||||
} else {
|
||||
_getDeviceConfigUiState.value = UiState.Error(response.msg ?: "请求失败")
|
||||
}
|
||||
}.onFailure {
|
||||
_getDeviceConfigUiState.value = UiState.Error(it.message ?: "请求异常")
|
||||
}
|
||||
}
|
||||
}
|
||||
// fun getDeviceConfig(deviceId: String, deviceToken: String) {
|
||||
// viewModelScope.launch {
|
||||
// _getDeviceConfigUiState.value = UiState.Loading
|
||||
// runCatching {
|
||||
// val response = apiService.getDeviceInfo(equipmentCode = deviceId)
|
||||
// if (response.isSuccess()) {
|
||||
// _getDeviceConfigUiState.value = UiState.Success(response)
|
||||
// } else {
|
||||
// _getDeviceConfigUiState.value = UiState.Error(response.msg ?: "请求失败")
|
||||
// }
|
||||
// }.onFailure {
|
||||
// _getDeviceConfigUiState.value = UiState.Error(it.message ?: "请求异常")
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
fun getAccessToken(deviceId: String) {
|
||||
viewModelScope.launch {
|
||||
_getAccessTokenUiState.value = UiState.Loading
|
||||
runCatching {
|
||||
val response = apiService.getAccessToken(qrcodeId = deviceId)
|
||||
if (response.isSuccess()) {
|
||||
_getAccessTokenUiState.value = UiState.Success(response)
|
||||
} else {
|
||||
_getAccessTokenUiState.value = UiState.Error(response.msg ?: "请求失败")
|
||||
}
|
||||
}.onFailure {
|
||||
_getAccessTokenUiState.value = UiState.Error(it.message ?: "请求异常")
|
||||
}
|
||||
}
|
||||
}
|
||||
// fun getAccessToken(deviceId: String) {
|
||||
// viewModelScope.launch {
|
||||
// _getAccessTokenUiState.value = UiState.Loading
|
||||
// runCatching {
|
||||
// val response = apiService.getAccessToken(qrcodeId = deviceId)
|
||||
// if (response.isSuccess()) {
|
||||
// _getAccessTokenUiState.value = UiState.Success(response)
|
||||
// } else {
|
||||
// _getAccessTokenUiState.value = UiState.Error(response.msg ?: "请求失败")
|
||||
// }
|
||||
// }.onFailure {
|
||||
// _getAccessTokenUiState.value = UiState.Error(it.message ?: "请求异常")
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
fun getShelfList(deviceId: String) {
|
||||
viewModelScope.launch {
|
||||
|
||||
Reference in New Issue
Block a user