This commit is contained in:
2025-08-14 14:26:24 +08:00
parent 3b4ba599bf
commit d609bde82e
13 changed files with 1380 additions and 590 deletions
@@ -42,16 +42,16 @@ class AppViewModel(private val rep: AppRepository) : ViewModel() {
}
}
fun saveCookFood(cookMode: Int, entity: CookFoodEntity) {
viewModelScope.launch {
val data = rep.getCookFoodById(entity.foodId, cookMode)
if (data == null) {
rep.insertCookFood(entity)
return@launch
}
rep.updateCookFood(entity)
}
}
// fun saveCookFood(cookMode: Int, entity: CookFoodEntity) {
// viewModelScope.launch {
// val data = rep.getCookFoodById(entity.foodId, cookMode)
// if (data == null) {
// rep.insertCookFood(entity)
// return@launch
// }
// rep.updateCookFood(entity)
// }
// }
fun saveCookFoodAndGoods(
cookMode: Int,
@@ -68,7 +68,12 @@ class AppViewModel(private val rep: AppRepository) : ViewModel() {
}
//重新保存数据
rep.insertCookFood(entity)
list?.let { rep.insertGoodsList(it) }
list?.let { it ->
it.forEach { goods->
goods.id = 0
}
rep.insertGoodsList(it)
}
onFinish()
}
}