作者 lyh

gx

... ... @@ -10,6 +10,7 @@ use App\Models\Devops\DevopsTask;
use App\Models\Project\Project;
use App\Models\Devops\ServerConfig;
use App\Services\ProjectServer;
use App\Utils\EncryptUtils;
use Illuminate\Support\Facades\DB;
/**
... ... @@ -47,7 +48,11 @@ class ServerConfigLogic extends BaseLogic
* @time :2023/8/2 17:53
*/
public function getServiceConfig(){
$encrypt = new EncryptUtils();
$info = $this->model->read(['id'=>$this->param['id']]);
$info['account'] = $encrypt->unlock_url($this->param['account']);
$info['password'] = $encrypt->unlock_url($this->param['password']);
$this->param['port'] = $encrypt->unlock_url($this->param['port']);
if($info === false){
$this->fail('当前数据不存在或者被删除');
}
... ... @@ -65,6 +70,10 @@ class ServerConfigLogic extends BaseLogic
{
DB::beginTransaction();
try {
$encrypt = new EncryptUtils();
$this->param['account'] = $encrypt->lock_url($this->param['account']);
$this->param['password'] = $encrypt->lock_url($this->param['password']);
$this->param['port'] = $encrypt->lock_url($this->param['port']);
//保存配置
if(isset($this->param['id']) && !empty($this->param['id'])){
$this->model->edit($this->param,['id'=>$this->param['id']]);
... ... @@ -125,11 +134,6 @@ class ServerConfigLogic extends BaseLogic
if($rs === false){
$this->fail('删除失败');
}
//TODO::上线放开
// if($info['type'] == $this->model::TYPE_MYSQL){
// $sql = 'DROP DATABASE '.$info['title'];
// DB::connection('custom_mysql')->statement($sql);
// }
return $this->success();
}
... ...
... ... @@ -9,6 +9,7 @@
namespace App\Services;
use App\Models\Project\Project;
use App\Utils\EncryptUtils;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
... ... @@ -32,11 +33,12 @@ class ProjectServer extends BaseService
return false;
}
// 设置 database.connections.custom_mysql 配置
$encrypt = new EncryptUtils();
config(['database.connections.custom_mysql.host' => $project->mysqlConfig->host]);
config(['database.connections.custom_mysql.port' => $project->mysqlConfig->port]);
config(['database.connections.custom_mysql.port' => $encrypt->unlock_url($project->mysqlConfig->port)]);
config(['database.connections.custom_mysql.database' => $project->databaseName()]);
config(['database.connections.custom_mysql.username' => $project->mysqlConfig->user]);
config(['database.connections.custom_mysql.password' => $project->mysqlConfig->password]);
config(['database.connections.custom_mysql.username' => $encrypt->unlock_url($project->mysqlConfig->user)]);
config(['database.connections.custom_mysql.password' => $encrypt->unlock_url($project->mysqlConfig->password)]);
// 设置 redis 配置
return $project;
}
... ...