UpgradeDictId.php 1.4 KB

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