Merge branch 'master' of http://47.244.231.31:8099/zhl/globalso-v6
正在显示
5 个修改的文件
包含
144 行增加
和
5 行删除
| @@ -10,10 +10,14 @@ | @@ -10,10 +10,14 @@ | ||
| 10 | namespace App\Http\Controllers\Aside\Com; | 10 | namespace App\Http\Controllers\Aside\Com; |
| 11 | 11 | ||
| 12 | 12 | ||
| 13 | +use App\Enums\Common\Code; | ||
| 13 | use App\Http\Controllers\Aside\BaseController; | 14 | use App\Http\Controllers\Aside\BaseController; |
| 14 | use App\Models\Domain\DomainInfo; | 15 | use App\Models\Domain\DomainInfo; |
| 16 | +use App\Models\Project\Country as CountryModel; | ||
| 15 | use App\Models\Project\DeployBuild; | 17 | use App\Models\Project\DeployBuild; |
| 18 | +use App\Models\WebSetting\WebLanguage; | ||
| 16 | use Illuminate\Http\Request; | 19 | use Illuminate\Http\Request; |
| 20 | +use Illuminate\Support\Facades\DB; | ||
| 17 | 21 | ||
| 18 | 22 | ||
| 19 | /** | 23 | /** |
| @@ -55,4 +59,23 @@ class CNoticeController extends BaseController | @@ -55,4 +59,23 @@ class CNoticeController extends BaseController | ||
| 55 | $this->response('更新中请稍后, 更新完成将会发送站内信通知更新结果!'); | 59 | $this->response('更新中请稍后, 更新完成将会发送站内信通知更新结果!'); |
| 56 | } | 60 | } |
| 57 | 61 | ||
| 62 | + /** | ||
| 63 | + * @remark :获取当前项目选中的语种 | ||
| 64 | + * @name :getCountry | ||
| 65 | + * @author :lyh | ||
| 66 | + * @method :post | ||
| 67 | + * @time :2023/9/12 15:20 | ||
| 68 | + */ | ||
| 69 | + public function getCountry(){ | ||
| 70 | + $countryModel = new CountryModel(); | ||
| 71 | + $info = $countryModel->read(['project_id'=>$this->param['project_id']],['id','country_lists']); | ||
| 72 | + $ids = []; | ||
| 73 | + if($info !== false){ | ||
| 74 | + $ids = explode(',',$info['country_lists']); | ||
| 75 | + } | ||
| 76 | + $languageModel = new WebLanguage(); | ||
| 77 | + //根据排序查询选中的小语种 | ||
| 78 | + $lists = $languageModel->whereIn('id', $ids)->orderByRaw(DB::raw("FIND_IN_SET(id,'" . implode(',', $ids) . "'" . ')'))->get()->toArray(); | ||
| 79 | + $this->response('success',Code::SUCCESS,$lists); | ||
| 80 | + } | ||
| 58 | } | 81 | } |
| @@ -284,7 +284,7 @@ class ProjectController extends BaseController | @@ -284,7 +284,7 @@ class ProjectController extends BaseController | ||
| 284 | $info = $managerHr->read(['manage_id'=>$this->manage['id']]); | 284 | $info = $managerHr->read(['manage_id'=>$this->manage['id']]); |
| 285 | //获取当前用户自己的项目 | 285 | //获取当前用户自己的项目 |
| 286 | $query->where(function ($subQuery) use ($info) { | 286 | $query->where(function ($subQuery) use ($info) { |
| 287 | - $subQuery->whereIn('gl_project.id',[1,3])//项目1+项目3默认显示 | 287 | + $subQuery->whereIn('gl_project.id',[1])//项目1+项目3默认显示 |
| 288 | ->orWhere('gl_project_deploy_build.leader_mid', $this->manage['id']) | 288 | ->orWhere('gl_project_deploy_build.leader_mid', $this->manage['id']) |
| 289 | ->orWhere('gl_project_deploy_build.manager_mid', $this->manage['id']) | 289 | ->orWhere('gl_project_deploy_build.manager_mid', $this->manage['id']) |
| 290 | ->orWhere('gl_project_deploy_build.designer_mid', $this->manage['id']) | 290 | ->orWhere('gl_project_deploy_build.designer_mid', $this->manage['id']) |
| @@ -4,6 +4,7 @@ namespace App\Http\Logic\Aside\Domain; | @@ -4,6 +4,7 @@ namespace App\Http\Logic\Aside\Domain; | ||
| 4 | 4 | ||
| 5 | 5 | ||
| 6 | use App\Http\Logic\Aside\BaseLogic; | 6 | use App\Http\Logic\Aside\BaseLogic; |
| 7 | +use App\Jobs\EditCustomDomainBt; | ||
| 7 | use App\Jobs\EditDomainBt; | 8 | use App\Jobs\EditDomainBt; |
| 8 | use App\Models\Devops\ServerConfig; | 9 | use App\Models\Devops\ServerConfig; |
| 9 | use App\Models\Domain\DomainInfo; | 10 | use App\Models\Domain\DomainInfo; |
| @@ -403,16 +404,18 @@ class DomainInfoLogic extends BaseLogic | @@ -403,16 +404,18 @@ class DomainInfoLogic extends BaseLogic | ||
| 403 | $info = $custom_model->read(['project_id'=>$project_id,'language_id'=>$this->param['language_id']]); | 404 | $info = $custom_model->read(['project_id'=>$project_id,'language_id'=>$this->param['language_id']]); |
| 404 | if($info === false){ | 405 | if($info === false){ |
| 405 | $this->param['project_id'] = $project_id; | 406 | $this->param['project_id'] = $project_id; |
| 406 | - $custom_model->add($this->param); | 407 | + $id = $custom_model->addReturnId($this->param); |
| 407 | }else{ | 408 | }else{ |
| 408 | $custom_model->edit($this->param,['id'=>$info['id']]); | 409 | $custom_model->edit($this->param,['id'=>$info['id']]); |
| 410 | + $id = $info['id']; | ||
| 409 | } | 411 | } |
| 410 | 412 | ||
| 411 | if($this->param['is_create']){ | 413 | if($this->param['is_create']){ |
| 412 | //创建站点,设置证书 | 414 | //创建站点,设置证书 |
| 413 | - $this->param['key'] = $this->param['private_key'] ?? ''; | ||
| 414 | - $this->param['cert'] = $this->param['private_cert'] ?? ''; | ||
| 415 | - $this->setDomainSsl($server_info['init_domain'],$this->param['custom_domain'],[],[],1); | 415 | + EditCustomDomainBt::dispatch($id); |
| 416 | +// $this->param['key'] = $this->param['private_key'] ?? ''; | ||
| 417 | +// $this->param['cert'] = $this->param['private_cert'] ?? ''; | ||
| 418 | +// $this->setDomainSsl($server_info['init_domain'],$this->param['custom_domain'],[],[],1); | ||
| 416 | } | 419 | } |
| 417 | 420 | ||
| 418 | return $this->success(); | 421 | return $this->success(); |
app/Jobs/EditCustomDomainBt.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Jobs; | ||
| 4 | + | ||
| 5 | +use App\Models\Devops\ServerConfig; | ||
| 6 | +use App\Models\Project\CountryCustom; | ||
| 7 | +use App\Models\Project\Project; | ||
| 8 | +use App\Utils\HttpUtils; | ||
| 9 | +use GuzzleHttp\Exception\GuzzleException; | ||
| 10 | +use Illuminate\Bus\Queueable; | ||
| 11 | +use Illuminate\Contracts\Queue\ShouldQueue; | ||
| 12 | +use Illuminate\Foundation\Bus\Dispatchable; | ||
| 13 | +use Illuminate\Queue\InteractsWithQueue; | ||
| 14 | +use Illuminate\Queue\SerializesModels; | ||
| 15 | + | ||
| 16 | +class EditCustomDomainBt implements ShouldQueue | ||
| 17 | +{ | ||
| 18 | + use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; | ||
| 19 | + | ||
| 20 | + public $tries = 1; // 可配置任务重试次数 | ||
| 21 | + | ||
| 22 | + protected $domain_id; | ||
| 23 | + | ||
| 24 | + /** | ||
| 25 | + * Create a new job instance. | ||
| 26 | + * | ||
| 27 | + * @param $domain_id | ||
| 28 | + */ | ||
| 29 | + public function __construct($domain_id) | ||
| 30 | + { | ||
| 31 | + $this->domain_id = $domain_id; | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + /** | ||
| 35 | + * Execute the job. | ||
| 36 | + * | ||
| 37 | + * @return bool | ||
| 38 | + */ | ||
| 39 | + public function handle() | ||
| 40 | + { | ||
| 41 | + //获取域名数据 | ||
| 42 | + $domain_model = new CountryCustom(); | ||
| 43 | + $domain_info = $domain_model->read(['id' => $this->domain_id]); | ||
| 44 | + if ($domain_info === false) { | ||
| 45 | + return $this->output($domain_info['custom_domain'] . ':获取域名数据失败'); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + //获取项目数据 | ||
| 49 | + $project_model = new Project(); | ||
| 50 | + $project_info = $project_model->read(['id' => $domain_info['project_id']], 'serve_id'); | ||
| 51 | + if ($project_info === false) { | ||
| 52 | + return $this->output($domain_info['custom_domain'] . ':获取项目数据失败'); | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + //获取服务器数据 | ||
| 56 | + $server_model = new ServerConfig(); | ||
| 57 | + $server_info = $server_model->read(['id' => $project_info['serve_id']], ['init_domain', 'host']); | ||
| 58 | + if ($server_info === false) { | ||
| 59 | + return $this->output($domain_info['custom_domain'] . ':获取服务器数据失败'); | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + //编辑站点 | ||
| 63 | + if ($domain_info['type'] == 2) { | ||
| 64 | + $api_url = 'http://' . $server_info['init_domain'] . '/api/setSsl'; | ||
| 65 | + $api_param = [ | ||
| 66 | + 'domain' => $domain_info['custom_domain'], | ||
| 67 | + 'private_key' => $domain_info['private_key'], | ||
| 68 | + 'cert' => $domain_info['private_cert'], | ||
| 69 | + 'rewrite' => [], | ||
| 70 | + 'other_domain' => [], | ||
| 71 | + 'is_https' => 1 | ||
| 72 | + ]; | ||
| 73 | + } else { | ||
| 74 | + $api_url = 'http://' . $server_info['init_domain'] . '/api/applySsl'; | ||
| 75 | + $api_param = [ | ||
| 76 | + 'domain' => $domain_info['custom_domain'], | ||
| 77 | + 'rewrite' => [], | ||
| 78 | + 'other_domain' => [], | ||
| 79 | + 'is_https' => 1 | ||
| 80 | + ]; | ||
| 81 | + } | ||
| 82 | + try { | ||
| 83 | + $rs = HttpUtils::get($api_url, $api_param); | ||
| 84 | + $rs = json_decode($rs, true); | ||
| 85 | + if (isset($rs['status']) && $rs['status'] == 200) { | ||
| 86 | + $this->output($domain_info['custom_domain'] . ':站点编辑成功'); | ||
| 87 | + } else { | ||
| 88 | + $this->output($domain_info['custom_domain'] . ':站点编辑失败,原因:' . ($rs['message'] ?? '')); | ||
| 89 | + } | ||
| 90 | + } catch (\Exception | GuzzleException $e) { | ||
| 91 | + $this->output($domain_info['custom_domain'] . ':站点编辑失败,原因:' . $e->getMessage()); | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + return true; | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + /** | ||
| 98 | + * 输出处理日志 | ||
| 99 | + * @param $message | ||
| 100 | + * @return bool | ||
| 101 | + */ | ||
| 102 | + public function output($message) | ||
| 103 | + { | ||
| 104 | + echo date('Y-m-d H:i:s') . ' | ' . $message . PHP_EOL; | ||
| 105 | + return true; | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + public function failed(\Exception $exception) | ||
| 109 | + { | ||
| 110 | + return $this->output($exception->getMessage()); | ||
| 111 | + } | ||
| 112 | +} |
| @@ -15,6 +15,7 @@ Route::middleware(['aloginauth'])->group(function () { | @@ -15,6 +15,7 @@ Route::middleware(['aloginauth'])->group(function () { | ||
| 15 | Route::get('/logout', [Aside\LoginController::class, 'logout'])->name('admin.logout.white'); | 15 | Route::get('/logout', [Aside\LoginController::class, 'logout'])->name('admin.logout.white'); |
| 16 | Route::any('/getAccessAddress', [Aside\LoginController::class, 'getAccessAddress'])->name('admin.getAccessAddress');//获取B端地址 | 16 | Route::any('/getAccessAddress', [Aside\LoginController::class, 'getAccessAddress'])->name('admin.getAccessAddress');//获取B端地址 |
| 17 | Route::get('/sendNotify', [Aside\Com\CNoticeController::class, 'sendNotify'])->name('admin.sendNotify'); | 17 | Route::get('/sendNotify', [Aside\Com\CNoticeController::class, 'sendNotify'])->name('admin.sendNotify'); |
| 18 | + Route::get('/getCountry', [Aside\Com\CNoticeController::class, 'getCountry'])->name('admin.getCountry'); | ||
| 18 | 19 | ||
| 19 | //会员相关 | 20 | //会员相关 |
| 20 | Route::prefix('user')->group(function () { | 21 | Route::prefix('user')->group(function () { |
-
请 注册 或 登录 后发表评论