feat: 添加对应成本分类树接口

This commit is contained in:
2025-03-12 16:31:22 +08:00
parent 89ae83f8f8
commit ac8f9013a4
3 changed files with 78 additions and 1 deletions

View 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));
}
}