Browse Source

:bug: 单个单词变形删除旧数据会把其他词都删掉

visuddhinanda 3 năm trước cách đây
mục cha
commit
fb1eeabaa9
1 tập tin đã thay đổi với 9 bổ sung5 xóa
  1. 9 5
      app/Console/Commands/UpgradeRegular.php

+ 9 - 5
app/Console/Commands/UpgradeRegular.php

@@ -172,7 +172,7 @@ class UpgradeRegular extends Command
 				if($isMatch){
 					if($this->option('debug'))  $this->error($newword.':match');
 					//查询这个词是否在三藏存在
-					$exist = Cache::remember('palicanon/word/exists/'.$newword, 10 , function() use($newword) {
+					$exist = Cache::remember('palicanon/word/exists/'.$newword, 100 , function() use($newword) {
 						return WbwTemplate::where('real',$newword)->exists();
 					});
 					if($exist){
@@ -184,7 +184,7 @@ class UpgradeRegular extends Command
 								'grammar' => $newGrammar,
 								'parent' => $word->word,
 								'factors' => "{$word->word}+[{$newEnding}]",
-								'dict_id' => $this->dict_id,
+								'dict_id' => $this->dict_id, 
 							],
 							[
 								'id' => app('snowflake')->id(),
@@ -205,9 +205,13 @@ class UpgradeRegular extends Command
 			$bar->advance();
 		}
 		$bar->finish();
-				//删除旧数据
-		UserDict::where('dict_id',$this->dict_id)->where('flag',0)->delete();
-		UserDict::where('dict_id',$this->dict_id)->where('flag',1)->update(['flag'=>0]);
+		//删除旧数据
+		$delOld = UserDict::where('dict_id',$this->dict_id);
+		if(!empty($this->argument('word'))){
+			$delOld = $delOld->where('word',$this->argument('word'));
+		}
+		$delOld->where('flag',0)->delete();
+		$delOld->where('flag',1)->update(['flag'=>0]);
         return 0;
     }
 }