fix:获取产品类型列表接口修改
This commit is contained in:
parent
ffed76fb13
commit
b301698ec9
@ -35,37 +35,39 @@ class WorksType extends BaseController
|
|||||||
->order('works_type_order')
|
->order('works_type_order')
|
||||||
->column('works_type_guid');
|
->column('works_type_guid');
|
||||||
|
|
||||||
$works_type = ModelWorksType::whereOr([
|
$works_type_tree = [];
|
||||||
[["a.works_type_guid", 'in', $works_type_guids]],
|
if ($works_type_guids) {
|
||||||
[["a.works_type_ancestors_guid", 'REGEXP', implode('|', $works_type_guids)]],
|
$works_type = ModelWorksType::whereOr([
|
||||||
])
|
[["a.works_type_guid", 'in', $works_type_guids]],
|
||||||
->where([['b.works_type_delete_time', 'NULL', null]])
|
[["a.works_type_ancestors_guid", 'REGEXP', implode('|', $works_type_guids)]],
|
||||||
->field([
|
])
|
||||||
'a.works_type_id',
|
->where([['b.works_type_delete_time', 'NULL', null]])
|
||||||
'a.works_type_guid',
|
->field([
|
||||||
'a.works_type_name',
|
'a.works_type_id',
|
||||||
'a.works_type_order',
|
'a.works_type_guid',
|
||||||
'a.works_type_parent_guid',
|
'a.works_type_name',
|
||||||
'a.works_type_ancestors_guid',
|
'a.works_type_order',
|
||||||
'b.works_type_name' => "works_type_parent_name",
|
'a.works_type_parent_guid',
|
||||||
])->alias('a')
|
'a.works_type_ancestors_guid',
|
||||||
->leftjoin('works_type b', 'a.works_type_parent_guid = b.works_type_guid')
|
'b.works_type_name' => "works_type_parent_name",
|
||||||
->order('works_type_order')
|
])->alias('a')
|
||||||
->select()
|
->leftjoin('works_type b', 'a.works_type_parent_guid = b.works_type_guid')
|
||||||
->toArray();
|
->order('works_type_order')
|
||||||
|
->select()
|
||||||
$Traverse = new Traverse('works_type_guid', 'works_type_parent_guid');
|
->toArray();
|
||||||
$works_type_tree = $Traverse->tree($works_type, '0', function ($v) {
|
|
||||||
return [
|
|
||||||
'works_type_name' => $v['works_type_name'],
|
|
||||||
'works_type_parent_name' => $v['works_type_parent_name'],
|
|
||||||
'works_type_guid' => $v['works_type_guid'],
|
|
||||||
'works_type_parent_guid' => $v['works_type_parent_guid'],
|
|
||||||
'works_type_ancestors_guid' => $v['works_type_ancestors_guid'],
|
|
||||||
'works_type_order' => $v['works_type_order'],
|
|
||||||
];
|
|
||||||
});
|
|
||||||
|
|
||||||
|
$Traverse = new Traverse('works_type_guid', 'works_type_parent_guid');
|
||||||
|
$works_type_tree = $Traverse->tree($works_type, '0', function ($v) {
|
||||||
|
return [
|
||||||
|
'works_type_name' => $v['works_type_name'],
|
||||||
|
'works_type_parent_name' => $v['works_type_parent_name'],
|
||||||
|
'works_type_guid' => $v['works_type_guid'],
|
||||||
|
'works_type_parent_guid' => $v['works_type_parent_guid'],
|
||||||
|
'works_type_ancestors_guid' => $v['works_type_ancestors_guid'],
|
||||||
|
'works_type_order' => $v['works_type_order'],
|
||||||
|
];
|
||||||
|
});
|
||||||
|
}
|
||||||
return msg(0, "获取作品类型列表成功!", [
|
return msg(0, "获取作品类型列表成功!", [
|
||||||
'data' => $works_type_tree,
|
'data' => $works_type_tree,
|
||||||
'count' => ModelWorksType::where('works_type_parent_guid', '0')->count()
|
'count' => ModelWorksType::where('works_type_parent_guid', '0')->count()
|
||||||
|
Loading…
Reference in New Issue
Block a user