正在显示
8 个修改的文件
包含
561 行增加
和
8 行删除
| @@ -22,9 +22,25 @@ class ServerInformationController extends BaseController | @@ -22,9 +22,25 @@ class ServerInformationController extends BaseController | ||
| 22 | */ | 22 | */ |
| 23 | public function lists($deleted = ServerInformation::DELETED_NORMAL) | 23 | public function lists($deleted = ServerInformation::DELETED_NORMAL) |
| 24 | { | 24 | { |
| 25 | + | ||
| 26 | + $search = []; | ||
| 27 | + $ip = response()->input('ip'); | ||
| 28 | + if ($ip) { | ||
| 29 | + $search['ip'] = $ip; | ||
| 30 | + } | ||
| 31 | + $remark = response()->input('title'); | ||
| 32 | + if ($remark) { | ||
| 33 | + $search['title'] = $remark; | ||
| 34 | + } | ||
| 35 | + if (empty($search)) { | ||
| 36 | + return $this->response('请输入搜索内容', Code::USER_ERROR); | ||
| 37 | + } | ||
| 25 | $size = request()->input('size', $this->row); | 38 | $size = request()->input('size', $this->row); |
| 26 | - $data = ServerInformation::query()->select(['id', 'title', 'ip']) | ||
| 27 | - ->where('deleted', $deleted) | 39 | + $query = ServerInformation::query()->select(['id', 'title', 'ip']); |
| 40 | + foreach ($search as $key => $item) { | ||
| 41 | + $query = $query->Where("{$key}", 'like', "%{$item}%"); | ||
| 42 | + } | ||
| 43 | + $data = $query->where('deleted', $deleted) | ||
| 28 | ->orderBy('id', 'desc') | 44 | ->orderBy('id', 'desc') |
| 29 | ->paginate($size); | 45 | ->paginate($size); |
| 30 | return $this->response('success', Code::SUCCESS, $data); | 46 | return $this->response('success', Code::SUCCESS, $data); |
| @@ -110,7 +126,7 @@ class ServerInformationController extends BaseController | @@ -110,7 +126,7 @@ class ServerInformationController extends BaseController | ||
| 110 | public function search(Request $request) | 126 | public function search(Request $request) |
| 111 | { | 127 | { |
| 112 | $search = []; | 128 | $search = []; |
| 113 | - $ip = $request->input('ip'); | 129 | + $ip = $request->input('ip'); |
| 114 | if ($ip) { | 130 | if ($ip) { |
| 115 | $search['ip'] = $ip; | 131 | $search['ip'] = $ip; |
| 116 | } | 132 | } |
| @@ -125,7 +141,7 @@ class ServerInformationController extends BaseController | @@ -125,7 +141,7 @@ class ServerInformationController extends BaseController | ||
| 125 | foreach ($search as $key => $item) { | 141 | foreach ($search as $key => $item) { |
| 126 | $query = $query->Where("{$key}", 'like', "%{$item}%"); | 142 | $query = $query->Where("{$key}", 'like', "%{$item}%"); |
| 127 | } | 143 | } |
| 128 | - $size = $request->input('size', $this->row); | 144 | + $size = $request->input('size', $this->row); |
| 129 | $query = $query->orderBy('id', 'desc')->paginate($size); | 145 | $query = $query->orderBy('id', 'desc')->paginate($size); |
| 130 | return $this->response('success', Code::SUCCESS, $query); | 146 | return $this->response('success', Code::SUCCESS, $query); |
| 131 | } | 147 | } |
| @@ -142,7 +158,7 @@ class ServerInformationController extends BaseController | @@ -142,7 +158,7 @@ class ServerInformationController extends BaseController | ||
| 142 | public function getServerInfo(int $deleted = ServerInformation::DELETED_NORMAL) | 158 | public function getServerInfo(int $deleted = ServerInformation::DELETED_NORMAL) |
| 143 | { | 159 | { |
| 144 | $serverInformationLogic = new ServerInformationLogic(); | 160 | $serverInformationLogic = new ServerInformationLogic(); |
| 145 | - $data = $serverInformationLogic->serverInfo($deleted); | 161 | + $data = $serverInformationLogic->serverInfo($deleted); |
| 146 | if (!$data) { | 162 | if (!$data) { |
| 147 | return $this->response('服务器信息不存在', Code::USER_ERROR); | 163 | return $this->response('服务器信息不存在', Code::USER_ERROR); |
| 148 | } | 164 | } |
| @@ -150,6 +166,7 @@ class ServerInformationController extends BaseController | @@ -150,6 +166,7 @@ class ServerInformationController extends BaseController | ||
| 150 | } | 166 | } |
| 151 | 167 | ||
| 152 | /** | 168 | /** |
| 169 | + * 获取软删除的服务器信息 | ||
| 153 | * @return JsonResponse | 170 | * @return JsonResponse |
| 154 | * @throws AsideGlobalException | 171 | * @throws AsideGlobalException |
| 155 | * @throws BsideGlobalException | 172 | * @throws BsideGlobalException |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Controllers\Aside\Domain; | ||
| 4 | + | ||
| 5 | +use App\Enums\Common\Code; | ||
| 6 | +use App\Exceptions\AsideGlobalException; | ||
| 7 | +use App\Exceptions\BsideGlobalException; | ||
| 8 | +use App\Http\Controllers\Aside\BaseController; | ||
| 9 | +use App\Http\Logic\Aside\Domain\DomainInfoLogic; | ||
| 10 | +use App\Http\Requests\Aside\Domain\DomainInfoRequest; | ||
| 11 | +use App\Models\Aside\Domain\DomainInfo; | ||
| 12 | +use App\Models\Aside\Domain\DomainInfoLog; | ||
| 13 | +use Illuminate\Http\JsonResponse; | ||
| 14 | +use Psr\Container\ContainerExceptionInterface; | ||
| 15 | +use Psr\Container\NotFoundExceptionInterface; | ||
| 16 | + | ||
| 17 | +/** | ||
| 18 | + * Class DomainInfoController | ||
| 19 | + * @package App\Http\Controllers\Aside 域名管理 | ||
| 20 | + */ | ||
| 21 | +class DomainInfoController extends BaseController | ||
| 22 | +{ | ||
| 23 | + /** | ||
| 24 | + * 域名列表 | ||
| 25 | + * @param int $deleted | ||
| 26 | + * @return JsonResponse | ||
| 27 | + */ | ||
| 28 | + public function lists(int $deleted = DomainInfo::DELETED_NORMAL) | ||
| 29 | + { | ||
| 30 | + $size = request()->input('size', $this->row); | ||
| 31 | + $data = DomainInfo::query()->select(['id', 'domain', 'belong_to']) | ||
| 32 | + ->where('deleted', $deleted) | ||
| 33 | + ->orderBy('id', 'desc') | ||
| 34 | + ->paginate($size); | ||
| 35 | + return $this->response('success', Code::SUCCESS, $data); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * 获取软删除的数据 | ||
| 40 | + * @return JsonResponse | ||
| 41 | + */ | ||
| 42 | + public function delete_list() | ||
| 43 | + { | ||
| 44 | + return $this->lists(DomainInfo::DELETED_DELETE); | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + /** | ||
| 48 | + * 添加域名 | ||
| 49 | + * @param DomainInfoRequest $domainInfoRequest | ||
| 50 | + * @param DomainInfoLogic $domainInfoLogic | ||
| 51 | + * @return void | ||
| 52 | + * @throws AsideGlobalException | ||
| 53 | + * @throws BsideGlobalException | ||
| 54 | + */ | ||
| 55 | + public function add(DomainInfoRequest $domainInfoRequest, DomainInfoLogic $domainInfoLogic) | ||
| 56 | + { | ||
| 57 | + $domainInfoRequest->validated(); | ||
| 58 | + $domainInfoLogic->create(); | ||
| 59 | + $this->response('域名添加成功!'); | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + /** | ||
| 63 | + * 编辑域名 | ||
| 64 | + * @param DomainInfoRequest $domainInfoRequest | ||
| 65 | + * @param DomainInfoLogic $domainInfoLogic | ||
| 66 | + * @return void | ||
| 67 | + * @throws AsideGlobalException | ||
| 68 | + * @throws BsideGlobalException | ||
| 69 | + */ | ||
| 70 | + public function edit(DomainInfoRequest $domainInfoRequest, DomainInfoLogic $domainInfoLogic) | ||
| 71 | + { | ||
| 72 | + $domainInfoRequest->validate([ | ||
| 73 | + 'id' => 'required|integer' | ||
| 74 | + ], [ | ||
| 75 | + 'id.required' => 'id不能为空', | ||
| 76 | + 'id.integer' => 'id参数错误' | ||
| 77 | + ]); | ||
| 78 | + $domainInfoLogic->update(); | ||
| 79 | + $this->response('域名修改成功!'); | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + /** | ||
| 83 | + * 删除 | ||
| 84 | + * @param DomainInfoLogic $domainInfoLogic | ||
| 85 | + * @return void | ||
| 86 | + * @throws AsideGlobalException | ||
| 87 | + * @throws BsideGlobalException | ||
| 88 | + */ | ||
| 89 | + public function delete(DomainInfoLogic $domainInfoLogic) | ||
| 90 | + { | ||
| 91 | + $domainInfoLogic->get_batch_update(); | ||
| 92 | + $this->response('服务器删除成功!'); | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + /** | ||
| 96 | + * 恢复数据 | ||
| 97 | + * @param DomainInfoLogic $domainInfoLogic | ||
| 98 | + * @return void | ||
| 99 | + * @throws AsideGlobalException | ||
| 100 | + * @throws BsideGlobalException | ||
| 101 | + */ | ||
| 102 | + public function restore(DomainInfoLogic $domainInfoLogic) | ||
| 103 | + { | ||
| 104 | + $domainInfoLogic->get_batch_update(DomainInfoLog::ACTION_RECOVER, DomainInfo::DELETED_DELETE); | ||
| 105 | + $this->response('服务器恢复成功!'); | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + /** | ||
| 109 | + * 域名信息 | ||
| 110 | + * @param int $deleted | ||
| 111 | + * @return JsonResponse | ||
| 112 | + * @throws AsideGlobalException | ||
| 113 | + * @throws BsideGlobalException | ||
| 114 | + * @throws ContainerExceptionInterface | ||
| 115 | + * @throws NotFoundExceptionInterface | ||
| 116 | + */ | ||
| 117 | + public function getDomainInfo(int $deleted = DomainInfo::DELETED_NORMAL) | ||
| 118 | + { | ||
| 119 | + $domainInfoLogic = new DomainInfoLogic(); | ||
| 120 | + $data = $domainInfoLogic->domainInfo($deleted); | ||
| 121 | + if (!$data) { | ||
| 122 | + return $this->response('服务器信息不存在', Code::USER_ERROR); | ||
| 123 | + } | ||
| 124 | + return $this->success($data->toArray()); | ||
| 125 | + } | ||
| 126 | + | ||
| 127 | + /** | ||
| 128 | + * 获取软删除域名信息 | ||
| 129 | + * @return JsonResponse | ||
| 130 | + * @throws AsideGlobalException | ||
| 131 | + * @throws BsideGlobalException | ||
| 132 | + * @throws ContainerExceptionInterface | ||
| 133 | + * @throws NotFoundExceptionInterface | ||
| 134 | + */ | ||
| 135 | + public function getDeleteDomainInfo() | ||
| 136 | + { | ||
| 137 | + return $this->getDomainInfo(DomainInfo::DELETED_DELETE); | ||
| 138 | + } | ||
| 139 | +} |
| @@ -152,7 +152,7 @@ class ServerInformationLogic extends BaseLogic | @@ -152,7 +152,7 @@ class ServerInformationLogic extends BaseLogic | ||
| 152 | if (!$id) { | 152 | if (!$id) { |
| 153 | return $this->fail('参数错误'); | 153 | return $this->fail('参数错误'); |
| 154 | } | 154 | } |
| 155 | - $data = ServerInformation::query()->where('deleted', $deleted)->find($id, ['type', 'ip', 'title', 'belong_to', 'sshpass', 'ports', 'create_at', 'update_at']); | 155 | + $data = ServerInformation::query()->where('deleted', $deleted)->find($id, ['type', 'ip', 'title', 'belong_to', 'ports', 'create_at', 'update_at']); |
| 156 | if (!$data) { | 156 | if (!$data) { |
| 157 | return $this->fail('数据不存在!'); | 157 | return $this->fail('数据不存在!'); |
| 158 | } | 158 | } |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Logic\Aside\Domain; | ||
| 4 | + | ||
| 5 | + | ||
| 6 | +use App\Enums\Common\Code; | ||
| 7 | +use App\Exceptions\AsideGlobalException; | ||
| 8 | +use App\Exceptions\BsideGlobalException; | ||
| 9 | +use App\Http\Logic\Aside\BaseLogic; | ||
| 10 | +use App\Models\Aside\Domain\DomainInfo; | ||
| 11 | +use App\Models\Aside\Domain\DomainInfoLog; | ||
| 12 | +use App\Models\Devops\ServerInformation; | ||
| 13 | +use App\Models\Devops\ServerInformationLog; | ||
| 14 | +use Illuminate\Database\Eloquent\Builder; | ||
| 15 | +use Illuminate\Database\Eloquent\Collection; | ||
| 16 | +use Illuminate\Database\Eloquent\Model; | ||
| 17 | +use Illuminate\Support\Facades\DB; | ||
| 18 | +use Illuminate\Support\Facades\Log; | ||
| 19 | + | ||
| 20 | +class DomainInfoLogic extends BaseLogic | ||
| 21 | +{ | ||
| 22 | + /** | ||
| 23 | + * @var array | ||
| 24 | + */ | ||
| 25 | + private $param; | ||
| 26 | + | ||
| 27 | + public function __construct() | ||
| 28 | + { | ||
| 29 | + parent::__construct(); | ||
| 30 | + | ||
| 31 | + $this->model = new ServerInformation(); | ||
| 32 | + | ||
| 33 | + $this->param = $this->requestAll; | ||
| 34 | + | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + /** | ||
| 38 | + * 添加数据 | ||
| 39 | + * @return array | ||
| 40 | + * @throws AsideGlobalException | ||
| 41 | + * @throws BsideGlobalException | ||
| 42 | + */ | ||
| 43 | + public function create() | ||
| 44 | + { | ||
| 45 | + $request = $this->param; | ||
| 46 | + $domain = new DomainInfo(); | ||
| 47 | + $this->extracted($request, $domain); | ||
| 48 | + DB::beginTransaction(); | ||
| 49 | + if ($domain->save()) { | ||
| 50 | + $original = [ | ||
| 51 | + 'id' => $domain->id, | ||
| 52 | + 'domain' => $domain->domain, | ||
| 53 | + 'belong_to' => $domain->belong_to, | ||
| 54 | + 'status' => $domain->status, | ||
| 55 | + 'domain_start_time' => $domain->domain_start_time, | ||
| 56 | + 'domain_end_time' => $domain->domain_end_time, | ||
| 57 | + 'certificate_start_time' => $domain->certificate_start_time, | ||
| 58 | + 'certificate_end_time' => $domain->certificate_end_time, | ||
| 59 | + ]; | ||
| 60 | + // 添加日志 | ||
| 61 | + $this->domain_action_log(ServerInformationLog::ACTION_ADD, $original, $original, '添加服务器信息成功 - ID : ' . $domain->id); | ||
| 62 | + DB::commit(); | ||
| 63 | + return $this->success(); | ||
| 64 | + } | ||
| 65 | + DB::rollBack(); | ||
| 66 | + return $this->fail('域名信息添加失败'); | ||
| 67 | + | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + /** | ||
| 71 | + * 修改数据 | ||
| 72 | + * @return array | ||
| 73 | + * @throws AsideGlobalException | ||
| 74 | + * @throws BsideGlobalException | ||
| 75 | + */ | ||
| 76 | + public function update() | ||
| 77 | + { | ||
| 78 | + $domain = new DomainInfo(); | ||
| 79 | + $request = $this->param; | ||
| 80 | + $this->extracted($request, $domain); | ||
| 81 | + DB::beginTransaction(); | ||
| 82 | + if ($domain->save()) { | ||
| 83 | + $fields_array = $domain->FieldsArray(); | ||
| 84 | + $original = $domain->getOriginal(); | ||
| 85 | + $revised = [ | ||
| 86 | + 'id' => $domain->id, | ||
| 87 | + 'domain' => $domain->domain, | ||
| 88 | + 'belong_to' => $domain->belong_to, | ||
| 89 | + 'status' => $domain->status, | ||
| 90 | + 'domain_start_time' => $domain->domain_start_time, | ||
| 91 | + 'domain_end_time' => $domain->domain_end_time, | ||
| 92 | + 'certificate_start_time' => $domain->certificate_start_time, | ||
| 93 | + 'certificate_end_time' => $domain->certificate_end_time, | ||
| 94 | + 'delete' => $domain->delete, | ||
| 95 | + ]; | ||
| 96 | + $diff = array_diff_assoc($original, $revised); | ||
| 97 | + unset($diff['deleted']); | ||
| 98 | + $remarks = ''; | ||
| 99 | + if ($diff) { | ||
| 100 | + $remarks .= '修改ID为 ' . $domain->id . ' 的服务器信息,修改内容为:'; | ||
| 101 | + foreach ($diff as $key => $value) { | ||
| 102 | + $remarks .= $fields_array[$key] . ' 由 ' . $value . ' 修改为 ' . $revised[$key] . '; '; | ||
| 103 | + } | ||
| 104 | + } | ||
| 105 | + // 添加日志 | ||
| 106 | + $this->domain_action_log(ServerInformationLog::ACTION_UPDATE, $original, $revised, $remarks); | ||
| 107 | + DB::commit(); | ||
| 108 | + return $this->success(); | ||
| 109 | + } | ||
| 110 | + DB::rollBack(); | ||
| 111 | + return $this->fail('域名信息修改失败'); | ||
| 112 | + } | ||
| 113 | + | ||
| 114 | + /** | ||
| 115 | + * 检查域名是否存在 | ||
| 116 | + * @param $domain | ||
| 117 | + * @return bool | ||
| 118 | + */ | ||
| 119 | + public function checkDomain($domain) | ||
| 120 | + { | ||
| 121 | + $usIp = DomainInfo::query()->where('domain', $domain)->first(); | ||
| 122 | + if ($usIp) { | ||
| 123 | + return true; | ||
| 124 | + } else { | ||
| 125 | + return false; | ||
| 126 | + } | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + /** | ||
| 130 | + * 详情 | ||
| 131 | + * @param int $deleted | ||
| 132 | + * @return array|Builder|Collection|Model | ||
| 133 | + * @throws AsideGlobalException | ||
| 134 | + * @throws BsideGlobalException | ||
| 135 | + */ | ||
| 136 | + public function domainInfo(int $deleted = DomainInfo::DELETED_NORMAL) | ||
| 137 | + { | ||
| 138 | + $id = request()->input('id'); | ||
| 139 | + if (!$id) { | ||
| 140 | + return $this->fail('参数错误'); | ||
| 141 | + } | ||
| 142 | + $data = DomainInfo::query()->where('deleted', $deleted)->find($id, ['domain', 'belong_to', 'title', 'domain_start_time', 'domain_end_time', 'certificate_start_time', 'certificate_end_time', 'create_at', 'update_at']); | ||
| 143 | + if (!$data) { | ||
| 144 | + return $this->fail('数据不存在!'); | ||
| 145 | + } | ||
| 146 | + return $data; | ||
| 147 | + } | ||
| 148 | + | ||
| 149 | + /** | ||
| 150 | + * 服务器操作日志 | ||
| 151 | + * @param int $action 1:添加 2:修改 3:删除 4:搜索 5:详情 6:列表 | ||
| 152 | + * @param array $original 原始数据 | ||
| 153 | + * @param array $revised 修改后数据 | ||
| 154 | + */ | ||
| 155 | + public function domain_action_log(int $action = DomainInfoLog::ACTION_ADD, array $original = [], array $revised = [], $remarks = '') | ||
| 156 | + { | ||
| 157 | + // $action 1:添加 2:修改 3:删除 4:恢复 | ||
| 158 | + $actionArr = DomainInfoLog::actionArr(); | ||
| 159 | + $actionStr = $actionArr[$action]; | ||
| 160 | + $ip = request()->getClientIp(); | ||
| 161 | + $url = request()->getRequestUri(); | ||
| 162 | + $method = request()->getMethod(); | ||
| 163 | + $userId = $this->uid ?? 0; | ||
| 164 | + $log = new ServerInformationLog(); | ||
| 165 | + $log->user_id = $userId; | ||
| 166 | + $log->action = $actionStr; | ||
| 167 | + $log->original = json_encode($original); | ||
| 168 | + $log->revised = json_encode($revised); | ||
| 169 | + $log->ip = $ip; | ||
| 170 | + $log->url = $url; | ||
| 171 | + $log->method = $method; | ||
| 172 | + $log->remarks = $remarks; | ||
| 173 | + DB::beginTransaction(); | ||
| 174 | + try { | ||
| 175 | + $log->save(); | ||
| 176 | + DB::commit(); | ||
| 177 | + } catch (\Exception $e) { | ||
| 178 | + DB::rollBack(); | ||
| 179 | + Log::error('服务器信息日志添加失败'); | ||
| 180 | + } | ||
| 181 | + } | ||
| 182 | + | ||
| 183 | + /** | ||
| 184 | + * @param array $request | ||
| 185 | + * @param $domain | ||
| 186 | + * @return void | ||
| 187 | + */ | ||
| 188 | + public function extracted(array $request, $domain) | ||
| 189 | + { | ||
| 190 | + $domain->domain = trim($request['domain']); // 域名 | ||
| 191 | + $domain->belong_to = trim($request['belong_to']); // 域名归属 1 - 公司 2 - 客户 | ||
| 192 | + $domain->status = trim($request['status']); // 域名状态 0 - 正常 1 - 关闭 | ||
| 193 | + $domain->domain_start_time = trim($request['domain_start_time']); // 域名开始时间 | ||
| 194 | + $domain->domain_end_time = trim($request['domain_end_time']); // 域名结束时间 | ||
| 195 | + $domain->certificate_start_time = trim($request['certificate_start_time']); // 证书开始时间 | ||
| 196 | + $domain->certificate_end_time = trim($request['certificate_end_time']); // 证书结束时间 | ||
| 197 | + } | ||
| 198 | + | ||
| 199 | + /** | ||
| 200 | + * 批量获取数据删除 | ||
| 201 | + * @return array | ||
| 202 | + * @throws AsideGlobalException | ||
| 203 | + * @throws BsideGlobalException | ||
| 204 | + */ | ||
| 205 | + public function get_batch_update($action = DomainInfoLog::ACTION_DELETE, $deleted = DomainInfo::DELETED_NORMAL) | ||
| 206 | + { | ||
| 207 | + $id = request()->input('id'); | ||
| 208 | + if (!$id) { | ||
| 209 | + return $this->fail('参数错误'); | ||
| 210 | + } | ||
| 211 | + $ids = []; | ||
| 212 | + if (!is_array($id)) { | ||
| 213 | + $ids = explode(',', $id); | ||
| 214 | + } | ||
| 215 | + $ids = array_filter($ids, 'intval'); | ||
| 216 | + if (empty($ids)) { | ||
| 217 | + return $this->fail('参数错误'); | ||
| 218 | + } | ||
| 219 | + $data = DomainInfo::query()->whereIn('id', $ids)->where('deleted', $deleted)->get(); | ||
| 220 | + $restore_ids = $data->pluck('id')->toArray(); | ||
| 221 | + $actionArr = DomainInfoLog::actionArr(); | ||
| 222 | + $actionStr = $actionArr[$action]; | ||
| 223 | + if (empty($restore_ids)) { | ||
| 224 | + $this->fail($actionStr . '服务器信息不存在!', Code::USER_ERROR); | ||
| 225 | + } | ||
| 226 | + $original = $data->toArray(); | ||
| 227 | + DB::beginTransaction(); | ||
| 228 | + try { | ||
| 229 | + $update = $deleted == DomainInfo::DELETED_NORMAL ? DomainInfo::DELETED_DELETE : DomainInfo::DELETED_NORMAL; | ||
| 230 | + DomainInfo::query()->whereIn('id', $restore_ids)->update(['deleted' => $update]); | ||
| 231 | + $this->domain_action_log($action, $original, $original, $actionStr . '服务器信息 - ID : ' . implode(', ', $restore_ids)); | ||
| 232 | + DB::commit(); | ||
| 233 | + return $this->success(); | ||
| 234 | + } catch (\Exception $e) { | ||
| 235 | + DB::rollBack(); | ||
| 236 | + return $this->fail('服务器信息' . $actionStr . '失败', Code::USER_ERROR); | ||
| 237 | + } | ||
| 238 | + } | ||
| 239 | +} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Requests\Aside\Domain; | ||
| 4 | + | ||
| 5 | +use Illuminate\Foundation\Http\FormRequest; | ||
| 6 | +use Illuminate\Validation\Rule; | ||
| 7 | + | ||
| 8 | +class DomainInfoRequest extends FormRequest | ||
| 9 | +{ | ||
| 10 | + /** | ||
| 11 | + * Determine if the user is authorized to make this request. | ||
| 12 | + * | ||
| 13 | + * @return bool | ||
| 14 | + */ | ||
| 15 | + public function authorize() | ||
| 16 | + { | ||
| 17 | + return true; | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + /** | ||
| 21 | + * Get the validation rules that apply to the request. | ||
| 22 | + * | ||
| 23 | + * @return array | ||
| 24 | + */ | ||
| 25 | + public function rules() | ||
| 26 | + { | ||
| 27 | + return [ | ||
| 28 | + 'domain' => 'required|max:200', | ||
| 29 | + 'belong_to' => [ | ||
| 30 | + 'required', | ||
| 31 | + Rule::in([1, 2]) | ||
| 32 | + ], | ||
| 33 | + 'status' => [ | ||
| 34 | + 'required', | ||
| 35 | + Rule::in([0, 1]) | ||
| 36 | + ] | ||
| 37 | + ]; | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + public function messages() | ||
| 41 | + { | ||
| 42 | + return [ | ||
| 43 | + 'domain.required' => '域名不能为空', | ||
| 44 | + 'domain.max' => '域名长度不能超过200个字符', | ||
| 45 | + 'belong_to.required' => '所属不能为空', | ||
| 46 | + 'belong_to.in' => '所属参数错误', | ||
| 47 | + 'status.required' => '状态不能为空', | ||
| 48 | + 'status.in' => '状态参数错误', | ||
| 49 | + ]; | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | +} |
app/Models/Aside/Domain/DomainInfo.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Models\Aside\Domain; | ||
| 4 | + | ||
| 5 | +use App\Models\Base; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * Class DomainInfo | ||
| 9 | + * @package App\Models\Aside\Domain | ||
| 10 | + * @Author YiYuan-LIn | ||
| 11 | + * @Date: 2019/5/16 | ||
| 12 | + * 域名信息模型 | ||
| 13 | + */ | ||
| 14 | +class DomainInfo extends Base | ||
| 15 | +{ | ||
| 16 | + protected $table = 'gl_domain_info'; | ||
| 17 | + | ||
| 18 | + // 软删除 0:正常 1:删除 | ||
| 19 | + /** @var int 软删除 - 正常 */ | ||
| 20 | + const DELETED_NORMAL = 0; | ||
| 21 | + /** @var int 软删除 - 删除 */ | ||
| 22 | + const DELETED_DELETE = 1; | ||
| 23 | + | ||
| 24 | + protected $hidden = [ | ||
| 25 | + 'created_at', | ||
| 26 | + 'updated_at' | ||
| 27 | + ]; | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * 字段信息 | ||
| 31 | + * @return array | ||
| 32 | + */ | ||
| 33 | + public function FieldsArray() | ||
| 34 | + { | ||
| 35 | + return [ | ||
| 36 | + 'domain' => '域名', | ||
| 37 | + 'belong_to' => '域名归属', | ||
| 38 | + 'status' => '域名状态', | ||
| 39 | + 'domain_start_time' => '域名开始时间', | ||
| 40 | + 'domain_end_time' => '域名结束时间', | ||
| 41 | + 'certificate_start_time' => '证书开始时间', | ||
| 42 | + 'certificate_end_time' => '证书结束时间', | ||
| 43 | + ]; | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * 域名归属信息 | ||
| 48 | + * @return array | ||
| 49 | + */ | ||
| 50 | + public function BelongToArray() | ||
| 51 | + { | ||
| 52 | + return [ | ||
| 53 | + 1 => '公司', | ||
| 54 | + 2 => '客户', | ||
| 55 | + ]; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + public function BelongTo($num) | ||
| 59 | + { | ||
| 60 | + return $this->BelongToArray()[$num]; | ||
| 61 | + } | ||
| 62 | +} |
app/Models/Aside/Domain/DomainInfoLog.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Models\Aside\Domain; | ||
| 4 | + | ||
| 5 | +use Illuminate\Database\Eloquent\Model; | ||
| 6 | + | ||
| 7 | +class DomainInfoLog extends Model | ||
| 8 | +{ | ||
| 9 | + protected $table = 'gl_domain_info_log'; | ||
| 10 | + const CREATED_AT = 'create_at'; | ||
| 11 | + const UPDATED_AT = 'update_at'; | ||
| 12 | + | ||
| 13 | + public function getOriginalAttribute($value) | ||
| 14 | + { | ||
| 15 | + return json_decode($value, true); | ||
| 16 | + } | ||
| 17 | + | ||
| 18 | + public function getRevisedAttribute($value) | ||
| 19 | + { | ||
| 20 | + return json_decode($value, true); | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + /** @var int 日志添加 */ | ||
| 24 | + const ACTION_ADD = 1; | ||
| 25 | + /** @var int 日志修改 */ | ||
| 26 | + const ACTION_UPDATE = 2; | ||
| 27 | + /** @var int 日志删除 */ | ||
| 28 | + const ACTION_DELETE = 3; | ||
| 29 | + /** @var int 日志恢复 */ | ||
| 30 | + const ACTION_RECOVER = 4; | ||
| 31 | + | ||
| 32 | + | ||
| 33 | + /** | ||
| 34 | + * @return string[] | ||
| 35 | + */ | ||
| 36 | + public static function actionArr() | ||
| 37 | + { | ||
| 38 | + return [ | ||
| 39 | + 1 => '添加', | ||
| 40 | + 2 => '修改', | ||
| 41 | + 3 => '删除', | ||
| 42 | + 4 => '恢复', | ||
| 43 | + ]; | ||
| 44 | + } | ||
| 45 | +} |
| @@ -127,7 +127,7 @@ Route::middleware(['web'])->group(function (){ //admin用渲染默认要加上w | @@ -127,7 +127,7 @@ Route::middleware(['web'])->group(function (){ //admin用渲染默认要加上w | ||
| 127 | 127 | ||
| 128 | // 服务器添加|修改|删除 | 128 | // 服务器添加|修改|删除 |
| 129 | Route::prefix('server')->group(function () { | 129 | Route::prefix('server')->group(function () { |
| 130 | - Route::get('/', [Aside\Devops\ServerInformationController::class, 'lists'])->name('admin.devops.bt'); // 列表 | 130 | + Route::get('/', [Aside\Devops\ServerInformationController::class, 'lists'])->name('admin.devops.bt'); // 列表 | 搜索 |
| 131 | Route::get('/info', [Aside\Devops\ServerInformationController::class, 'getServerInfo'])->name('admin.devops.bt_info'); // 获取信息 | 131 | Route::get('/info', [Aside\Devops\ServerInformationController::class, 'getServerInfo'])->name('admin.devops.bt_info'); // 获取信息 |
| 132 | Route::get('/delete_info', [Aside\Devops\ServerInformationController::class, 'getDeleteServerInfo'])->name('admin.devops.bt_delete_info'); // 删除信息 | 132 | Route::get('/delete_info', [Aside\Devops\ServerInformationController::class, 'getDeleteServerInfo'])->name('admin.devops.bt_delete_info'); // 删除信息 |
| 133 | Route::post('/add', [Aside\Devops\ServerInformationController::class, 'add'])->name('admin.devops.bt_add'); // 添加 | 133 | Route::post('/add', [Aside\Devops\ServerInformationController::class, 'add'])->name('admin.devops.bt_add'); // 添加 |
| @@ -135,7 +135,6 @@ Route::middleware(['web'])->group(function (){ //admin用渲染默认要加上w | @@ -135,7 +135,6 @@ Route::middleware(['web'])->group(function (){ //admin用渲染默认要加上w | ||
| 135 | Route::get('/delete', [Aside\Devops\ServerInformationController::class, 'delete'])->name('admin.devops.bt_delete'); // 删除 | 135 | Route::get('/delete', [Aside\Devops\ServerInformationController::class, 'delete'])->name('admin.devops.bt_delete'); // 删除 |
| 136 | Route::get('/delete_list', [Aside\Devops\ServerInformationController::class, 'delete_list'])->name('admin.devops.bt_delete_list'); // 删除列表 | 136 | Route::get('/delete_list', [Aside\Devops\ServerInformationController::class, 'delete_list'])->name('admin.devops.bt_delete_list'); // 删除列表 |
| 137 | Route::get('/restore', [Aside\Devops\ServerInformationController::class, 'restore'])->name('admin.devops.bt_restore'); //恢复数据 | 137 | Route::get('/restore', [Aside\Devops\ServerInformationController::class, 'restore'])->name('admin.devops.bt_restore'); //恢复数据 |
| 138 | - Route::get('/search', [Aside\Devops\ServerInformationController::class, 'search'])->name('admin.devops.bt_search'); //搜索 | ||
| 139 | Route::get('/log', [Aside\Devops\ServerInformationLogController::class, 'lists'])->name('admin.devops.bt_log_lists'); //日志列表 | 138 | Route::get('/log', [Aside\Devops\ServerInformationLogController::class, 'lists'])->name('admin.devops.bt_log_lists'); //日志列表 |
| 140 | }); | 139 | }); |
| 141 | 140 |
-
请 注册 或 登录 后发表评论