1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Elton
- * Date: 2020/2/29
- * Time: 20:20
- */
- namespace app\admin\command;
- use app\common\library\Redis;
- use app\common\model\Config as ConfigModel;
- use think\console\Command;
- use think\console\Input;
- use think\console\Output;
- use think\Request;
- class UpdateConfigTab extends Command
- {
- /**
- * 配置指令
- */
- protected function configure()
- {
- $this->setName('UpdateConfigTab')
- ->setDescription('CPS测试功能配置,如果系统配置中没有CPS测试功能配置则添加一个Tab');
- }
- /**
- * 执行指令
- * @param Input $input
- * @param Output $output
- * @return null|int
- * @throws \LogicException
- * @see setCode()
- */
- protected function execute(Input $input, Output $output)
- {
- //cli模式下无法获取到当前的项目模块,手动指定一下
- Request::instance()->module('admin');
- $model = new ConfigModel();
- $obj = $model->where('name', 'eq', 'configgroup')->find();
- if(!in_array('cpstest', json_decode($obj->value, true))){
- $config_arr = json_decode($obj->value, true);
- $config_arr['cpstest'] = 'CPS测试功能配置';
- $rst = $model->update(['value'=>json_encode($config_arr)], ['name'=>'configgroup']);
- // is_open_share share_channels share_domain share_content share_book_id share_chapter_num
- Redis::instance()->del('site');
- $output->writeln('Test'.json_encode($rst));
- }
- }
- }
|