UpgradeDictId.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\Http\Api\DictApi;
  4. use App\Tools\Tools;
  5. use Illuminate\Console\Command;
  6. use Illuminate\Support\Facades\DB;
  7. class UpgradeDictId extends Command
  8. {
  9. /**
  10. * The name and signature of the console command.
  11. *
  12. * @var string
  13. */
  14. protected $signature = 'upgrade:wbw.dict.id';
  15. /**
  16. * The console command description.
  17. *
  18. * @var string
  19. */
  20. protected $description = '修改wbw字典id';
  21. /**
  22. * Create a new command instance.
  23. *
  24. * @return void
  25. */
  26. public function __construct()
  27. {
  28. parent::__construct();
  29. }
  30. /**
  31. * Execute the console command.
  32. *
  33. * @return int
  34. */
  35. public function handle()
  36. {
  37. if (Tools::isStop()) {
  38. return 0;
  39. }
  40. $this->info($this->description);
  41. $user_dict_id = DictApi::getSysDict('community');
  42. if ($user_dict_id) {
  43. $result = DB::select('UPDATE "user_dicts" set "dict_id"=? where "source"=? ', [$user_dict_id, '_USER_WBW_']);
  44. } else {
  45. $this->error('没有找到 community 字典');
  46. }
  47. $user_dict_extract_id = DictApi::getSysDict('community_extract');
  48. if ($user_dict_extract_id) {
  49. $result = DB::select('UPDATE "user_dicts" set "dict_id"=? where "source"=? ', [$user_dict_extract_id, '_SYS_USER_WBW_']);
  50. } else {
  51. $this->error('没有找到 community_extract 字典');
  52. }
  53. $this->info('all done');
  54. return 0;
  55. }
  56. }