|
|
|
<?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++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|