lyh
2025-06-16 24e0bdd24a10449c98013cdb5bcc5e37735f5a91
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package org.jeecg.modules.dnc.dto;
 
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import org.jeecg.modules.dnc.entity.ComponentInfo;
import org.jeecg.modules.dnc.entity.ProductInfo;
 
import java.util.ArrayList;
import java.util.List;
 
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class ComponentHierarchy {
    private ProductInfo rootProduct;
    private final List<ComponentInfo> components = new ArrayList<>(); // 从根部件到底层部件的顺序
 
    public void addComponentToTop(ComponentInfo component) {
        components.add(0, component);
    }
 
    public List<ComponentInfo> getComponentsFromTop() {
        return new ArrayList<>(components);
    }
 
    public ComponentInfo getLeafComponent() {
        return components.isEmpty() ? null : components.get(components.size() - 1);
    }
}