作者 lyh

gx

... ... @@ -72,14 +72,13 @@ class DevopsTask extends Command
continue;
}
//DB类是单例模式,生命周期内修改配置不会生效
$encrypt = new EncryptUtils();
try {
$conn = new \mysqli(
$project->mysqlConfig->host,
$encrypt->unlock_url($project->mysqlConfig->user),
$encrypt->unlock_url($project->mysqlConfig->password),
$project->mysqlConfig->user,
$project->mysqlConfig->password,
$project->databaseName(),
$encrypt->unlock_url($project->mysqlConfig->port),
$project->mysqlConfig->port,
);
}catch (\Exception $e){
$log->remark = mb_substr('数据库连接失败:' . $e->getMessage(), 0, 500);
... ...
... ... @@ -50,11 +50,7 @@ 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['user'] = $encrypt->unlock_url($info['user']);
$info['password'] = $encrypt->unlock_url($info['password']);
$info['port'] = $encrypt->unlock_url($info['port']);
if($info === false){
$this->fail('当前数据不存在或者被删除');
}
... ...
... ... @@ -8,7 +8,9 @@
namespace App\Models\Devops;
use App\Helper\Arr;
use App\Models\Base;
use App\Utils\EncryptUtils;
/**
* 服务账户信息
... ... @@ -32,4 +34,36 @@ class ServerConfig extends Base
const STATUS_ONE = 1;
/**
* @remark :获取数据用户名解密
* @name :getUserAttribute
* @author :lyh
* @method :post
* @time :2023/9/12 16:05
*/
public function getUserAttribute($value){
return EncryptUtils::unlock_url($value);
}
/**
* @remark :密码解密
* @name :getPasswordAttribute
* @author :lyh
* @method :post
* @time :2023/9/12 16:05
*/
public function getPasswordAttribute($value){
return EncryptUtils::unlock_url($value);
}
/**
* @remark :端口解密
* @name :getPasswordAttribute
* @author :lyh
* @method :post
* @time :2023/9/12 16:05
*/
public function getPortAttribute($value){
return EncryptUtils::unlock_url($value);
}
}
... ...