Merge branch 'develop' of http://47.244.231.31:8099/zhl/globalso-v6 into develop
正在显示
13 个修改的文件
包含
743 行增加
和
2 行删除
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Controllers\Aside\Devops; | ||
| 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\Devops\ServerInformationLogic; | ||
| 10 | +use App\Http\Requests\Aside\Devops\ServerInformationRequest; | ||
| 11 | +use App\Models\Devops\ServerInformation; | ||
| 12 | +use App\Models\Devops\ServerInformationLog; | ||
| 13 | +use Illuminate\Http\JsonResponse; | ||
| 14 | +use Illuminate\Http\Request; | ||
| 15 | +use Psr\Container\ContainerExceptionInterface; | ||
| 16 | +use Psr\Container\NotFoundExceptionInterface; | ||
| 17 | + | ||
| 18 | +class ServerInformationController extends BaseController | ||
| 19 | +{ | ||
| 20 | + /** | ||
| 21 | + * @return JsonResponse | ||
| 22 | + */ | ||
| 23 | + public function lists($deleted = ServerInformation::DELETED_NORMAL) | ||
| 24 | + { | ||
| 25 | + $size = request()->input('size', $this->row); | ||
| 26 | + $data = ServerInformation::query()->select(['id', 'title', 'ip']) | ||
| 27 | + ->where('deleted', $deleted) | ||
| 28 | + ->orderBy('id', 'desc') | ||
| 29 | + ->paginate($size); | ||
| 30 | + return $this->response('success', Code::SUCCESS, $data); | ||
| 31 | + | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + /** | ||
| 35 | + * 添加 | ||
| 36 | + * @param ServerInformationRequest $serverInformationRequest | ||
| 37 | + * @param ServerInformationLogic $serverInformationLogic | ||
| 38 | + * @return void | ||
| 39 | + * @throws AsideGlobalException | ||
| 40 | + * @throws BsideGlobalException | ||
| 41 | + */ | ||
| 42 | + public function add(ServerInformationRequest $serverInformationRequest, ServerInformationLogic $serverInformationLogic) | ||
| 43 | + { | ||
| 44 | + | ||
| 45 | + $serverInformationRequest->validated(); | ||
| 46 | + $serverInformationLogic->create(); | ||
| 47 | + $this->response('服务器添加成功!'); | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + /** | ||
| 51 | + * 编辑 | ||
| 52 | + * @param ServerInformationRequest $serverInformationRequest | ||
| 53 | + * @param ServerInformationLogic $serverInformationLogic | ||
| 54 | + * @return void | ||
| 55 | + * @throws AsideGlobalException | ||
| 56 | + * @throws BsideGlobalException | ||
| 57 | + */ | ||
| 58 | + public function edit(ServerInformationRequest $serverInformationRequest, ServerInformationLogic $serverInformationLogic) | ||
| 59 | + { | ||
| 60 | + $serverInformationRequest->validate([ | ||
| 61 | + 'id' => ['required'], | ||
| 62 | + ], [ | ||
| 63 | + 'id.required' => 'ID不能为空', | ||
| 64 | + ]); | ||
| 65 | + $serverInformationLogic->update(); | ||
| 66 | + $this->response('服务器修改成功!'); | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + /** | ||
| 70 | + * 删除 | ||
| 71 | + * @param ServerInformationLogic $serverInformationLogic | ||
| 72 | + * @return void | ||
| 73 | + * @throws AsideGlobalException | ||
| 74 | + * @throws BsideGlobalException | ||
| 75 | + */ | ||
| 76 | + public function delete(ServerInformationLogic $serverInformationLogic) | ||
| 77 | + { | ||
| 78 | + $serverInformationLogic->get_batch_update(); | ||
| 79 | + $this->response('服务器删除成功!'); | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + /** | ||
| 83 | + * 获取软删除的数据 | ||
| 84 | + * @return JsonResponse | ||
| 85 | + */ | ||
| 86 | + public function delete_list() | ||
| 87 | + { | ||
| 88 | + return $this->lists(ServerInformation::DELETED_DELETE); | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + /** | ||
| 92 | + * 恢复数据 | ||
| 93 | + * @param ServerInformationLogic $serverInformationLogic | ||
| 94 | + * @return void | ||
| 95 | + * @throws AsideGlobalException | ||
| 96 | + * @throws BsideGlobalException | ||
| 97 | + */ | ||
| 98 | + public function restore(ServerInformationLogic $serverInformationLogic) | ||
| 99 | + { | ||
| 100 | + $serverInformationLogic->get_batch_update(ServerInformationLog::ACTION_RECOVER, ServerInformation::DELETED_DELETE); | ||
| 101 | + $this->response('服务器恢复成功!'); | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + | ||
| 105 | + /** | ||
| 106 | + * 搜索 | ||
| 107 | + * @param Request $request | ||
| 108 | + * @return JsonResponse | ||
| 109 | + */ | ||
| 110 | + public function search(Request $request) | ||
| 111 | + { | ||
| 112 | + $search = []; | ||
| 113 | + $ip = $request->input('ip'); | ||
| 114 | + if ($ip) { | ||
| 115 | + $search['ip'] = $ip; | ||
| 116 | + } | ||
| 117 | + $remark = $request->input('title'); | ||
| 118 | + if ($remark) { | ||
| 119 | + $search['title'] = $remark; | ||
| 120 | + } | ||
| 121 | + if (empty($search)) { | ||
| 122 | + return $this->response('请输入搜索内容', Code::USER_ERROR); | ||
| 123 | + } | ||
| 124 | + $query = ServerInformation::query()->select(['id', 'title', 'ip']); | ||
| 125 | + foreach ($search as $key => $item) { | ||
| 126 | + $query = $query->Where("{$key}", 'like', "%{$item}%"); | ||
| 127 | + } | ||
| 128 | + $size = $request->input('size', $this->row); | ||
| 129 | + $query = $query->orderBy('id', 'desc')->paginate($size); | ||
| 130 | + return $this->response('success', Code::SUCCESS, $query); | ||
| 131 | + } | ||
| 132 | + | ||
| 133 | + /** | ||
| 134 | + * 服务器信息 | ||
| 135 | + * @param int $deleted | ||
| 136 | + * @return JsonResponse | ||
| 137 | + * @throws AsideGlobalException | ||
| 138 | + * @throws BsideGlobalException | ||
| 139 | + * @throws ContainerExceptionInterface | ||
| 140 | + * @throws NotFoundExceptionInterface | ||
| 141 | + */ | ||
| 142 | + public function getServerInfo(int $deleted = ServerInformation::DELETED_NORMAL) | ||
| 143 | + { | ||
| 144 | + $serverInformationLogic = new ServerInformationLogic(); | ||
| 145 | + $data = $serverInformationLogic->serverInfo($deleted); | ||
| 146 | + if (!$data) { | ||
| 147 | + return $this->response('服务器信息不存在', Code::USER_ERROR); | ||
| 148 | + } | ||
| 149 | + return $this->success($data->toArray()); | ||
| 150 | + } | ||
| 151 | + | ||
| 152 | + /** | ||
| 153 | + * @return JsonResponse | ||
| 154 | + * @throws AsideGlobalException | ||
| 155 | + * @throws BsideGlobalException | ||
| 156 | + * @throws ContainerExceptionInterface | ||
| 157 | + * @throws NotFoundExceptionInterface | ||
| 158 | + */ | ||
| 159 | + public function getDeleteServerInfo() | ||
| 160 | + { | ||
| 161 | + return $this->getServerInfo(ServerInformation::DELETED_DELETE); | ||
| 162 | + } | ||
| 163 | + | ||
| 164 | + | ||
| 165 | +} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Controllers\Aside\Devops; | ||
| 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\Devops\ServerInformationLogic; | ||
| 10 | +use App\Http\Requests\Aside\Devops\ServerInformationRequest; | ||
| 11 | +use App\Models\Devops\ServerInformation; | ||
| 12 | +use App\Models\Devops\ServerInformationLog; | ||
| 13 | +use Illuminate\Http\JsonResponse; | ||
| 14 | +use Illuminate\Http\Request; | ||
| 15 | +use Illuminate\Support\Facades\DB; | ||
| 16 | +use Psr\Container\ContainerExceptionInterface; | ||
| 17 | +use Psr\Container\NotFoundExceptionInterface; | ||
| 18 | + | ||
| 19 | +class ServerInformationLogController extends BaseController | ||
| 20 | +{ | ||
| 21 | + public function lists(Request $request) | ||
| 22 | + { | ||
| 23 | + $size = $request->input('size', $this->row); | ||
| 24 | + $data = ServerInformationLog::query() | ||
| 25 | + ->orderBy('id', 'desc') | ||
| 26 | + ->paginate($size); | ||
| 27 | + return $this->response('success', Code::SUCCESS, $data); | ||
| 28 | + | ||
| 29 | + } | ||
| 30 | +} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Controllers\Aside\Template; | ||
| 4 | + | ||
| 5 | +use App\Http\Controllers\Aside\BaseController; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * 模板header footer | ||
| 9 | + * @author:dc | ||
| 10 | + * @time 2023/4/26 11:10 | ||
| 11 | + * Class HeaderFooterController | ||
| 12 | + * @package App\Http\Controllers\Aside\Template | ||
| 13 | + */ | ||
| 14 | +class HeaderFooterController extends BaseController | ||
| 15 | +{ | ||
| 16 | + | ||
| 17 | +} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Controllers\Bside\Template; | ||
| 4 | + | ||
| 5 | +use App\Http\Controllers\Bside\BaseController; | ||
| 6 | + | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * 模板header footer | ||
| 10 | + * @author:dc | ||
| 11 | + * @time 2023/4/26 11:10 | ||
| 12 | + * Class HeaderFooterController | ||
| 13 | + * @package App\Http\Controllers\Bside\Template | ||
| 14 | + */ | ||
| 15 | +class HeaderFooterController extends BaseController | ||
| 16 | +{ | ||
| 17 | + | ||
| 18 | +} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Logic\Aside\Devops; | ||
| 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\Devops\ServerInformation; | ||
| 11 | +use App\Models\Devops\ServerInformationLog; | ||
| 12 | +use Illuminate\Database\Eloquent\Builder; | ||
| 13 | +use Illuminate\Database\Eloquent\Collection; | ||
| 14 | +use Illuminate\Database\Eloquent\Model; | ||
| 15 | +use Illuminate\Http\JsonResponse; | ||
| 16 | +use Illuminate\Support\Facades\DB; | ||
| 17 | +use Illuminate\Support\Facades\Log; | ||
| 18 | + | ||
| 19 | +class ServerInformationLogic extends BaseLogic | ||
| 20 | +{ | ||
| 21 | + /** | ||
| 22 | + * @var array | ||
| 23 | + */ | ||
| 24 | + private $param; | ||
| 25 | + | ||
| 26 | + public function __construct() | ||
| 27 | + { | ||
| 28 | + parent::__construct(); | ||
| 29 | + | ||
| 30 | + $this->model = new ServerInformation(); | ||
| 31 | + | ||
| 32 | + $this->param = $this->requestAll; | ||
| 33 | + | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * 添加数据 | ||
| 38 | + * @return array | ||
| 39 | + * @throws AsideGlobalException | ||
| 40 | + * @throws BsideGlobalException | ||
| 41 | + */ | ||
| 42 | + public function create() | ||
| 43 | + { | ||
| 44 | + $request = $this->param; | ||
| 45 | + $service = new ServerInformation(); | ||
| 46 | + $this->extracted($request, $service); | ||
| 47 | + if ($this->checkIp($service->ip)) { | ||
| 48 | + return $this->fail('服务器信息添加失败,ip已存在'); | ||
| 49 | + } | ||
| 50 | + DB::beginTransaction(); | ||
| 51 | + | ||
| 52 | + if ($service->save()) { | ||
| 53 | + $original = [ | ||
| 54 | + 'id' => $service->id, | ||
| 55 | + 'type' => $service->type, | ||
| 56 | + 'ip' => $service->ip, | ||
| 57 | + 'title' => $service->title, | ||
| 58 | + 'belong_to' => $service->belong_to, | ||
| 59 | + 'sshpass' => $service->sshpass, | ||
| 60 | + 'ports' => $service->ports, | ||
| 61 | + ]; | ||
| 62 | + // 添加日志 | ||
| 63 | + $this->server_action_log(ServerInformationLog::ACTION_ADD, $original, $original, '添加服务器信息成功 - ID : ' . $service->id); | ||
| 64 | + DB::commit(); | ||
| 65 | + return $this->success(); | ||
| 66 | + } | ||
| 67 | + DB::rollBack(); | ||
| 68 | + return $this->fail('服务器信息添加失败'); | ||
| 69 | + | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + /** | ||
| 73 | + * 修改数据 | ||
| 74 | + * @return array | ||
| 75 | + * @throws AsideGlobalException | ||
| 76 | + * @throws BsideGlobalException | ||
| 77 | + */ | ||
| 78 | + public function update() | ||
| 79 | + { | ||
| 80 | + | ||
| 81 | + $service = new ServerInformation(); | ||
| 82 | + $fields_array = $service->FieldsArray(); | ||
| 83 | + $request = $this->param; | ||
| 84 | + $service = $this->ServerInfo(); | ||
| 85 | + $original = $service->toArray(); | ||
| 86 | + $this->extracted($request, $service); | ||
| 87 | + | ||
| 88 | + // 检查ip是否存在 | ||
| 89 | + if ($service->ip != $request['ip']) { | ||
| 90 | + if ($this->checkIp($request['ip'])) { | ||
| 91 | + $this->fail('服务器信息修改失败,ip已存在', Code::USER_ERROR); | ||
| 92 | + } | ||
| 93 | + } | ||
| 94 | + DB::beginTransaction(); | ||
| 95 | + if ($service->save()) { | ||
| 96 | + $revised = [ | ||
| 97 | + 'id' => $service->id, | ||
| 98 | + 'type' => $service->type, | ||
| 99 | + 'ip' => $service->ip, | ||
| 100 | + 'title' => $service->title, | ||
| 101 | + 'belong_to' => $service->belong_to, | ||
| 102 | + 'sshpass' => $service->sshpass, | ||
| 103 | + 'ports' => $service->ports, | ||
| 104 | + 'other' => $service->other, | ||
| 105 | + 'delete' => $service->delete, | ||
| 106 | + ]; | ||
| 107 | + $diff = array_diff_assoc($original, $revised); | ||
| 108 | + unset($diff['create_at']); | ||
| 109 | + unset($diff['update_at']); | ||
| 110 | + unset($diff['deleted']); | ||
| 111 | + $remarks = ''; | ||
| 112 | + if ($diff) { | ||
| 113 | + $remarks .= '修改ID为 ' . $service->id . ' 的服务器信息,修改内容为:'; | ||
| 114 | + foreach ($diff as $key => $value) { | ||
| 115 | + $remarks .= $fields_array[$key] . ' 由 ' . $value . ' 修改为 ' . $revised[$key] . '; '; | ||
| 116 | + } | ||
| 117 | + } | ||
| 118 | + // 添加日志 | ||
| 119 | + $this->server_action_log(ServerInformationLog::ACTION_UPDATE, $original, $revised, $remarks); | ||
| 120 | + DB::commit(); | ||
| 121 | + return $this->success(); | ||
| 122 | + } | ||
| 123 | + DB::rollBack(); | ||
| 124 | + return $this->fail('服务器信息修改失败'); | ||
| 125 | + } | ||
| 126 | + | ||
| 127 | + /** | ||
| 128 | + * 检查ip是否存在 | ||
| 129 | + * @param $ip | ||
| 130 | + * @return bool | ||
| 131 | + */ | ||
| 132 | + public function checkIp($ip) | ||
| 133 | + { | ||
| 134 | + $usIp = ServerInformation::query()->where('ip', $ip)->first(); | ||
| 135 | + if ($usIp) { | ||
| 136 | + return true; | ||
| 137 | + } else { | ||
| 138 | + return false; | ||
| 139 | + } | ||
| 140 | + } | ||
| 141 | + | ||
| 142 | + /** | ||
| 143 | + * 详情 | ||
| 144 | + * @param int $deleted | ||
| 145 | + * @return array|Builder|Collection|Model | ||
| 146 | + * @throws AsideGlobalException | ||
| 147 | + * @throws BsideGlobalException | ||
| 148 | + */ | ||
| 149 | + public function serverInfo(int $deleted = ServerInformation::DELETED_NORMAL) | ||
| 150 | + { | ||
| 151 | + $id = \request()->input('id'); | ||
| 152 | + if (!$id) { | ||
| 153 | + return $this->fail('参数错误'); | ||
| 154 | + } | ||
| 155 | + $data = ServerInformation::query()->where('deleted', $deleted)->find($id, ['type', 'ip', 'title', 'belong_to', 'sshpass', 'ports', 'create_at', 'update_at']); | ||
| 156 | + if (!$data) { | ||
| 157 | + return $this->fail('数据不存在!'); | ||
| 158 | + } | ||
| 159 | + return $data; | ||
| 160 | + } | ||
| 161 | + | ||
| 162 | + /** | ||
| 163 | + * 服务器操作日志 | ||
| 164 | + * @param int $action 1:添加 2:修改 3:删除 4:搜索 5:详情 6:列表 | ||
| 165 | + * @param array $original 原始数据 | ||
| 166 | + * @param array $revised 修改后数据 | ||
| 167 | + */ | ||
| 168 | + public function server_action_log(int $action = ServerInformationLog::ACTION_ADD, array $original = [], array $revised = [], $remarks = '') | ||
| 169 | + { | ||
| 170 | + // $action 1:添加 2:修改 3:删除 4:恢复 | ||
| 171 | + $actionArr = ServerInformationLog::actionArr(); | ||
| 172 | + $actionStr = $actionArr[$action]; | ||
| 173 | + $ip = request()->getClientIp(); | ||
| 174 | + $url = request()->getRequestUri(); | ||
| 175 | + $method = request()->getMethod(); | ||
| 176 | + $userId = $this->uid ?? 0; | ||
| 177 | + $log = new ServerInformationLog(); | ||
| 178 | + $log->user_id = $userId; | ||
| 179 | + $log->action = $actionStr; | ||
| 180 | + $log->original = json_encode($original); | ||
| 181 | + $log->revised = json_encode($revised); | ||
| 182 | + $log->ip = $ip; | ||
| 183 | + $log->url = $url; | ||
| 184 | + $log->method = $method; | ||
| 185 | + $log->remarks = $remarks; | ||
| 186 | + DB::beginTransaction(); | ||
| 187 | + try { | ||
| 188 | + $log->save(); | ||
| 189 | + DB::commit(); | ||
| 190 | + } catch (\Exception $e) { | ||
| 191 | + DB::rollBack(); | ||
| 192 | + Log::error('服务器信息日志添加失败'); | ||
| 193 | + } | ||
| 194 | + } | ||
| 195 | + | ||
| 196 | + /** | ||
| 197 | + * @param array $request | ||
| 198 | + * @param $service | ||
| 199 | + * @return void | ||
| 200 | + */ | ||
| 201 | + public function extracted(array $request, $service) | ||
| 202 | + { | ||
| 203 | + $service->type = trim($request['type']); // 服务器类型 | ||
| 204 | + $service->ip = trim($request['ip']); // 服务器ip | ||
| 205 | + $service->title = trim($request['title']); // 服务器标题 | ||
| 206 | + $service->belong_to = trim($request['belong_to']); // 服务器归属 | ||
| 207 | + $service->sshpass = trim($request['sshpass']); // ssh密码 | ||
| 208 | + $service->ports = trim($request['ports']); // ssh端口 | ||
| 209 | + } | ||
| 210 | + | ||
| 211 | + /** | ||
| 212 | + * 批量获取数据删除 | ||
| 213 | + * @return array | ||
| 214 | + * @throws AsideGlobalException | ||
| 215 | + * @throws BsideGlobalException | ||
| 216 | + */ | ||
| 217 | + public function get_batch_update($action = ServerInformationLog::ACTION_DELETE, $deleted = ServerInformation::DELETED_NORMAL) | ||
| 218 | + { | ||
| 219 | + $id = request()->input('id'); | ||
| 220 | + if (!$id) { | ||
| 221 | + return $this->fail('参数错误'); | ||
| 222 | + } | ||
| 223 | + $ids = []; | ||
| 224 | + if (!is_array($id)) { | ||
| 225 | + $ids = explode(',', $id); | ||
| 226 | + } | ||
| 227 | + $ids = array_filter($ids, 'intval'); | ||
| 228 | + if (empty($ids)) { | ||
| 229 | + return $this->fail('参数错误'); | ||
| 230 | + } | ||
| 231 | + $data = ServerInformation::query()->whereIn('id', $ids)->where('deleted', $deleted)->get(); | ||
| 232 | + $restore_ids = $data->pluck('id')->toArray(); | ||
| 233 | + $actionArr = ServerInformationLog::actionArr(); | ||
| 234 | + $actionStr = $actionArr[$action]; | ||
| 235 | + if (empty($restore_ids)) { | ||
| 236 | + $this->fail($actionStr . '服务器信息不存在!', Code::USER_ERROR); | ||
| 237 | + } | ||
| 238 | + $original = $data->toArray(); | ||
| 239 | + DB::beginTransaction(); | ||
| 240 | + try { | ||
| 241 | + $update = $deleted == ServerInformation::DELETED_NORMAL ? ServerInformation::DELETED_DELETE : ServerInformation::DELETED_NORMAL; | ||
| 242 | + ServerInformation::query()->whereIn('id', $restore_ids)->update(['deleted' => $update]); | ||
| 243 | + $this->server_action_log($action, $original, $original, $actionStr . '服务器信息 - ID : ' . implode(', ', $restore_ids)); | ||
| 244 | + DB::commit(); | ||
| 245 | + return $this->success(); | ||
| 246 | + } catch (\Exception $e) { | ||
| 247 | + DB::rollBack(); | ||
| 248 | + return $this->fail('服务器信息' . $actionStr . '失败', Code::USER_ERROR); | ||
| 249 | + } | ||
| 250 | + } | ||
| 251 | +} |
| @@ -96,6 +96,7 @@ class RankDataLogic extends BaseLogic | @@ -96,6 +96,7 @@ class RankDataLogic extends BaseLogic | ||
| 96 | ]; | 96 | ]; |
| 97 | 97 | ||
| 98 | //外链引荐域名 | 98 | //外链引荐域名 |
| 99 | + $recomm_domain = $recomm_domain ? $recomm_domain->toArray() : []; | ||
| 99 | $data['external_links_domain_chat'] = [ | 100 | $data['external_links_domain_chat'] = [ |
| 100 | 'labels' => array_map(function ($item) { | 101 | 'labels' => array_map(function ($item) { |
| 101 | return Str::substrReplace($item, '***', 2, 3); | 102 | return Str::substrReplace($item, '***', 2, 3); |
| @@ -120,8 +121,8 @@ class RankDataLogic extends BaseLogic | @@ -120,8 +121,8 @@ class RankDataLogic extends BaseLogic | ||
| 120 | } | 121 | } |
| 121 | //关键词排名分析图 | 122 | //关键词排名分析图 |
| 122 | $data['rank_chat'] = [ | 123 | $data['rank_chat'] = [ |
| 123 | - 'data' => $rank_week['data'], | ||
| 124 | - 'labels' => $rank_week['date'], | 124 | + 'data' => $rank_week['data'] ?? [], |
| 125 | + 'labels' => $rank_week['date'] ?? [], | ||
| 125 | ]; | 126 | ]; |
| 126 | 127 | ||
| 127 | return $data; | 128 | return $data; |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Requests\Aside\Devops; | ||
| 4 | + | ||
| 5 | +use App\Models\Devops\ServerInformation; | ||
| 6 | +use Illuminate\Foundation\Http\FormRequest; | ||
| 7 | +use Illuminate\Validation\Rule; | ||
| 8 | + | ||
| 9 | +class ServerInformationRequest extends FormRequest | ||
| 10 | +{ | ||
| 11 | + /** | ||
| 12 | + * Determine if the user is authorized to make this request. | ||
| 13 | + * | ||
| 14 | + * @return bool | ||
| 15 | + */ | ||
| 16 | + public function authorize() | ||
| 17 | + { | ||
| 18 | + return true; | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + /** | ||
| 22 | + * Get the validation rules that apply to the request. | ||
| 23 | + * | ||
| 24 | + * @return array | ||
| 25 | + */ | ||
| 26 | + public function rules() | ||
| 27 | + { | ||
| 28 | + return [ | ||
| 29 | + 'type' => [ 'required', Rule::in( array_keys( ( new ServerInformation )->ServiceArray() ) ) ], | ||
| 30 | + 'ip' => 'required|ip', | ||
| 31 | + 'title' => 'required|max:200', | ||
| 32 | + 'belong_to' => 'required|integer|in:1,2', // 1:公司 2:客户 | ||
| 33 | + 'sshpass' => 'required|max:100', | ||
| 34 | + 'ports' => 'required|integer|min:1|max:65535', | ||
| 35 | + ]; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + public function messages() | ||
| 39 | + { | ||
| 40 | + $service_array = ( new ServerInformation )->ServiceArray(); | ||
| 41 | + $serviceStr = implode( ', ', $service_array ); | ||
| 42 | + return [ | ||
| 43 | + 'type.required' => '服务器类型不能为空', | ||
| 44 | + 'type.integer' => '服务器类型格式不正确', | ||
| 45 | + 'type.between' => '服务器类型 ' . $serviceStr, | ||
| 46 | + 'ip.required' => 'ip不能为空', | ||
| 47 | + 'ip.ip' => 'ip格式不正确', | ||
| 48 | + 'title.required' => '服务器标题不能为空', | ||
| 49 | + 'title.max' => '服务器标题不能超过200个字符', | ||
| 50 | + 'belong_to.required' => '服务器归属不能为空', | ||
| 51 | + 'belong_to.integer' => '服务器归属格式不正确', | ||
| 52 | + 'belong_to.in' => '服务器归属只能是公司或者客户', | ||
| 53 | + 'sshpass.required' => 'ssh密码不能为空', | ||
| 54 | + 'sshpass.max' => 'ssh密码不能超过100个字符', | ||
| 55 | + 'ports.required' => 'ssh端口不能为空', | ||
| 56 | + 'ports.integer' => 'ssh端口格式不正确', | ||
| 57 | + 'ports.min' => 'ssh端口不能小于1', | ||
| 58 | + 'ports.max' => 'ssh端口不能大于65535', | ||
| 59 | + ]; | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | +} |
app/Models/Aside/TemplateHeaderFooter.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Models\Aside; | ||
| 4 | + | ||
| 5 | +use App\Models\Base; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * 模板 头部底部 对所有 客户 | ||
| 9 | + * @author:dc | ||
| 10 | + * @time 2023/4/26 11:21 | ||
| 11 | + * Class TemplateHeaderFooter | ||
| 12 | + * @package App\Models\Aside | ||
| 13 | + */ | ||
| 14 | +class TemplateHeaderFooter extends Base | ||
| 15 | +{ | ||
| 16 | + protected $table = 'gl_aside_template_header_footer'; | ||
| 17 | +} |
app/Models/Bside/TemplateHeaderFooter.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Models\Bside; | ||
| 4 | + | ||
| 5 | +use App\Models\Base; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * 模板 头部底部 客户自己的 | ||
| 9 | + * @author:dc | ||
| 10 | + * @time 2023/4/26 11:21 | ||
| 11 | + * Class TemplateHeaderFooter | ||
| 12 | + * @package App\Models\Bside | ||
| 13 | + */ | ||
| 14 | +class TemplateHeaderFooter extends Base | ||
| 15 | +{ | ||
| 16 | + protected $table = 'gl_bside_template_header_footer'; | ||
| 17 | +} |
app/Models/Devops/ServerInformation.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Models\Devops; | ||
| 4 | + | ||
| 5 | +use Illuminate\Database\Eloquent\Model; | ||
| 6 | + | ||
| 7 | +class ServerInformation extends Model | ||
| 8 | +{ | ||
| 9 | + | ||
| 10 | + protected $table = 'gl_server_information'; | ||
| 11 | + const CREATED_AT = 'create_at'; | ||
| 12 | + const UPDATED_AT = 'update_at'; | ||
| 13 | + | ||
| 14 | + // 软删除 0:正常 1:删除 | ||
| 15 | + const DELETED_NORMAL = 0; | ||
| 16 | + const DELETED_DELETE = 1; | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + /** | ||
| 20 | + * @param $num | ||
| 21 | + * | ||
| 22 | + * @return string | ||
| 23 | + */ | ||
| 24 | + public function Service($num) | ||
| 25 | + { | ||
| 26 | + return $this->ServiceArray()[$num]; | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * @return array | ||
| 31 | + */ | ||
| 32 | + public function ServiceArray() | ||
| 33 | + { | ||
| 34 | + return [ | ||
| 35 | + 1 => '阿里云', | ||
| 36 | + 2 => '腾讯云', | ||
| 37 | + 3 => 'linode', | ||
| 38 | + 4 => '尊云', | ||
| 39 | + 5 => '互联', | ||
| 40 | + 6 => '其他', | ||
| 41 | + 7 => 'Ramnode', | ||
| 42 | + 8 => 'CN2-SSD美国', | ||
| 43 | + 9 => '国内测试服务器', | ||
| 44 | + ]; | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + /** | ||
| 48 | + * 字段信息 | ||
| 49 | + * @return array | ||
| 50 | + */ | ||
| 51 | + public function FieldsArray() | ||
| 52 | + { | ||
| 53 | + return [ | ||
| 54 | + 'type' => '服务器类型', | ||
| 55 | + 'ip' => '服务器IP', | ||
| 56 | + 'title' => '服务器标题', | ||
| 57 | + 'belong_to' => '服务器归属', | ||
| 58 | + 'sshpass' => 'SSH 密码', | ||
| 59 | + 'ports' => 'SSH 端口', | ||
| 60 | + 'other' => '其他信息 json格式', | ||
| 61 | + ]; | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + /** | ||
| 65 | + * 服务器归属信息 | ||
| 66 | + * @return array | ||
| 67 | + */ | ||
| 68 | + public function BelongToArray() | ||
| 69 | + { | ||
| 70 | + return [ | ||
| 71 | + 1 => '公司', | ||
| 72 | + 2 => '客户', | ||
| 73 | + ]; | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + public function BelongTo($num) | ||
| 77 | + { | ||
| 78 | + return $this->BelongToArray()[$num]; | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + /** | ||
| 82 | + * 返回服务器类型 | ||
| 83 | + * @param $value | ||
| 84 | + * | ||
| 85 | + * @return string | ||
| 86 | + */ | ||
| 87 | + public function getTypeAttribute($value) | ||
| 88 | + { | ||
| 89 | + return $this->Service($value); | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + /** | ||
| 93 | + * 返回服务器归属 | ||
| 94 | + * @param $value | ||
| 95 | + * | ||
| 96 | + * @return string | ||
| 97 | + */ | ||
| 98 | + public function getBelongToAttribute($value) | ||
| 99 | + { | ||
| 100 | + return $this->BelongTo($value); | ||
| 101 | + } | ||
| 102 | +} |
app/Models/Devops/ServerInformationLog.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Models\Devops; | ||
| 4 | + | ||
| 5 | +use Illuminate\Database\Eloquent\Model; | ||
| 6 | + | ||
| 7 | +class ServerInformationLog extends Model | ||
| 8 | +{ | ||
| 9 | + protected $table = 'gl_server_information_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 | +} |
composer.lock
0 → 100644
此 diff 太大无法显示。
| @@ -4,6 +4,7 @@ | @@ -4,6 +4,7 @@ | ||
| 4 | */ | 4 | */ |
| 5 | use \Illuminate\Support\Facades\Route; | 5 | use \Illuminate\Support\Facades\Route; |
| 6 | use \App\Http\Controllers\Aside; | 6 | use \App\Http\Controllers\Aside; |
| 7 | + | ||
| 7 | //必须登录验证的路由组 | 8 | //必须登录验证的路由组 |
| 8 | Route::middleware(['web'])->group(function (){ //admin用渲染默认要加上web的中间件 | 9 | Route::middleware(['web'])->group(function (){ //admin用渲染默认要加上web的中间件 |
| 9 | Route::middleware(['aloginauth'])->group(function () { | 10 | Route::middleware(['aloginauth'])->group(function () { |
| @@ -123,6 +124,21 @@ Route::middleware(['web'])->group(function (){ //admin用渲染默认要加上w | @@ -123,6 +124,21 @@ Route::middleware(['web'])->group(function (){ //admin用渲染默认要加上w | ||
| 123 | Route::post('/update_database', [Aside\Devops\ServerConfigController::class, 'updateDatabase'])->name('admin.devops.server_config.update_database'); | 124 | Route::post('/update_database', [Aside\Devops\ServerConfigController::class, 'updateDatabase'])->name('admin.devops.server_config.update_database'); |
| 124 | Route::post('/update_code', [Aside\Devops\ServerConfigController::class, 'updateCode'])->name('admin.devops.server_config.update_code'); | 125 | Route::post('/update_code', [Aside\Devops\ServerConfigController::class, 'updateCode'])->name('admin.devops.server_config.update_code'); |
| 125 | }); | 126 | }); |
| 127 | + | ||
| 128 | + // 服务器添加|修改|删除 | ||
| 129 | + Route::prefix('server')->group(function () { | ||
| 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'); // 获取信息 | ||
| 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'); // 添加 | ||
| 134 | + Route::post('/edit', [Aside\Devops\ServerInformationController::class, 'edit'])->name('admin.devops.bt_edit'); // 修改 | ||
| 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'); // 删除列表 | ||
| 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'); //日志列表 | ||
| 140 | + }); | ||
| 141 | + | ||
| 126 | }); | 142 | }); |
| 127 | 143 | ||
| 128 | // 自定义页面 模板,头部底部 | 144 | // 自定义页面 模板,头部底部 |
-
请 注册 或 登录 后发表评论