From b0ba33dce8487581d2bb3c49f886d158724dc44e Mon Sep 17 00:00:00 2001
From: shiyunteng <shiyunteng@example.com>
Date: 星期一, 08 六月 2026 17:19:49 +0800
Subject: [PATCH] fix:产品列表接口

---
 platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ProductServiceImpl.java |   69 ++++++++++++++++++++++++++++++++++
 1 files changed, 69 insertions(+), 0 deletions(-)

diff --git a/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ProductServiceImpl.java b/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ProductServiceImpl.java
index b389286..331d6da 100644
--- a/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ProductServiceImpl.java
+++ b/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ProductServiceImpl.java
@@ -1,10 +1,25 @@
 package com.by4cloud.platformx.business.service.impl;
 
+import cn.hutool.core.lang.tree.Tree;
+import cn.hutool.core.lang.tree.TreeNode;
+import cn.hutool.core.lang.tree.TreeUtil;
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.by4cloud.platformx.business.entity.Product;
 import com.by4cloud.platformx.business.mapper.ProductMapper;
 import com.by4cloud.platformx.business.service.ProductService;
+import com.by4cloud.platformx.common.data.datascope.DataScope;
+import jakarta.validation.constraints.NotNull;
+import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
 /**
  * 浜у搧淇℃伅
  *
@@ -13,4 +28,58 @@
  */
 @Service
 public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements ProductService {
+    @Override
+    public List<Tree<Long>> treeList(Long parentId, String productName) {
+        Long parent = parentId == null ? 0l : parentId;
+
+        List<TreeNode<Long>> collect = baseMapper
+                .selectListByScope(Wrappers.<Product>lambdaQuery()
+                        .like(StrUtil.isNotBlank(productName), Product::getProductName, productName)
+                        .orderByAsc(Product::getCreateTime), DataScope.of("comp_id"))
+                .stream().map(getNodeFunction()).collect(Collectors.toList());
+
+        // 妯$硦鏌ヨ 涓嶇粍瑁呮爲缁撴瀯 鐩存帴杩斿洖 琛ㄦ牸鏂逛究缂栬緫
+        if (StrUtil.isNotBlank(productName)) {
+            return collect.stream().map(node -> {
+                Tree<Long> tree = new Tree<>();
+                tree.putAll(node.getExtra());
+                BeanUtils.copyProperties(node, tree);
+                return tree;
+            }).collect(Collectors.toList());
+        }
+
+        return TreeUtil.build(collect, parent);
+    }
+
+	@Override
+	public List<Product> getProductList(Product product) {
+		return baseMapper.getProductListByScope(product,DataScope.of("comp_id"));
+	}
+
+	@NotNull
+    private Function<Product, TreeNode<Long>> getNodeFunction() {
+        return product -> {
+            TreeNode<Long> node = new TreeNode<>();
+            node.setId(product.getId());
+            node.setName(product.getProductName());
+            node.setParentId(product.getParentId());
+            //node.setWeight(product.getParentId());
+            // 鎵╁睍灞炴��
+//            Map<String, Object> extra = new HashMap<>();
+//            extra.put("picPath", category.getPicPath());
+//            extra.put("Type", category.getType());
+//            extra.put("isShow", category.getIsShow());
+//            extra.put("iconPicPath", category.getIconPath());
+//            extra.put("status", category.getStatus());
+
+            // 閫傞厤 vue3
+//            Map<String, Object> meta = new HashMap<>();
+           /* meta.put("title", product.getProductName());
+            meta.put("icon", product.getPrice());*/
+
+            //extra.put("meta", meta);
+            //node.setExtra(extra);
+            return node;
+        };
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.1