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);
|
}
|
}
|