shiyunteng
2026-06-11 45847670fea5d7354c2bfb4b53a321887271dcd4
platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ProductServiceImpl.java
@@ -1,18 +1,26 @@
package com.by4cloud.platformx.business.service.impl;
import cn.hutool.core.bean.BeanUtil;
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.ArrayUtil;
import cn.hutool.core.util.ObjUtil;
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.business.vo.ProductTreeVo;
import com.by4cloud.platformx.common.core.util.R;
import com.by4cloud.platformx.common.data.datascope.DataScope;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import jakarta.validation.constraints.NotNull;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -32,9 +40,9 @@
        Long parent = parentId == null ? 0l : parentId;
        List<TreeNode<Long>> collect = baseMapper
                .selectList(Wrappers.<Product>lambdaQuery()
                .selectListByScope(Wrappers.<Product>lambdaQuery()
                        .like(StrUtil.isNotBlank(productName), Product::getProductName, productName)
                        .orderByAsc(Product::getCreateTime))
                        .orderByAsc(Product::getCreateTime), DataScope.of("comp_id"))
                .stream().map(getNodeFunction()).collect(Collectors.toList());
        // 模糊查询 不组装树结构 直接返回 表格方便编辑
@@ -50,7 +58,13 @@
        return TreeUtil.build(collect, parent);
    }
    @NotNull
   @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<>();
@@ -59,7 +73,7 @@
            node.setParentId(product.getParentId());
            //node.setWeight(product.getParentId());
            // 扩展属性
            Map<String, Object> extra = new HashMap<>();
//            Map<String, Object> extra = new HashMap<>();
//            extra.put("picPath", category.getPicPath());
//            extra.put("Type", category.getType());
//            extra.put("isShow", category.getIsShow());
@@ -67,7 +81,7 @@
//            extra.put("status", category.getStatus());
            // 适配 vue3
            Map<String, Object> meta = new HashMap<>();
//            Map<String, Object> meta = new HashMap<>();
           /* meta.put("title", product.getProductName());
            meta.put("icon", product.getPrice());*/