添加了注释,完善了参数校验及空值处理

This commit is contained in:
zxj
2025-07-09 15:29:52 +08:00
parent de80a26c2c
commit 6cf7b4fb9b
42 changed files with 584 additions and 334 deletions
@@ -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
}
}
}
}
}