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