ServersIpLogic.php 1.5 KB
<?php
/**
 * @remark :
 * @name   :ServersIpLogic.php
 * @author :lyh
 * @method :post
 * @time   :2024/6/24 16:21
 */

namespace App\Http\Logic\Aside\Devops;

use App\Http\Logic\Aside\BaseLogic;
use App\Models\Devops\ServersIp;

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

    /**
     * @remark :保存数据
     * @name   :saveServersIp
     * @author :lyh
     * @method :post
     * @time   :2024/6/24 17:28
     */
    public function saveServersIp(){
        if(isset($this->param['id']) && !empty($this->param['id'])){
            $id = $this->param['id'];
            $this->model->edit($this->param,['id'=>$this->param['id']]);
        }else{
            $id = $this->model->addReturnId($this->param);
        }
        return $this->success(['id'=>$id]);
    }

    /**
     * @remark :批量添加
     * @name   :batchSaveServersIp
     * @author :lyh
     * @method :post
     * @time   :2024/6/24 17:25
     */
    public function batchSaveServersIp(){
        $data = [];
        foreach ($this->param['data'] as $v){
            if(empty($v['ip']) || empty($v['domain'])){
                continue;
            }
            $data[] = [
                'ip'=>$v['ip'],
                'domain'=>$v['domain'],
                'servers_id'=>$this->param['servers_id']
            ];
        }
        return $this->addReturnId($data);
    }
}