ServersIpLogic.php
1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?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);
}
}