合并分支 'master-lyh-edit' 到 'master'
更新项目搜索+新功能服务器管理 查看合并请求 !627
正在显示
9 个修改的文件
包含
426 行增加
和
2 行删除
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :ServersController.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2024/6/24 16:18 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Http\Controllers\Aside\Devops; | ||
| 11 | + | ||
| 12 | +use App\Enums\Common\Code; | ||
| 13 | +use App\Http\Controllers\Aside\BaseController; | ||
| 14 | +use App\Http\Logic\Aside\Devops\ServersLogic; | ||
| 15 | +use App\Models\Devops\Servers; | ||
| 16 | +use App\Models\Devops\Servers as ServersModel; | ||
| 17 | +use App\Models\Devops\ServersIp; | ||
| 18 | + | ||
| 19 | +class ServersController extends BaseController | ||
| 20 | +{ | ||
| 21 | + /** | ||
| 22 | + * @remark :获取服务器列表 | ||
| 23 | + * @name :serverList | ||
| 24 | + * @author :lyh | ||
| 25 | + * @method :post | ||
| 26 | + * @time :2024/6/24 17:47 | ||
| 27 | + */ | ||
| 28 | + public function serverList(){ | ||
| 29 | + $serversIpModel = new ServersIp(); | ||
| 30 | + $query = $serversIpModel->leftJoin('gl_servers', 'gl_servers_ip.servers_id', '=', 'gl_servers.id'); | ||
| 31 | + $query = $this->searchParam($query); | ||
| 32 | + $lists = $query->paginate($this->row, $this->selectParam(), 'page', $this->page)->toArray(); | ||
| 33 | + $this->response('success',Code::SUCCESS,$lists); | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * @remark :查询列表 | ||
| 38 | + * @name :selectParam | ||
| 39 | + * @author :lyh | ||
| 40 | + * @method :post | ||
| 41 | + * @time :2024/6/25 9:33 | ||
| 42 | + */ | ||
| 43 | + public function selectParam(){ | ||
| 44 | + $select = [ | ||
| 45 | + 'gl_servers_ip.id AS id', | ||
| 46 | + 'gl_servers_ip.ip AS ip', | ||
| 47 | + 'gl_servers_ip.domain AS domain', | ||
| 48 | + 'gl_servers.server_name AS server_name', | ||
| 49 | + 'gl_servers.total AS total', | ||
| 50 | + 'gl_servers.being_number AS being_number', | ||
| 51 | + ]; | ||
| 52 | + return $select; | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + /** | ||
| 56 | + * @remark :服务器名称搜索 | ||
| 57 | + * @name :searchParam | ||
| 58 | + * @author :lyh | ||
| 59 | + * @method :post | ||
| 60 | + * @time :2024/6/25 9:28 | ||
| 61 | + */ | ||
| 62 | + public function searchParam(&$query){ | ||
| 63 | + if(isset($this->param['server_name'])){ | ||
| 64 | + $query->where('gl_servers.server_name','like','%'.$this->param['server_name'].'%'); | ||
| 65 | + } | ||
| 66 | + return $query; | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + /** | ||
| 70 | + * @remark :服务器列表 | ||
| 71 | + * @name :lists | ||
| 72 | + * @author :lyh | ||
| 73 | + * @method :post | ||
| 74 | + * @time :2024/6/24 16:25 | ||
| 75 | + */ | ||
| 76 | + public function lists(){ | ||
| 77 | + if(isset($this->map['server_name']) && !empty($this->map['server_name'])){ | ||
| 78 | + $this->map['server_name'] = ['like','%'.$this->map['server_name'].'%']; | ||
| 79 | + } | ||
| 80 | + $serversModel = new ServersModel(); | ||
| 81 | + $data = $serversModel->lists($this->map,$this->page,$this->row,$this->order); | ||
| 82 | + $this->response('success',Code::SUCCESS,$data); | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + /** | ||
| 86 | + * @remark :获取详情 | ||
| 87 | + * @name :Info | ||
| 88 | + * @author :lyh | ||
| 89 | + * @method :post | ||
| 90 | + * @time :2024/6/24 17:05 | ||
| 91 | + */ | ||
| 92 | + public function info(ServersLogic $serversLogic){ | ||
| 93 | + $this->request->validate([ | ||
| 94 | + 'id'=>'required' | ||
| 95 | + ],[ | ||
| 96 | + 'id.required' => '主键不能为空' | ||
| 97 | + | ||
| 98 | + ]); | ||
| 99 | + $data = $serversLogic->infoServers(); | ||
| 100 | + $this->response('success',Code::SUCCESS,$data); | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + /** | ||
| 104 | + * @remark :保存数据 | ||
| 105 | + * @name :save | ||
| 106 | + * @author :lyh | ||
| 107 | + * @method :post | ||
| 108 | + * @time :2024/6/24 16:25 | ||
| 109 | + */ | ||
| 110 | + public function save(ServersLogic $serversLogic){ | ||
| 111 | + $this->request->validate([ | ||
| 112 | + 'server_name'=>'required', | ||
| 113 | + 'service_type'=>'required', | ||
| 114 | + 'total'=>'required', | ||
| 115 | + 'account'=>'required', | ||
| 116 | + 'password'=>'required', | ||
| 117 | + 'port'=>'required' | ||
| 118 | + ],[ | ||
| 119 | + 'server_name.required' => '服务器名称server_name不能为空', | ||
| 120 | + 'service_type.required' => '服务器类型不能为空', | ||
| 121 | + 'total.required' => '总数不能为空', | ||
| 122 | + 'account.required' => '账号不能为空', | ||
| 123 | + 'password.required' => '密码不能为空', | ||
| 124 | + 'port.required' => '端口不能为空' | ||
| 125 | + ]); | ||
| 126 | + $data = $serversLogic->saveServers(); | ||
| 127 | + $this->response('success',Code::SUCCESS,$data); | ||
| 128 | + } | ||
| 129 | +} |
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :ServersIpController.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2024/6/24 16:23 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Http\Controllers\Aside\Devops; | ||
| 11 | + | ||
| 12 | +use App\Enums\Common\Code; | ||
| 13 | +use App\Http\Controllers\Aside\BaseController; | ||
| 14 | +use App\Http\Logic\Aside\Devops\ServersIpLogic; | ||
| 15 | +use App\Models\Devops\ServersIp as ServersIpModel; | ||
| 16 | + | ||
| 17 | +class ServersIpController extends BaseController | ||
| 18 | +{ | ||
| 19 | + /** | ||
| 20 | + * @remark :当前服务器器对应的ip列表 | ||
| 21 | + * @name :list | ||
| 22 | + * @author :lyh | ||
| 23 | + * @method :post | ||
| 24 | + * @time :2024/6/24 16:23 | ||
| 25 | + */ | ||
| 26 | + public function lists(){ | ||
| 27 | + $this->request->validate([ | ||
| 28 | + 'servers_id'=>'required' | ||
| 29 | + ],[ | ||
| 30 | + 'servers_id.required' => '服务器servers_id不能为空' | ||
| 31 | + ]); | ||
| 32 | + $serversIpModel = new ServersIpModel(); | ||
| 33 | + $data = $serversIpModel->lists($this->map,$this->page,$this->row,$this->order); | ||
| 34 | + $this->response('success',Code::SUCCESS,$data); | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * @remark :保存数据 | ||
| 40 | + * @name :save | ||
| 41 | + * @author :lyh | ||
| 42 | + * @method :post | ||
| 43 | + * @time :2024/6/24 16:24 | ||
| 44 | + */ | ||
| 45 | + public function save(ServersIpLogic $serversIpLogic){ | ||
| 46 | + $this->request->validate([ | ||
| 47 | + 'ip'=>'required', | ||
| 48 | + 'servers_id'=>'required', | ||
| 49 | + 'domain'=>'required' | ||
| 50 | + ],[ | ||
| 51 | + 'ip.required' => 'ip不能为空', | ||
| 52 | + 'servers_id.required' => '服务器servers_id不能为空', | ||
| 53 | + 'domain.required' => 'cname域名不能为空', | ||
| 54 | + ]); | ||
| 55 | + $data = $serversIpLogic->saveServersIp(); | ||
| 56 | + $this->response('success',Code::SUCCESS,$data); | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + /** | ||
| 60 | + * @remark :批量保存ip_domain | ||
| 61 | + * @name :batchSave | ||
| 62 | + * @author :lyh | ||
| 63 | + * @method :post | ||
| 64 | + * @time :2024/6/24 17:23 | ||
| 65 | + */ | ||
| 66 | + public function batchSave(ServersIpLogic $serversIpLogic){ | ||
| 67 | + $this->request->validate([ | ||
| 68 | + 'data'=>'required', | ||
| 69 | + 'servers_id'=>'required', | ||
| 70 | + ],[ | ||
| 71 | + 'data.required' => 'data集合不能为空', | ||
| 72 | + 'servers_id.required' => '服务器servers_id不能为空', | ||
| 73 | + ]); | ||
| 74 | + $data = $serversIpLogic->batchSaveServersIp(); | ||
| 75 | + $this->response('success',Code::SUCCESS,$data); | ||
| 76 | + } | ||
| 77 | +} |
| @@ -87,6 +87,7 @@ class ProjectController extends BaseController | @@ -87,6 +87,7 @@ class ProjectController extends BaseController | ||
| 87 | 'gl_project.channel AS channel', | 87 | 'gl_project.channel AS channel', |
| 88 | 'gl_project.company AS company', | 88 | 'gl_project.company AS company', |
| 89 | 'gl_project.type AS type', | 89 | 'gl_project.type AS type', |
| 90 | + 'gl_project.extend_type AS extend_type', | ||
| 90 | 'gl_project.uptime AS uptime', | 91 | 'gl_project.uptime AS uptime', |
| 91 | 'gl_project.is_upgrade AS is_upgrade', | 92 | 'gl_project.is_upgrade AS is_upgrade', |
| 92 | 'gl_project.created_at AS created_at', | 93 | 'gl_project.created_at AS created_at', |
| @@ -173,6 +174,7 @@ class ProjectController extends BaseController | @@ -173,6 +174,7 @@ class ProjectController extends BaseController | ||
| 173 | else{ | 174 | else{ |
| 174 | $query->whereIn('gl_project.type', [Project::TYPE_FOUR,Project::TYPE_SIX]); | 175 | $query->whereIn('gl_project.type', [Project::TYPE_FOUR,Project::TYPE_SIX]); |
| 175 | } | 176 | } |
| 177 | + $query->where('gl_project.extend_type', '!=' ,5); | ||
| 176 | } | 178 | } |
| 177 | if(isset($this->map['uptime']) && is_array($this->map['uptime'])){ | 179 | if(isset($this->map['uptime']) && is_array($this->map['uptime'])){ |
| 178 | $query->whereBetween('gl_project.uptime', $this->map['uptime']); | 180 | $query->whereBetween('gl_project.uptime', $this->map['uptime']); |
| @@ -604,7 +606,7 @@ class ProjectController extends BaseController | @@ -604,7 +606,7 @@ class ProjectController extends BaseController | ||
| 604 | * @name :getServiceConfig | 606 | * @name :getServiceConfig |
| 605 | * @author :lyh | 607 | * @author :lyh |
| 606 | * @method :post | 608 | * @method :post |
| 607 | - * @time :2023/8/14 10:23 | 609 | + * @time :2023/8/14 10:23 todo::后面删除 |
| 608 | */ | 610 | */ |
| 609 | public function getServiceConfig(){ | 611 | public function getServiceConfig(){ |
| 610 | $serviceConfigModel = new ServerConfig(); | 612 | $serviceConfigModel = new ServerConfig(); |
| @@ -107,7 +107,8 @@ class RenewProjectController extends BaseController | @@ -107,7 +107,8 @@ class RenewProjectController extends BaseController | ||
| 107 | * @time :2023/8/18 14:33 | 107 | * @time :2023/8/18 14:33 |
| 108 | */ | 108 | */ |
| 109 | public function notHaveRenewItems(Project $project){ | 109 | public function notHaveRenewItems(Project $project){ |
| 110 | - $this->map['extend_type'] = $project::TYPE_FIVE;//未续费网站 | 110 | + $this->map['extend_type'] = $project::TYPE_FIVE;//未续费网站 if(!empty($param['search']) && !empty($param['search_type'])){ |
| 111 | + $this->map['title'] = ['like', '%'.$this->map['title'].'title']; | ||
| 111 | $lists = $project->where($this->map)->with('payment')->with('deploy_build') | 112 | $lists = $project->where($this->map)->with('payment')->with('deploy_build') |
| 112 | ->with('deploy_optimize')->with('online_check') | 113 | ->with('deploy_optimize')->with('online_check') |
| 113 | ->with('project_after')->paginate($this->row, ['*'], 'page', $this->page); | 114 | ->with('project_after')->paginate($this->row, ['*'], 'page', $this->page); |
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :ServersIpLogic.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2024/6/24 16:21 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Http\Logic\Aside\Devops; | ||
| 11 | + | ||
| 12 | +use App\Http\Logic\Aside\BaseLogic; | ||
| 13 | +use App\Models\Devops\ServersIp; | ||
| 14 | + | ||
| 15 | +class ServersIpLogic extends BaseLogic | ||
| 16 | +{ | ||
| 17 | + /** | ||
| 18 | + * 数据初始化 | ||
| 19 | + */ | ||
| 20 | + public function __construct() | ||
| 21 | + { | ||
| 22 | + parent::__construct(); | ||
| 23 | + $this->param = $this->requestAll; | ||
| 24 | + $this->model = new ServersIp(); | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + /** | ||
| 28 | + * @remark :保存数据 | ||
| 29 | + * @name :saveServersIp | ||
| 30 | + * @author :lyh | ||
| 31 | + * @method :post | ||
| 32 | + * @time :2024/6/24 17:28 | ||
| 33 | + */ | ||
| 34 | + public function saveServersIp(){ | ||
| 35 | + if(isset($this->param['id']) && !empty($this->param['id'])){ | ||
| 36 | + $id = $this->param['id']; | ||
| 37 | + $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 38 | + }else{ | ||
| 39 | + $id = $this->model->addReturnId($this->param); | ||
| 40 | + } | ||
| 41 | + return $this->success(['id'=>$id]); | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + /** | ||
| 45 | + * @remark :批量添加 | ||
| 46 | + * @name :batchSaveServersIp | ||
| 47 | + * @author :lyh | ||
| 48 | + * @method :post | ||
| 49 | + * @time :2024/6/24 17:25 | ||
| 50 | + */ | ||
| 51 | + public function batchSaveServersIp(){ | ||
| 52 | + $data = []; | ||
| 53 | + foreach ($this->param['data'] as $v){ | ||
| 54 | + if(empty($v['ip']) || empty($v['domain'])){ | ||
| 55 | + continue; | ||
| 56 | + } | ||
| 57 | + $data[] = [ | ||
| 58 | + 'ip'=>$v['ip'], | ||
| 59 | + 'domain'=>$v['domain'], | ||
| 60 | + 'servers_id'=>$this->param['servers_id'] | ||
| 61 | + ]; | ||
| 62 | + } | ||
| 63 | + return $this->addReturnId($data); | ||
| 64 | + } | ||
| 65 | +} |
app/Http/Logic/Aside/Devops/ServersLogic.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :ServersLogic.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2024/6/24 16:19 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Http\Logic\Aside\Devops; | ||
| 11 | + | ||
| 12 | +use App\Http\Logic\Aside\BaseLogic; | ||
| 13 | +use App\Models\Devops\Servers; | ||
| 14 | +use App\Utils\EncryptUtils; | ||
| 15 | + | ||
| 16 | +class ServersLogic extends BaseLogic | ||
| 17 | +{ | ||
| 18 | + /** | ||
| 19 | + * 数据初始化 | ||
| 20 | + */ | ||
| 21 | + public function __construct() | ||
| 22 | + { | ||
| 23 | + parent::__construct(); | ||
| 24 | + $this->param = $this->requestAll; | ||
| 25 | + $this->model = new Servers(); | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + /** | ||
| 29 | + * @remark :获取信息 | ||
| 30 | + * @name :getServiceConfig | ||
| 31 | + * @author :lyh | ||
| 32 | + * @method :post | ||
| 33 | + * @time :2024/6/24 17:05 | ||
| 34 | + */ | ||
| 35 | + public function infoServers(){ | ||
| 36 | + $info = $this->model->read(['id'=>$this->param['id']]); | ||
| 37 | + if($info === false){ | ||
| 38 | + $this->fail('当前数据不存在或者被删除'); | ||
| 39 | + } | ||
| 40 | + return $this->success($info); | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + /** | ||
| 44 | + * @remark :保存数据 | ||
| 45 | + * @name :saveServers | ||
| 46 | + * @author :lyh | ||
| 47 | + * @method :post | ||
| 48 | + * @time :2024/6/24 16:33 | ||
| 49 | + */ | ||
| 50 | + public function saveServers(){ | ||
| 51 | + $encrypt = new EncryptUtils(); | ||
| 52 | + $this->param['account'] = $encrypt->lock_url($this->param['account']); | ||
| 53 | + $this->param['password'] = $encrypt->lock_url($this->param['password']); | ||
| 54 | + $this->param['port'] = $encrypt->lock_url($this->param['port']); | ||
| 55 | + if(isset($this->param['id']) && !empty($this->param['id'])){ | ||
| 56 | + $id = $this->param['id']; | ||
| 57 | + $this->model->edit($this->param,['id'=>$id]); | ||
| 58 | + }else{ | ||
| 59 | + $id = $this->model->addReturnId($this->param); | ||
| 60 | + } | ||
| 61 | + return $this->success(['id'=>$id]); | ||
| 62 | + } | ||
| 63 | +} |
app/Models/Devops/Servers.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :Servers.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2024/6/24 16:19 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Models\Devops; | ||
| 11 | + | ||
| 12 | +use App\Models\Base; | ||
| 13 | +use App\Utils\EncryptUtils; | ||
| 14 | + | ||
| 15 | +class Servers extends Base | ||
| 16 | +{ | ||
| 17 | + protected $table = 'gl_servers'; | ||
| 18 | + const SELF_SITE_ID = 8;//自建站服务器ID | ||
| 19 | + | ||
| 20 | + /** | ||
| 21 | + * @remark :获取数据用户名解密 | ||
| 22 | + * @name :getUserAttribute | ||
| 23 | + * @author :lyh | ||
| 24 | + * @method :post | ||
| 25 | + * @time :2023/9/12 16:05 | ||
| 26 | + */ | ||
| 27 | + public function getAccountAttribute($value){ | ||
| 28 | + return (new EncryptUtils())->unlock_url($value); | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * @remark :密码解密 | ||
| 33 | + * @name :getPasswordAttribute | ||
| 34 | + * @author :lyh | ||
| 35 | + * @method :post | ||
| 36 | + * @time :2023/9/12 16:05 | ||
| 37 | + */ | ||
| 38 | + public function getPasswordAttribute($value){ | ||
| 39 | + return (new EncryptUtils())->unlock_url($value); | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + /** | ||
| 43 | + * @remark :端口解密 | ||
| 44 | + * @name :getPasswordAttribute | ||
| 45 | + * @author :lyh | ||
| 46 | + * @method :post | ||
| 47 | + * @time :2023/9/12 16:05 | ||
| 48 | + */ | ||
| 49 | + public function getPortAttribute($value){ | ||
| 50 | + return (new EncryptUtils())->unlock_url($value); | ||
| 51 | + } | ||
| 52 | +} |
app/Models/Devops/ServersIp.php
0 → 100644
| @@ -428,6 +428,24 @@ Route::middleware(['aloginauth'])->group(function () { | @@ -428,6 +428,24 @@ Route::middleware(['aloginauth'])->group(function () { | ||
| 428 | // 生成页面任务 | 428 | // 生成页面任务 |
| 429 | Route::any('/create_html_task', [Aside\Task\AutoTaskController::class, 'createHtmlTask'])->name('admin.create_html_task'); | 429 | Route::any('/create_html_task', [Aside\Task\AutoTaskController::class, 'createHtmlTask'])->name('admin.create_html_task'); |
| 430 | Route::any('/create_html_param', [Aside\Task\AutoTaskController::class, 'createHtmlTaskParam'])->name('admin.create_html_param'); | 430 | Route::any('/create_html_param', [Aside\Task\AutoTaskController::class, 'createHtmlTaskParam'])->name('admin.create_html_param'); |
| 431 | + | ||
| 432 | + /** | ||
| 433 | + * 服务器管理 | ||
| 434 | + */ | ||
| 435 | + Route::prefix('servers')->group(function () { | ||
| 436 | + Route::any('/', [Aside\Devops\ServersController::class, 'lists'])->name('admin.servers_lists'); | ||
| 437 | + Route::any('/serverList', [Aside\Devops\ServersController::class, 'serverList'])->name('admin.servers_serverList'); | ||
| 438 | + Route::any('/save', [Aside\Devops\ServersController::class, 'save'])->name('admin.servers_save'); | ||
| 439 | + Route::any('/info', [Aside\Devops\ServersController::class, 'info'])->name('admin.servers_info'); | ||
| 440 | + }); | ||
| 441 | + /** | ||
| 442 | + * ip+domain | ||
| 443 | + */ | ||
| 444 | + Route::prefix('servers_ip')->group(function () { | ||
| 445 | + Route::any('/', [Aside\Devops\ServersIpController::class, 'lists'])->name('admin.servers_lists'); | ||
| 446 | + Route::any('/save', [Aside\Devops\ServersIpController::class, 'save'])->name('admin.servers_save'); | ||
| 447 | + Route::any('/info', [Aside\Devops\ServersIpController::class, 'info'])->name('admin.servers_info'); | ||
| 448 | + }); | ||
| 431 | }); | 449 | }); |
| 432 | 450 | ||
| 433 | //无需登录验证的路由组 | 451 | //无需登录验证的路由组 |
-
请 注册 或 登录 后发表评论