feat 产品类目接口
This commit is contained in:
parent
c151191430
commit
f03755613e
70
app/api/controller/Products/ProductType.php
Normal file
70
app/api/controller/Products/ProductType.php
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\controller\Products;
|
||||||
|
|
||||||
|
use app\BaseController;
|
||||||
|
use app\common\model\Products\ProductType as ModelProductType;
|
||||||
|
use app\common\arw\adjfut\src\Traverse;
|
||||||
|
use app\Request;
|
||||||
|
use think\Validate;
|
||||||
|
use think\exception\ValidateException;
|
||||||
|
use think\facade\Filesystem;
|
||||||
|
use app\common\arw\adjfut\src\Excel;
|
||||||
|
use app\common\arw\adjfut\src\UploadFile;
|
||||||
|
use app\common\exception\Tool;
|
||||||
|
use think\facade\Db;
|
||||||
|
use think\facade\Env;
|
||||||
|
|
||||||
|
class ProductType extends BaseController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 获取产品系列树形列表接口接口
|
||||||
|
*
|
||||||
|
* @param Request request
|
||||||
|
* @date 2023-04-03
|
||||||
|
* @example
|
||||||
|
* @author xjh
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function getProductTypeTree(Request $request): array
|
||||||
|
{
|
||||||
|
$con = Tool::getOptionalQuery(
|
||||||
|
['b.product_delete_time', 'NULL'],
|
||||||
|
['a.product_type_name', 'LIKE']
|
||||||
|
);
|
||||||
|
|
||||||
|
$product_type = ModelProductType::field([
|
||||||
|
'a.product_type_parent_guid',
|
||||||
|
'a.product_type_name',
|
||||||
|
'a.product_type_title',
|
||||||
|
'a.product_type_link',
|
||||||
|
'b.product_type_name' => "product_type_parent_name",
|
||||||
|
'a.product_type_order',
|
||||||
|
'a.product_type_guid',
|
||||||
|
'a.product_type_id',
|
||||||
|
'a.product_type_icon',
|
||||||
|
])
|
||||||
|
->alias('a')
|
||||||
|
->leftjoin('product_type b', 'a.product_type_parent_guid = b.product_type_guid')
|
||||||
|
->where($con)
|
||||||
|
->order(['product_type_order' => 'asc'])
|
||||||
|
->select()->toArray();
|
||||||
|
|
||||||
|
$Traverse = new Traverse('product_type_guid', 'product_type_parent_guid');
|
||||||
|
$product_type_tree = $Traverse->tree($product_type, '0', function ($v) {
|
||||||
|
return [
|
||||||
|
'product_type_name' => $v['product_type_name'],
|
||||||
|
'product_type_title' => $v['product_type_title'],
|
||||||
|
'product_type_link' => $v['product_type_link'],
|
||||||
|
'product_type_parent_name' => $v['product_type_parent_name'],
|
||||||
|
'product_type_guid' => $v['product_type_guid'],
|
||||||
|
'product_type_id' => $v['product_type_id'],
|
||||||
|
'product_type_parent_guid' => $v['product_type_parent_guid'],
|
||||||
|
'product_type_order' => $v['product_type_order'],
|
||||||
|
'product_type_icon' => $v['product_type_icon'],
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
return msg("获取产品系列列表成功!", $product_type_tree);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user