增加重置密码命令行功能

This commit is contained in:
augushong
2019-10-17 19:44:59 +08:00
parent 2bf7d7014f
commit e7aa648486
2 changed files with 34 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace app\command;
use app\model\Admin;
use think\console\Command;
use think\console\Input;
use think\console\input\Argument;
use think\console\input\Option;
use think\console\Output;
use think\helper\Str;
class ResetPassword extends Command
{
protected function configure()
{
// 指令配置
$this->setName('reset_password')
->setDescription('the reset_password command');
}
protected function execute(Input $input, Output $output)
{
// 指令输出
$account['salt'] = Str::random(6);
$account['password'] = md5('123456'.$account['salt']);
Admin::update($account,1);
$output->writeln('重置密码成功');
}
}