DomainInfoController.php
3.8 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?php
namespace App\Http\Controllers\Aside\Domain;
use App\Enums\Common\Code;
use App\Exceptions\AsideGlobalException;
use App\Exceptions\BsideGlobalException;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\Domain\DomainInfoLogic;
use App\Http\Requests\Aside\Domain\DomainInfoRequest;
use App\Models\Aside\Domain\DomainInfo;
use App\Models\Aside\Domain\DomainInfoLog;
use Illuminate\Http\JsonResponse;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
/**
* Class DomainInfoController
* @package App\Http\Controllers\Aside 域名管理
*/
class DomainInfoController extends BaseController
{
/**
* 域名列表
* @param int $deleted
* @return JsonResponse
*/
public function lists()
{
$domainModel = new DomainInfo();
if(isset($this->map['domain']) && !empty($this->map['domain'])){
$this->map['domain'] = ['like','%'.$this->map['domain'],'%'];
}
$lists = $domainModel->lists($this->map,$this->page,$this->row,$this->order);
return $this->response('success', Code::SUCCESS, $lists);
}
/**
* 添加域名
* @param DomainInfoRequest $domainInfoRequest
* @param DomainInfoLogic $domainInfoLogic
* @return void
* @throws AsideGlobalException
* @throws BsideGlobalException
*/
public function add(DomainInfoRequest $domainInfoRequest, DomainInfoLogic $domainInfoLogic)
{
$domainInfoRequest->validated();
$domainInfoLogic->create();
$this->response('域名添加成功!');
}
/**
* 编辑域名
* @param DomainInfoRequest $domainInfoRequest
* @param DomainInfoLogic $domainInfoLogic
* @return void
* @throws AsideGlobalException
* @throws BsideGlobalException
*/
public function edit(DomainInfoRequest $domainInfoRequest, DomainInfoLogic $domainInfoLogic)
{
$domainInfoRequest->validate([
'id' => 'required|integer'
], [
'id.required' => 'id不能为空',
'id.integer' => 'id参数错误'
]);
$domainInfoLogic->update();
$this->response('域名修改成功!');
}
/**
* 删除
* @param DomainInfoLogic $domainInfoLogic
* @return void
* @throws AsideGlobalException
* @throws BsideGlobalException
*/
public function delete(DomainInfoLogic $domainInfoLogic)
{
$domainInfoLogic->get_batch_update();
$this->response('域名删除成功!');
}
/**
* 恢复数据
* @param DomainInfoLogic $domainInfoLogic
* @return void
* @throws AsideGlobalException
* @throws BsideGlobalException
*/
public function restore(DomainInfoLogic $domainInfoLogic)
{
$domainInfoLogic->get_batch_update(DomainInfoLog::ACTION_RECOVER, DomainInfo::DELETED_DELETE);
$this->response('域名恢复成功!');
}
/**
* 域名信息
* @param int $deleted
* @return JsonResponse
* @throws AsideGlobalException
* @throws BsideGlobalException
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function info(int $deleted = DomainInfo::DELETED_NORMAL)
{
$domainInfoLogic = new DomainInfoLogic();
$data = $domainInfoLogic->domainInfo($deleted);
if (!$data) {
return $this->response('域名信息不存在', Code::USER_ERROR);
}
return $this->success($data->toArray());
}
/**
* 获取软删除域名信息
* @return JsonResponse
* @throws AsideGlobalException
* @throws BsideGlobalException
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function getDeleteDomainInfo()
{
return $this->info(DomainInfo::DELETED_DELETE);
}
}