ServersLogic.php 1.6 KB
<?php
/**
 * @remark :
 * @name   :ServersLogic.php
 * @author :lyh
 * @method :post
 * @time   :2024/6/24 16:19
 */

namespace App\Http\Logic\Aside\Devops;

use App\Http\Logic\Aside\BaseLogic;
use App\Models\Devops\Servers;
use App\Utils\EncryptUtils;

class ServersLogic extends BaseLogic
{
    /**
     * 数据初始化
     */
    public function __construct()
    {
        parent::__construct();
        $this->param = $this->requestAll;
        $this->model = new Servers();
    }

    /**
     * @remark :获取信息
     * @name   :getServiceConfig
     * @author :lyh
     * @method :post
     * @time   :2024/6/24 17:05
     */
    public function infoServers(){
        $info = $this->model->read(['id'=>$this->param['id']]);
        if($info === false){
            $this->fail('当前数据不存在或者被删除');
        }
        return $this->success($info);
    }

    /**
     * @remark :保存数据
     * @name   :saveServers
     * @author :lyh
     * @method :post
     * @time   :2024/6/24 16:33
     */
    public function saveServers(){
        $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'])){
            $id = $this->param['id'];
            $this->model->edit($this->param,['id'=>$id]);
        }else{
            $id = $this->model->addReturnId($this->param);
        }
        return $this->success(['id'=>$id]);
    }
}