作者 lyh

gx

... ... @@ -57,7 +57,7 @@ class UpdateRoute extends Command
*/
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['id'=>['=',2508]]);
$list = $projectModel->list(['id'=>['=',2503]]);
$data = [];
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
... ...
<?php
/**
* @remark :
* @name :DetailController.php
* @author :lyh
* @method :post
* @time :2024/11/12 14:55
*/
namespace App\Http\Controllers\Bside\Product;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\Product\DetailLogic;
use App\Models\Product\Column;
use App\Models\Product\Detail;
class DetailController extends BaseController
{
/**
* @remark :获取产品描述页所有详情
* @name :getType
* @author :lyh
* @method :post
* @time :2024/11/12 14:57
*/
public function getType(Detail $detail){
$data = [
'text_type' => $detail->text_type(),
'line_two_type' => $detail->line_two_type(),
'image_two_type' => $detail->image_two_type(),
'three_type' => $detail->three_type(),
'image_three_type' => $detail->image_three_type(),
];
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :获取产品描述栏目
* @name :getColumn
* @author :lyh
* @method :post
* @time :2024/11/12 15:07
*/
public function getColumn(Column $column){
$data = $column->list($this->map,'id',['*'],'asc');
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :保存切换栏
* @name :saveColumn
* @author :lyh
* @method :post
* @time :2024/11/12 15:13
*/
public function saveColumn(DetailLogic $logic){
$this->request->validate([
'column_name'=>'required'
],[
'column_name.required' => '栏目名称不能为空'
]);
$data = $logic->saveColumn();
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :保存数据
* @name :saveDetail
* @author :lyh
* @method :post
* @time :2024/11/12 16:24
*/
public function saveDetail(){
$this->request->validate([
'product_id'=>'required',
'data'=>'required',
],[
'product_id.required' => '产品id不能为空',
'data.required' => 'data不能为空',
]);
foreach ($this->param['data'] as $k => $data){
$i = 1;
foreach ($data as $key => $v){
$data = [
'sort'=>$i,
'column_id'=>$v['column_id'],
'product_id'=>$this->param['product_id'],
'title'=>$v['title'],
'content'=>json_encode($v['content'])
];
$i++;
}
}
}
}
... ...
<?php
/**
* @remark :
* @name :DetailLogic.php
* @author :lyh
* @method :post
* @time :2024/11/12 15:14
*/
namespace App\Http\Logic\Bside\Product;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Product\Column;
use App\Models\Product\Detail;
class DetailLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->param = $this->requestAll;
$this->model = new Detail();
}
/**
* @remark :保存栏目
* @name :saveColumn
* @author :lyh
* @method :post
* @time :2024/11/12 15:15
*/
public function saveColumn(){
$columnModel = new Column();
if(isset($this->param['id']) && !empty($this->param['id'])){
$id = $this->param['id'];
$rs = $columnModel->edit(['column_name'=>$this->param['column_name']],['id'=>$this->param['id']]);
if($rs === false){
$this->fail('保存失败,请联系管理员');
}
}else{
$id = $columnModel->add($this->param);
}
return $this->success(['id'=>$id]);
}
}
... ...
... ... @@ -560,7 +560,7 @@ class ProductLogic extends BaseLogic
'related_product_id'=>Arr::arrToSet($info['related_product_id']),
'sort'=>$info['sort'],
'status'=>0,
'route'=>$info['route'],
'route'=>$info['title'],
'product_type'=>$info['product_type'],
'created_uid'=>$this->user['id'],
'created_at'=>date('Y-m-d H:i:s'),
... ...
... ... @@ -20,7 +20,6 @@ class Blog extends Base
if(!$value){
return date('Y-m-d H:i:s', strtotime($this->getAttribute('created_at')));
}
return $value;
}
}
... ...
<?php
/**
* @remark :
* @name :Column.php
* @author :lyh
* @method :post
* @time :2024/11/12 14:14
*/
namespace App\Models\Product;
use App\Models\Base;
class Column extends Base
{
//设置关联表名
protected $table = 'gl_product_column';
//连接数据库
protected $connection = 'custom_mysql';
}
... ...
<?php
/**
* @remark :
* @name :Detail.php
* @author :lyh
* @method :post
* @time :2024/11/12 14:13
*/
namespace App\Models\Product;
use App\Models\Base;
class Detail extends Base
{
//设置关联表名
protected $table = 'gl_product_detail';
//连接数据库
protected $connection = 'custom_mysql';
/**
* @remark :文本框类型
* @name :text_box
* @author :lyh
* @method :post
* @time :2024/11/12 14:15
*/
public function text_type(){
return [
1=>'富文本框',
2=>'多图模块',
3=>'单图文案',
];
}
/**
* @remark :多图框类型
* @name :line_number
* @author :lyh
* @method :post
* @time :2024/11/12 14:15
*/
public function line_two_type(){
return [
1=>'1行',
2=>'2行',
3=>'3行',
4=>'4行',
5=>'5行',
];
}
/**
* @remark :图片框类型
* @name :line_number
* @author :lyh
* @method :post
* @time :2024/11/12 14:15
*/
public function image_two_type(){
return [
1=>'1张图',
2=>'2张图',
3=>'3张图',
4=>'4张图',
5=>'5张图',
];
}
/**
* @remark :图片文本框类型
* @name :line_number
* @author :lyh
* @method :post
* @time :2024/11/12 14:15
*/
public function three_type(){
return [
1=>'左图右文',
2=>'右图左文',
];
}
/**
* @remark :图片文本框类型
* @name :line_number
* @author :lyh
* @method :post
* @time :2024/11/12 14:15
*/
public function image_three_type(){
return [
1=>'图片悬浮',
2=>'图片固定',
];
}
}
... ...
... ... @@ -136,6 +136,8 @@ class ProjectServer
self::init404Page($project_id);
//初始化模块数据
self::initModule($project_id);
//初始化切换栏
self::initColumn();
//初始化search页面
// self::initSearchPage($project_id);
DB::disconnect('custom_mysql');
... ... @@ -163,6 +165,27 @@ class ProjectServer
}
return true;
}
/**
* @remark :初始化产品切换栏
* @name :initColumn
* @author :lyh
* @method :post
* @time :2024/11/12 11:39
*/
public static function initColumn(){
$info = DB::connection('custom_mysql')->table('gl_product_column')->first();
if(empty($info)){
$data = [
'column_name'=>'Product Details',
'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s')
];
DB::connection('custom_mysql')->table('gl_product_column')->insert($data);
}
return true;
}
/**
* @remark :菜单
* @name :initGroup
... ...