package org.jeecg.modules.dnc.dto; import com.fasterxml.jackson.annotation.JsonIgnore; import org.jeecg.modules.dnc.entity.DeviceGroup; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import org.springframework.beans.BeanUtils; import java.util.List; @Data @NoArgsConstructor @EqualsAndHashCode(callSuper = false) public class DeviceGroupExt extends DeviceGroup { private DeviceGroupExt parent; private List children; @JsonIgnore private String userId; public boolean hasChild() { boolean b = true; if(this.getChildren() == null || this.getChildren().size() < 1) { b = false; } return b; } public List getAllChildren(List groups) { if(this.hasChild()) { List extList = this.getChildren(); for(DeviceGroupExt ext : extList) { groups = ext.getAllChildren(groups); } DeviceGroup group = new DeviceGroup(); BeanUtils.copyProperties(this, group); groups.add(group); }else { DeviceGroup group = new DeviceGroup(); BeanUtils.copyProperties(this, group); groups.add(group); } return groups; } }