DetailController.php
2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?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;
use Illuminate\Support\Facades\DB;
class DetailController extends BaseController
{
/**
* @remark :获取当前产品的描述详情
* @name :getDetail
* @author :lyh
* @method :post
* @time :2024/11/13 9:53
*/
public function getDetail(Detail $detail,Column $column){
$data_column = $column->list(['product_id'=>['in',[0,$this->map['product_id']]]],'id',['*'],'asc');
$data = $detail->list($this->map,'sort',['*'],'asc');
if(!empty($data_column) && !empty($data)){
foreach ($data_column as $k => $v){
$column_data = [];
foreach ($data as $v1){
if($v['id'] == $v1['column_id']){
$column_data[] = $v1;
}
}
$v['data'] = $column_data;
$data_column[$k] = $v;
}
}
$this->response('success',Code::SUCCESS,$data_column);
}
/**
* @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){
$this->map['product_id'] = ['in',[0,$this->map['product_id'] ?? 0]];
$data = $column->list($this->map,'id',['*'],'asc');
$this->response('success',Code::SUCCESS,$data);
}
}