resetPassword.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. declare (strict_types=1);
  3. namespace app\command;
  4. use app\common\repositories\system\admin\AdminRepository;
  5. use think\console\Command;
  6. use think\console\Input;
  7. use think\console\input\Argument;
  8. use think\console\Output;
  9. use think\console\input\Option;
  10. class resetPassword extends Command
  11. {
  12. protected function configure()
  13. {
  14. // 指令配置
  15. $this->setName('reset:password')
  16. ->addArgument('root', Argument::OPTIONAL, 'root : admin')
  17. ->addOption('pwd', null, Option::VALUE_REQUIRED, 'pwd : 123456')
  18. ->setDescription('the update resetPwd command');
  19. }
  20. /**
  21. * @Author:Qinii
  22. * @Date: 2020/5/15
  23. * @param Input $input
  24. * @param Output $output
  25. * @return int|void|null
  26. */
  27. protected function execute(Input $input, Output $output)
  28. {
  29. $account = $input->getArgument('root');
  30. if ($input->hasOption('pwd')){
  31. $pwd = $input->getOption('pwd');
  32. }
  33. $this->resetPwd($account,$pwd);
  34. }
  35. public function resetPwd($account,$pwd)
  36. {
  37. app()->make(AdminRepository::class)->resetPwd($account,$pwd);
  38. }
  39. }