| | |
| | | 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; |
| | |
| | | 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()); |
| | | |
| | | // 模糊查询 不组装树结构 直接返回 表格方便编辑 |
| | |
| | | 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<>(); |
| | |
| | | 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()); |
| | |
| | | // 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());*/ |
| | | |