Browse Source

运行提示问题

wbspool 1 year ago
parent
commit
abd001396d

+ 14 - 0
BusinessStep/src/main/java/com/develop/step/viewmodel/CookDetailViewModel.kt

@@ -15,6 +15,7 @@ import com.develop.base.util.MMkvUtils
 import com.develop.base.util.ThreadUtils
 import com.develop.common.data_repo.FoodDataProvider
 import com.develop.common.data_repo.db.entity.DevAccessory
+import com.develop.common.data_repo.db.entity.DevRecipeCategory
 import com.develop.common.data_repo.db.entity.DevRecipePortionSize
 import com.develop.common.data_repo.db.entity.UserOnLineRecipes
 import com.develop.common.data_repo.net.Api
@@ -205,6 +206,19 @@ class CookDetailViewModel : BaseViewModel() {
 //            contentData.resetAllCodes()
             FoodDataProvider.getDatabase().runInTransaction {
                 FoodDataProvider.getDatabase().recipeDao().apply {
+
+                    val categorys = queryAllCategory()
+                    val categoryMap = HashMap<String, DevRecipeCategory>()
+                    for (category in categorys) {
+                        categoryMap[category.number + ":" + category.lang] = category
+                    }
+                    for (devRecipeCategory in contentData.devRecipeCategorys) {
+                        if (categoryMap.containsKey(devRecipeCategory.number + ":" + devRecipeCategory.lang)) {
+                            devRecipeCategory.code =
+                                categoryMap[devRecipeCategory.number + ":" + devRecipeCategory.lang]?.code.toString()
+                        }
+                    }
+
                     insertDevAccessorys(contentData.devAccessorys)
                     insertHotTags(contentData.devHotTags)
                     insertDevPortraits(contentData.devPortraits)