替换菜品识别模型,暂时取消相似的判断,查询全部数据测试新模型效果,暂时取消查询前后数据量不一致的判断避免查不出数据
This commit is contained in:
@@ -140,6 +140,7 @@ object ObjectBox {
|
||||
dbMutex.withLock { operation() }
|
||||
} catch (e: FileCorruptException) {
|
||||
// 操作中触发损坏,尝试重建数据库
|
||||
e.printStackTrace()
|
||||
//val context = boxStore.context
|
||||
//deleteDbFiles(context)
|
||||
init(MyApp.instance!!)
|
||||
@@ -173,19 +174,20 @@ object ObjectBox {
|
||||
}
|
||||
|
||||
suspend fun putAll(entities: List<Food>) = safeDbOp {
|
||||
getBox<Food>()?.put(entities)
|
||||
val box = getBox<Food>()
|
||||
box?.put(entities)
|
||||
}
|
||||
|
||||
suspend fun filter(name:String?) = safeDbOp {
|
||||
suspend fun filter(name: String?) = safeDbOp {
|
||||
val list = getBox<Food>()?.all?.distinctBy { it.name }
|
||||
if (name.isNullOrBlank().not()) {
|
||||
list?.filter { it.name?.contains(name) == true }
|
||||
} else {
|
||||
list
|
||||
}?:emptyList()
|
||||
} ?: emptyList()
|
||||
}
|
||||
|
||||
suspend fun remove(name:String) = safeDbOp {
|
||||
suspend fun remove(name: String) = safeDbOp {
|
||||
getBox<Food>()?.run {
|
||||
val filterIdList = all.filter { it.name == name }.map { it.id }
|
||||
removeByIds(filterIdList)
|
||||
|
||||
Reference in New Issue
Block a user