作者 lyh

Merge branch 'develop' of http://47.244.231.31:8099/zhl/globalso-v6 into develop

  1 +<?php
  2 +
  3 +namespace App\Http\Controllers\Bside\Setting;
  4 +
  5 +use App\Enums\Common\Code;
  6 +use App\Http\Controllers\Bside\BaseController;
  7 +use App\Http\Logic\Bside\Setting\WebSettingAmpLogic;
  8 +
  9 +class WebSettingAmpController extends BaseController
  10 +{
  11 + /**
  12 + * 获取amp设置详情
  13 + * @param WebSettingAmpLogic $logic
  14 + * @author Akun
  15 + * @date 2024/01/25 15:52
  16 + */
  17 + public function info(WebSettingAmpLogic $logic)
  18 + {
  19 + $info = $logic->ampInfo();
  20 + $this->response('success', Code::SUCCESS, $info);
  21 + }
  22 +
  23 + /**
  24 + * 保存amp 设置
  25 + * @param WebSettingAmpLogic $logic
  26 + * @author Akun
  27 + * @date 2024/01/25 15:53
  28 + */
  29 + public function save(WebSettingAmpLogic $logic)
  30 + {
  31 + $logic->ampSave();
  32 + $this->response('success');
  33 + }
  34 +}
  1 +<?php
  2 +
  3 +namespace App\Http\Logic\Bside\Setting;
  4 +
  5 +use App\Helper\Arr;
  6 +use App\Http\Logic\Bside\BaseLogic;
  7 +use App\Models\WebSetting\WebSettingAmp;
  8 +
  9 +class WebSettingAmpLogic extends BaseLogic
  10 +{
  11 + public function __construct()
  12 + {
  13 + parent::__construct();
  14 + $this->model = new WebSettingAmp();
  15 + $this->param = $this->requestAll;
  16 + }
  17 +
  18 + /**
  19 + * 获取详情
  20 + * @return array
  21 + * @author Akun
  22 + * @date 2024/01/25 15:32
  23 + */
  24 + public function ampInfo()
  25 + {
  26 + $info = $this->model->read(['project_id' => $this->user['project_id']]);
  27 + if ($info === false) {
  28 + return $this->success();
  29 + }
  30 + //banner处理
  31 + if (!empty($info['index_banner'])) {
  32 + foreach ($info['index_banner'] as &$v) {
  33 + $v = getImageUrl($v, $this->user['project_location'] ?? 0, $this->user['storage_type'] ?? 0);
  34 + }
  35 + }
  36 + return $this->success($info);
  37 + }
  38 +
  39 + /**
  40 + * 保存数据
  41 + * @return array
  42 + * @author Akun
  43 + * @date 2024/01/25 15:33
  44 + */
  45 + public function ampSave()
  46 + {
  47 + try {
  48 + //banner处理
  49 + foreach ($this->param['index_banner'] ?? [] as &$v) {
  50 + $v = str_replace_url($v);
  51 + }
  52 + $this->param['index_banner'] = Arr::a2s($this->param['index_banner'] ?? []);
  53 +
  54 + $info = $this->model->read(['project_id' => $this->user['project_id']]);
  55 + if ($info === false) {
  56 + $this->param['project_id'] = $this->user['project_id'];
  57 + $this->model->add($this->param);
  58 + } else {
  59 + $this->model->edit($this->param, ['project_id' => $this->user['project_id']]);
  60 + }
  61 + } catch (\Exception $e) {
  62 + $this->fail('error');
  63 + }
  64 + return $this->success();
  65 + }
  66 +}
  1 +<?php
  2 +
  3 +namespace App\Models\WebSetting;
  4 +
  5 +use App\Helper\Arr;
  6 +use App\Models\Base;
  7 +
  8 +class WebSettingAmp extends Base
  9 +{
  10 + protected $table = 'gl_web_setting_amp';
  11 +
  12 + //连接数据库
  13 + protected $connection = 'custom_mysql';
  14 +
  15 + public function getIndexBannerAttribute($value){
  16 + if(!empty($value)){
  17 + $value = Arr::s2a($value);
  18 + }
  19 + return $value;
  20 + }
  21 +
  22 +}
@@ -206,6 +206,12 @@ Route::middleware(['bloginauth'])->group(function () { @@ -206,6 +206,12 @@ Route::middleware(['bloginauth'])->group(function () {
206 Route::any('/info', [\App\Http\Controllers\Bside\Setting\SettingNumController::class, 'info'])->name('num_info'); 206 Route::any('/info', [\App\Http\Controllers\Bside\Setting\SettingNumController::class, 'info'])->name('num_info');
207 Route::any('/save',[\App\Http\Controllers\Bside\Setting\SettingNumController::class, 'save'])->name('num_save'); 207 Route::any('/save',[\App\Http\Controllers\Bside\Setting\SettingNumController::class, 'save'])->name('num_save');
208 }); 208 });
  209 +
  210 + //amp设置
  211 + Route::prefix('amp')->group(function () {
  212 + Route::any('/info', [\App\Http\Controllers\Bside\Setting\WebSettingAmpController::class, 'info'])->name('amp_info');
  213 + Route::any('/save',[\App\Http\Controllers\Bside\Setting\WebSettingAmpController::class, 'save'])->name('amp_save');
  214 + });
209 }); 215 });
210 //产品 216 //产品
211 Route::prefix('product')->group(function () { 217 Route::prefix('product')->group(function () {