Merge branch 'develop' of http://47.244.231.31:8099/zhl/globalso-v6 into bate
正在显示
7 个修改的文件
包含
143 行增加
和
29 行删除
| @@ -167,7 +167,7 @@ class VideoTask extends Command | @@ -167,7 +167,7 @@ class VideoTask extends Command | ||
| 167 | */ | 167 | */ |
| 168 | public function getProjectKeyword($number) | 168 | public function getProjectKeyword($number) |
| 169 | { | 169 | { |
| 170 | - $keyword_arr_id = Keyword::where('video', null)->where('route', 'not like', '%tag%')->whereNotNull('keyword_content')->pluck('id')->toArray(); | 170 | + $keyword_arr_id = Keyword::where('video', null)->where('route', 'not like', '%-tag')->whereNotNull('keyword_content')->pluck('id')->toArray(); |
| 171 | $keyword_id = array_rand($keyword_arr_id, $number); | 171 | $keyword_id = array_rand($keyword_arr_id, $number); |
| 172 | $keyword = Keyword::whereIn("id", $keyword_id)->get(); | 172 | $keyword = Keyword::whereIn("id", $keyword_id)->get(); |
| 173 | return $keyword; | 173 | return $keyword; |
| @@ -7,6 +7,8 @@ | @@ -7,6 +7,8 @@ | ||
| 7 | */ | 7 | */ |
| 8 | namespace App\Http\Controllers\Api; | 8 | namespace App\Http\Controllers\Api; |
| 9 | 9 | ||
| 10 | +use App\Enums\Common\Code; | ||
| 11 | +use App\Http\Logic\Bside\User\UserLoginLogic; | ||
| 10 | use App\Models\Domain\DomainInfo; | 12 | use App\Models\Domain\DomainInfo; |
| 11 | use App\Models\Product\Category; | 13 | use App\Models\Product\Category; |
| 12 | use App\Models\Product\Product; | 14 | use App\Models\Product\Product; |
| @@ -16,6 +18,7 @@ use App\Models\RouteMap\RouteMap; | @@ -16,6 +18,7 @@ use App\Models\RouteMap\RouteMap; | ||
| 16 | use App\Models\User\User; | 18 | use App\Models\User\User; |
| 17 | use App\Services\ProjectServer; | 19 | use App\Services\ProjectServer; |
| 18 | use Illuminate\Http\Request; | 20 | use Illuminate\Http\Request; |
| 21 | +use Illuminate\Support\Facades\Cache; | ||
| 19 | use Illuminate\Support\Facades\DB; | 22 | use Illuminate\Support\Facades\DB; |
| 20 | 23 | ||
| 21 | /** | 24 | /** |
| @@ -142,4 +145,26 @@ class PrivateController extends BaseController | @@ -142,4 +145,26 @@ class PrivateController extends BaseController | ||
| 142 | $user = array_unique(array_merge($valid_user, $upgrade_user)); | 145 | $user = array_unique(array_merge($valid_user, $upgrade_user)); |
| 143 | return $this->success($user); | 146 | return $this->success($user); |
| 144 | } | 147 | } |
| 148 | + | ||
| 149 | + /** | ||
| 150 | + * @remark :模拟登录返回token | ||
| 151 | + * @name :getToken | ||
| 152 | + * @author :lyh | ||
| 153 | + * @method :post | ||
| 154 | + * @time :2024/3/29 16:19 | ||
| 155 | + */ | ||
| 156 | + public function getAutoToken(){ | ||
| 157 | + //获取当前用户的草鸡管理员 | ||
| 158 | + $userModel = new User(); | ||
| 159 | + $userInfo = $userModel->read(['project_id'=>$this->param['project_id'],'role_id'=>0]); | ||
| 160 | + $userLoginLogicModel = new UserLoginLogic(); | ||
| 161 | + $info = $userLoginLogicModel->autoAssembleParam($userInfo); | ||
| 162 | + //生成新token | ||
| 163 | + $token = md5(uniqid().'auto'.$info['id']); | ||
| 164 | + //存储缓存 | ||
| 165 | + $info['token'] = $token; | ||
| 166 | + Cache::add($token,$info,3600); | ||
| 167 | + $data = ['token'=>$token,'main_lang_id'=>$info['main_lang_id']]; | ||
| 168 | + $this->response('success',Code::SUCCESS,$data); | ||
| 169 | + } | ||
| 145 | } | 170 | } |
| @@ -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\EditAmpDomainBt; | ||
| 7 | use App\Jobs\EditCustomDomainBt; | 8 | use App\Jobs\EditCustomDomainBt; |
| 8 | use App\Jobs\EditDomainBt; | 9 | use App\Jobs\EditDomainBt; |
| 9 | use App\Models\Devops\ServerConfig; | 10 | use App\Models\Devops\ServerConfig; |
| @@ -303,14 +304,15 @@ class DomainInfoLogic extends BaseLogic | @@ -303,14 +304,15 @@ class DomainInfoLogic extends BaseLogic | ||
| 303 | 'amp_private_cert' => $this->param['amp_cert'] ?? '', | 304 | 'amp_private_cert' => $this->param['amp_cert'] ?? '', |
| 304 | ]; | 305 | ]; |
| 305 | $this->model->edit($data,['id'=>$this->param['id']]); | 306 | $this->model->edit($data,['id'=>$this->param['id']]); |
| 306 | - //生成证书 | 307 | + //主站生成证书 |
| 307 | EditDomainBt::dispatch($this->param['id']); | 308 | EditDomainBt::dispatch($this->param['id']); |
| 308 | // $this->setDomainSsl($server_info['init_domain'],$info['domain'],$this->param['extend_config'] ?? [],$this->param['other_domain'] ?? [],$this->param['is_https'] ?? 0); | 309 | // $this->setDomainSsl($server_info['init_domain'],$info['domain'],$this->param['extend_config'] ?? [],$this->param['other_domain'] ?? [],$this->param['is_https'] ?? 0); |
| 309 | 310 | ||
| 310 | - //amp站点生成证书 | ||
| 311 | -// if($data['amp_status']){ | 311 | + //amp站生成证书 |
| 312 | + if($data['amp_status']){ | ||
| 313 | + EditAmpDomainBt::dispatch($this->param['id']); | ||
| 312 | // $this->setAmpDomainSsl($server_info['init_domain'],$info['domain']); | 314 | // $this->setAmpDomainSsl($server_info['init_domain'],$info['domain']); |
| 313 | -// } | 315 | + } |
| 314 | 316 | ||
| 315 | return $this->success(); | 317 | return $this->success(); |
| 316 | } | 318 | } |
| @@ -79,6 +79,13 @@ class WebSettingAmpLogic extends BaseLogic | @@ -79,6 +79,13 @@ class WebSettingAmpLogic extends BaseLogic | ||
| 79 | $this->param['company_image'] = Arr::a2s($this->param['company_image'] ?? []); | 79 | $this->param['company_image'] = Arr::a2s($this->param['company_image'] ?? []); |
| 80 | //icon处理 | 80 | //icon处理 |
| 81 | $this->param['web_icon'] = str_replace_url($this->param['web_icon'] ?? ''); | 81 | $this->param['web_icon'] = str_replace_url($this->param['web_icon'] ?? ''); |
| 82 | + //其余参数默认值 | ||
| 83 | + $this->param['top_backgroundcolor'] = $this->param['top_backgroundcolor'] ?? ''; | ||
| 84 | + $this->param['company_email'] = $this->param['company_email'] ?? ''; | ||
| 85 | + $this->param['company_address'] = $this->param['company_address'] ?? ''; | ||
| 86 | + $this->param['company_tel'] = $this->param['company_tel'] ?? ''; | ||
| 87 | + $this->param['company_skype'] = $this->param['company_skype'] ?? ''; | ||
| 88 | + $this->param['company_whatsapp'] = $this->param['company_whatsapp'] ?? ''; | ||
| 82 | 89 | ||
| 83 | $info = $this->model->read(['project_id' => $this->user['project_id']]); | 90 | $info = $this->model->read(['project_id' => $this->user['project_id']]); |
| 84 | if ($info === false) { | 91 | if ($info === false) { |
app/Jobs/EditAmpDomainBt.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Jobs; | ||
| 4 | + | ||
| 5 | +use App\Models\Devops\ServerConfig; | ||
| 6 | +use App\Models\Domain\DomainInfo; | ||
| 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 EditAmpDomainBt 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 DomainInfo(); | ||
| 43 | + $domain_info = $domain_model->read(['id' => $this->domain_id]); | ||
| 44 | + if ($domain_info === false) { | ||
| 45 | + return $this->output($domain_info['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['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['domain'] . ':获取服务器数据失败'); | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + //编辑amp站 | ||
| 63 | + $api_url_amp = 'http://' . $server_info['init_domain'] . '/api/createSiteAmp'; | ||
| 64 | + $api_param_amp = [ | ||
| 65 | + 'domain' => $domain_info['domain'], | ||
| 66 | + ]; | ||
| 67 | + if ($domain_info['amp_type'] == 2) { | ||
| 68 | + $api_param_amp['private_key'] = $domain_info['amp_private_key']; | ||
| 69 | + $api_param_amp['cert'] = $domain_info['amp_private_cert']; | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + try { | ||
| 73 | + $rs_amp = HttpUtils::get($api_url_amp, $api_param_amp); | ||
| 74 | + $rs_amp = json_decode($rs_amp, true); | ||
| 75 | + if (isset($rs_amp['status']) && $rs_amp['status'] == 200) { | ||
| 76 | + $this->output($domain_info['domain'] . ':amp站编辑成功'); | ||
| 77 | + } else { | ||
| 78 | + $this->output($domain_info['domain'] . ':amp站编辑失败,原因:' . ($rs_amp['message'] ?? '')); | ||
| 79 | + } | ||
| 80 | + } catch (\Exception | GuzzleException $e_amp) { | ||
| 81 | + $this->output($domain_info['domain'] . ':amp站编辑失败,原因:' . $e_amp->getMessage()); | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + return true; | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + /** | ||
| 88 | + * 输出处理日志 | ||
| 89 | + * @param $message | ||
| 90 | + * @return bool | ||
| 91 | + */ | ||
| 92 | + public function output($message) | ||
| 93 | + { | ||
| 94 | + echo date('Y-m-d H:i:s') . ' | ' . $message . PHP_EOL; | ||
| 95 | + return true; | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + public function failed(\Exception $exception) | ||
| 99 | + { | ||
| 100 | + return $this->output($exception->getMessage()); | ||
| 101 | + } | ||
| 102 | +} |
| @@ -79,6 +79,7 @@ class EditDomainBt implements ShouldQueue | @@ -79,6 +79,7 @@ class EditDomainBt implements ShouldQueue | ||
| 79 | 'is_https' => $domain_info['is_https'] | 79 | 'is_https' => $domain_info['is_https'] |
| 80 | ]; | 80 | ]; |
| 81 | } | 81 | } |
| 82 | + | ||
| 82 | try { | 83 | try { |
| 83 | $rs = HttpUtils::get($api_url, $api_param); | 84 | $rs = HttpUtils::get($api_url, $api_param); |
| 84 | $rs = json_decode($rs, true); | 85 | $rs = json_decode($rs, true); |
| @@ -91,30 +92,6 @@ class EditDomainBt implements ShouldQueue | @@ -91,30 +92,6 @@ class EditDomainBt implements ShouldQueue | ||
| 91 | $this->output($domain_info['domain'] . ':主站编辑失败,原因:' . $e->getMessage()); | 92 | $this->output($domain_info['domain'] . ':主站编辑失败,原因:' . $e->getMessage()); |
| 92 | } | 93 | } |
| 93 | 94 | ||
| 94 | - //编辑amp站 | ||
| 95 | - if ($domain_info['amp_status']) { | ||
| 96 | - $api_url_amp = 'http://' . $server_info['init_domain'] . '/api/createSiteAmp'; | ||
| 97 | - $api_param_amp = [ | ||
| 98 | - 'domain' => $domain_info['domain'], | ||
| 99 | - ]; | ||
| 100 | - if ($domain_info['amp_type'] == 2) { | ||
| 101 | - $api_param_amp['private_key'] = $domain_info['amp_private_key']; | ||
| 102 | - $api_param_amp['cert'] = $domain_info['amp_private_cert']; | ||
| 103 | - } | ||
| 104 | - | ||
| 105 | - try { | ||
| 106 | - $rs_amp = HttpUtils::get($api_url_amp, $api_param_amp); | ||
| 107 | - $rs_amp = json_decode($rs_amp, true); | ||
| 108 | - if (isset($rs_amp['status']) && $rs_amp['status'] == 200) { | ||
| 109 | - $this->output($domain_info['domain'] . ':amp站编辑成功'); | ||
| 110 | - } else { | ||
| 111 | - $this->output($domain_info['domain'] . ':amp站编辑失败,原因:' . ($rs_amp['message'] ?? '')); | ||
| 112 | - } | ||
| 113 | - } catch (\Exception | GuzzleException $e_amp) { | ||
| 114 | - $this->output($domain_info['domain'] . ':amp站编辑失败,原因:' . $e_amp->getMessage()); | ||
| 115 | - } | ||
| 116 | - } | ||
| 117 | - | ||
| 118 | return true; | 95 | return true; |
| 119 | } | 96 | } |
| 120 | 97 |
| @@ -33,3 +33,4 @@ Route::post('video_task_callback', [\App\Http\Controllers\Api\NoticeController:: | @@ -33,3 +33,4 @@ Route::post('video_task_callback', [\App\Http\Controllers\Api\NoticeController:: | ||
| 33 | Route::any('has_user', [\App\Http\Controllers\Api\PrivateController::class, 'hasUser'])->name('api.has_user'); | 33 | Route::any('has_user', [\App\Http\Controllers\Api\PrivateController::class, 'hasUser'])->name('api.has_user'); |
| 34 | // 6.0有效用户用户 | 34 | // 6.0有效用户用户 |
| 35 | Route::any('valid_user', [\App\Http\Controllers\Api\PrivateController::class, 'validUser'])->name('api.valid_user'); | 35 | Route::any('valid_user', [\App\Http\Controllers\Api\PrivateController::class, 'validUser'])->name('api.valid_user'); |
| 36 | +Route::any('getAutoToken', [\App\Http\Controllers\Api\PrivateController::class, 'getAutoToken'])->name('api.getAutoToken'); |
-
请 注册 或 登录 后发表评论