|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Aside\Devops;
|
|
|
|
|
|
|
|
use App\Http\Controllers\Bside\BaseController;
|
|
|
|
|
|
|
|
use App\Http\Logic\Aside\Devops\ServerConfigLogic;
|
|
|
|
use App\Http\Requests\Aside\Devops\ServerConfigRequest;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use Illuminate\Support\Str;
|
|
|
|
use Illuminate\Validation\Rule;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 项目服务器、数据库配置
|
|
|
|
* Class ServerConfigController
|
|
|
|
* @package App\Http\Controllers\Aside
|
|
|
|
* @author zbj
|
|
|
|
* @date 2023/4/24
|
|
|
|
*/
|
|
|
|
class ServerConfigController extends BaseController
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 保存配置
|
|
|
|
* @param ServerConfigRequest $request
|
|
|
|
* @param ServerConfigLogic $logic
|
|
|
|
* @author zbj
|
|
|
|
* @date 2023/4/23
|
|
|
|
*/
|
|
|
|
public function save(ServerConfigRequest $request, ServerConfigLogic $logic){
|
|
|
|
$data = $logic->save($this->param);
|
|
|
|
return $this->success($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 更新表结构
|
|
|
|
* @param ServerConfigLogic $logic
|
|
|
|
* @author zbj
|
|
|
|
* @date 2023/4/24
|
|
|
|
*/
|
|
|
|
public function updateDatabase(Request $request, ServerConfigLogic $logic){
|
|
|
|
$request->validate([
|
|
|
|
'type' => 'in:1,2,3',
|
|
|
|
'id'=> Rule::requiredIf($request->type == 1),
|
|
|
|
'sql' => ['required', function ($attribute, $value, $fail) {
|
|
|
|
if(Str::contains(Str::lower($value), ['drop', 'delete', 'truncate'])){
|
|
|
|
$fail('危险操作');
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
],[
|
|
|
|
'id.required' => 'ID不能为空',
|
|
|
|
'sql.required' => '请输入Sql语句',
|
|
|
|
]);
|
|
|
|
|
|
|
|
switch ($this->param['type']){
|
|
|
|
case "1":
|
|
|
|
$data = $logic->updateTable($this->param);
|
|
|
|
break;
|
|
|
|
case "2":
|
|
|
|
$data = $logic->updateLocalTable($this->param);
|
|
|
|
break;
|
|
|
|
case "3":
|
|
|
|
$data = $logic->updateAllTable($this->param);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->success($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 更新代码
|
|
|
|
* @param ServerConfigLogic $logic
|
|
|
|
* @author zbj
|
|
|
|
* @date 2023/4/24
|
|
|
|
*/
|
|
|
|
public function updateCode(){
|
|
|
|
//todo
|
|
|
|
//C端
|
|
|
|
// $process = new Process(['git', 'pull']);
|
|
|
|
// $process->run();
|
|
|
|
// dump($process->getExitCodeText());
|
|
|
|
// dump($process->getExitCode());
|
|
|
|
// dump($process->getErrorOutput());
|
|
|
|
// $output = explode(PHP_EOL, $process->getOutput());
|
|
|
|
// dump($output);
|
|
|
|
// exit;
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|