class AttributeBaseDomainService {

    public List<CategoryAttribute> findAllByCategoryId(Long categoryId) {
        List<Long> ancestorIds = backCategoryDomainReadService.findAncestorIdsOf(categoryId);
        Map<String, CategoryAttribute> leafCtgAttrMap = getAttrModelMap(categoryId);

        ancestorIds.remove(categoryId);
        ancestorIds.stream()
                .sorted(Comparator.reverseOrder())
                .forEach(cid -> {
                    List<CategoryAttribute> attributes = findByCategoryId(cid);
                    for (CategoryAttribute attr : attributes) {
                        // 1. 继承父类属性
                        // 2. 就近原则
                        leafCtgAttrMap.putIfAbsent(attrIdentity(attr), attr);
                    }
                });

        return leafCtgAttrMap.values().stream().
                sorted(Comparator.comparingLong(CategoryAttribute::getIndex)).
                collect(Collectors.toList());
    }

    public  AttributeBaseDomainService(CategoryAttributeDAO categoryAttributeDAO,
                                      BackCategoryDomainReadService backCategoryDomainReadService);

}