添加了注释,完善了参数校验及空值处理
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package com.sw.inbound.viewmodel
|
||||
|
||||
import com.sw.inbound.model.response.SupplierInfo
|
||||
import com.sw.inbound.repository.RemoteRepository
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
* 采购订单
|
||||
*/
|
||||
@HiltViewModel
|
||||
class PurchaseOrderViewModel @Inject constructor(
|
||||
private val repository: RemoteRepository
|
||||
) : BaseViewModel(repository) {
|
||||
|
||||
/**
|
||||
* 采购订单-供应商列表
|
||||
*/
|
||||
private val _supplierList = MutableStateFlow<List<SupplierInfo?>>(emptyList())
|
||||
val supplierList: StateFlow<List<SupplierInfo?>> = _supplierList
|
||||
|
||||
|
||||
fun getOrderList(pageNum: Int = 0, pageSize: Int = 20) {
|
||||
launchWithLoading {
|
||||
val response = repository.getReceiveList(pageNum, pageSize)
|
||||
if (response.isSuccess()) {
|
||||
response.data?.records?.let {
|
||||
_supplierList.value = it
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user