作者 lyh

gx

@@ -57,7 +57,7 @@ class UpdateRoute extends Command @@ -57,7 +57,7 @@ class UpdateRoute extends Command
57 */ 57 */
58 public function handle(){ 58 public function handle(){
59 $projectModel = new Project(); 59 $projectModel = new Project();
60 - $list = $projectModel->list(['id'=>['=',2508]]); 60 + $list = $projectModel->list(['id'=>['=',2503]]);
61 $data = []; 61 $data = [];
62 foreach ($list as $v){ 62 foreach ($list as $v){
63 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; 63 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :DetailController.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/11/12 14:55
  8 + */
  9 +
  10 +namespace App\Http\Controllers\Bside\Product;
  11 +
  12 +use App\Enums\Common\Code;
  13 +use App\Http\Controllers\Bside\BaseController;
  14 +use App\Http\Logic\Bside\Product\DetailLogic;
  15 +use App\Models\Product\Column;
  16 +use App\Models\Product\Detail;
  17 +
  18 +class DetailController extends BaseController
  19 +{
  20 + /**
  21 + * @remark :获取产品描述页所有详情
  22 + * @name :getType
  23 + * @author :lyh
  24 + * @method :post
  25 + * @time :2024/11/12 14:57
  26 + */
  27 + public function getType(Detail $detail){
  28 + $data = [
  29 + 'text_type' => $detail->text_type(),
  30 + 'line_two_type' => $detail->line_two_type(),
  31 + 'image_two_type' => $detail->image_two_type(),
  32 + 'three_type' => $detail->three_type(),
  33 + 'image_three_type' => $detail->image_three_type(),
  34 + ];
  35 + $this->response('success',Code::SUCCESS,$data);
  36 + }
  37 +
  38 + /**
  39 + * @remark :获取产品描述栏目
  40 + * @name :getColumn
  41 + * @author :lyh
  42 + * @method :post
  43 + * @time :2024/11/12 15:07
  44 + */
  45 + public function getColumn(Column $column){
  46 + $data = $column->list($this->map,'id',['*'],'asc');
  47 + $this->response('success',Code::SUCCESS,$data);
  48 + }
  49 +
  50 + /**
  51 + * @remark :保存切换栏
  52 + * @name :saveColumn
  53 + * @author :lyh
  54 + * @method :post
  55 + * @time :2024/11/12 15:13
  56 + */
  57 + public function saveColumn(DetailLogic $logic){
  58 + $this->request->validate([
  59 + 'column_name'=>'required'
  60 + ],[
  61 + 'column_name.required' => '栏目名称不能为空'
  62 + ]);
  63 + $data = $logic->saveColumn();
  64 + $this->response('success',Code::SUCCESS,$data);
  65 + }
  66 +
  67 + /**
  68 + * @remark :保存数据
  69 + * @name :saveDetail
  70 + * @author :lyh
  71 + * @method :post
  72 + * @time :2024/11/12 16:24
  73 + */
  74 + public function saveDetail(){
  75 + $this->request->validate([
  76 + 'product_id'=>'required',
  77 + 'data'=>'required',
  78 + ],[
  79 + 'product_id.required' => '产品id不能为空',
  80 + 'data.required' => 'data不能为空',
  81 + ]);
  82 +
  83 + foreach ($this->param['data'] as $k => $data){
  84 + $i = 1;
  85 + foreach ($data as $key => $v){
  86 + $data = [
  87 + 'sort'=>$i,
  88 + 'column_id'=>$v['column_id'],
  89 + 'product_id'=>$this->param['product_id'],
  90 + 'title'=>$v['title'],
  91 + 'content'=>json_encode($v['content'])
  92 + ];
  93 + $i++;
  94 + }
  95 + }
  96 + }
  97 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :DetailLogic.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/11/12 15:14
  8 + */
  9 +
  10 +namespace App\Http\Logic\Bside\Product;
  11 +
  12 +use App\Http\Logic\Bside\BaseLogic;
  13 +use App\Models\Product\Column;
  14 +use App\Models\Product\Detail;
  15 +
  16 +class DetailLogic extends BaseLogic
  17 +{
  18 + public function __construct()
  19 + {
  20 + parent::__construct();
  21 + $this->param = $this->requestAll;
  22 + $this->model = new Detail();
  23 + }
  24 +
  25 + /**
  26 + * @remark :保存栏目
  27 + * @name :saveColumn
  28 + * @author :lyh
  29 + * @method :post
  30 + * @time :2024/11/12 15:15
  31 + */
  32 + public function saveColumn(){
  33 + $columnModel = new Column();
  34 + if(isset($this->param['id']) && !empty($this->param['id'])){
  35 + $id = $this->param['id'];
  36 + $rs = $columnModel->edit(['column_name'=>$this->param['column_name']],['id'=>$this->param['id']]);
  37 + if($rs === false){
  38 + $this->fail('保存失败,请联系管理员');
  39 + }
  40 + }else{
  41 + $id = $columnModel->add($this->param);
  42 + }
  43 + return $this->success(['id'=>$id]);
  44 + }
  45 +}
@@ -560,7 +560,7 @@ class ProductLogic extends BaseLogic @@ -560,7 +560,7 @@ class ProductLogic extends BaseLogic
560 'related_product_id'=>Arr::arrToSet($info['related_product_id']), 560 'related_product_id'=>Arr::arrToSet($info['related_product_id']),
561 'sort'=>$info['sort'], 561 'sort'=>$info['sort'],
562 'status'=>0, 562 'status'=>0,
563 - 'route'=>$info['route'], 563 + 'route'=>$info['title'],
564 'product_type'=>$info['product_type'], 564 'product_type'=>$info['product_type'],
565 'created_uid'=>$this->user['id'], 565 'created_uid'=>$this->user['id'],
566 'created_at'=>date('Y-m-d H:i:s'), 566 'created_at'=>date('Y-m-d H:i:s'),
@@ -20,7 +20,6 @@ class Blog extends Base @@ -20,7 +20,6 @@ class Blog extends Base
20 if(!$value){ 20 if(!$value){
21 return date('Y-m-d H:i:s', strtotime($this->getAttribute('created_at'))); 21 return date('Y-m-d H:i:s', strtotime($this->getAttribute('created_at')));
22 } 22 }
23 -  
24 return $value; 23 return $value;
25 } 24 }
26 } 25 }
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :Column.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/11/12 14:14
  8 + */
  9 +
  10 +namespace App\Models\Product;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +class Column extends Base
  15 +{
  16 + //设置关联表名
  17 + protected $table = 'gl_product_column';
  18 + //连接数据库
  19 + protected $connection = 'custom_mysql';
  20 +
  21 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :Detail.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/11/12 14:13
  8 + */
  9 +
  10 +namespace App\Models\Product;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +class Detail extends Base
  15 +{
  16 + //设置关联表名
  17 + protected $table = 'gl_product_detail';
  18 + //连接数据库
  19 + protected $connection = 'custom_mysql';
  20 +
  21 + /**
  22 + * @remark :文本框类型
  23 + * @name :text_box
  24 + * @author :lyh
  25 + * @method :post
  26 + * @time :2024/11/12 14:15
  27 + */
  28 + public function text_type(){
  29 + return [
  30 + 1=>'富文本框',
  31 + 2=>'多图模块',
  32 + 3=>'单图文案',
  33 + ];
  34 + }
  35 +
  36 + /**
  37 + * @remark :多图框类型
  38 + * @name :line_number
  39 + * @author :lyh
  40 + * @method :post
  41 + * @time :2024/11/12 14:15
  42 + */
  43 + public function line_two_type(){
  44 + return [
  45 + 1=>'1行',
  46 + 2=>'2行',
  47 + 3=>'3行',
  48 + 4=>'4行',
  49 + 5=>'5行',
  50 + ];
  51 + }
  52 +
  53 + /**
  54 + * @remark :图片框类型
  55 + * @name :line_number
  56 + * @author :lyh
  57 + * @method :post
  58 + * @time :2024/11/12 14:15
  59 + */
  60 + public function image_two_type(){
  61 + return [
  62 + 1=>'1张图',
  63 + 2=>'2张图',
  64 + 3=>'3张图',
  65 + 4=>'4张图',
  66 + 5=>'5张图',
  67 + ];
  68 + }
  69 +
  70 + /**
  71 + * @remark :图片文本框类型
  72 + * @name :line_number
  73 + * @author :lyh
  74 + * @method :post
  75 + * @time :2024/11/12 14:15
  76 + */
  77 + public function three_type(){
  78 + return [
  79 + 1=>'左图右文',
  80 + 2=>'右图左文',
  81 + ];
  82 + }
  83 +
  84 + /**
  85 + * @remark :图片文本框类型
  86 + * @name :line_number
  87 + * @author :lyh
  88 + * @method :post
  89 + * @time :2024/11/12 14:15
  90 + */
  91 + public function image_three_type(){
  92 + return [
  93 + 1=>'图片悬浮',
  94 + 2=>'图片固定',
  95 + ];
  96 + }
  97 +
  98 +}
@@ -136,6 +136,8 @@ class ProjectServer @@ -136,6 +136,8 @@ class ProjectServer
136 self::init404Page($project_id); 136 self::init404Page($project_id);
137 //初始化模块数据 137 //初始化模块数据
138 self::initModule($project_id); 138 self::initModule($project_id);
  139 + //初始化切换栏
  140 + self::initColumn();
139 //初始化search页面 141 //初始化search页面
140 // self::initSearchPage($project_id); 142 // self::initSearchPage($project_id);
141 DB::disconnect('custom_mysql'); 143 DB::disconnect('custom_mysql');
@@ -163,6 +165,27 @@ class ProjectServer @@ -163,6 +165,27 @@ class ProjectServer
163 } 165 }
164 return true; 166 return true;
165 } 167 }
  168 +
  169 + /**
  170 + * @remark :初始化产品切换栏
  171 + * @name :initColumn
  172 + * @author :lyh
  173 + * @method :post
  174 + * @time :2024/11/12 11:39
  175 + */
  176 + public static function initColumn(){
  177 + $info = DB::connection('custom_mysql')->table('gl_product_column')->first();
  178 + if(empty($info)){
  179 + $data = [
  180 + 'column_name'=>'Product Details',
  181 + 'created_at' => date('Y-m-d H:i:s'),
  182 + 'updated_at' => date('Y-m-d H:i:s')
  183 + ];
  184 + DB::connection('custom_mysql')->table('gl_product_column')->insert($data);
  185 + }
  186 + return true;
  187 + }
  188 +
166 /** 189 /**
167 * @remark :菜单 190 * @remark :菜单
168 * @name :initGroup 191 * @name :initGroup