feat: 添加对应成本分类树接口
This commit is contained in:
34
app/admin/controller/v1/ProductTcoCategory.php
Normal file
34
app/admin/controller/v1/ProductTcoCategory.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\admin\controller\v1;
|
||||
|
||||
use app\admin\model\v1\ProductTcoCategoryModel;
|
||||
|
||||
/**
|
||||
* 产品 - 产品目录分类控制器
|
||||
*/
|
||||
class ProductTcoCategory
|
||||
{
|
||||
// 分类树
|
||||
public function tree()
|
||||
{
|
||||
$param = request()->param(['name']);
|
||||
|
||||
$categorys = ProductTcoCategoryModel::field([
|
||||
'tco_id' => 'id',
|
||||
'tco_pid' => 'pid',
|
||||
'name',
|
||||
])
|
||||
->withSearch(['name'], [
|
||||
'name' => $param['name'] ?? null,
|
||||
])
|
||||
->language(request()->lang_id)
|
||||
->enabled()
|
||||
->order(['id' => 'asc'])
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
return success('获取成功', array_to_tree($categorys, 0, 'pid', false));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user