在日常的开发工作中,时常会遇到树形结构的封装,比如:树形结构的菜单数据、部门数据等等。最近工作中,指标的树形结构封装场景频繁,比如:校验每个层级的指标权重之和要等于100,指标的满树校验等,接下来我们就来看一下我的思路。

一、准备数据

(1)准备一个指标实体类 

@Data
public class Indicator {

    private String code;

    private String parentCode;

    private String name;

    private Integer weight;

    private List<Indicator> children = Lists.newArrayList();

    public Indicator() {
    }

    public Indicator(String code, String parentCode, String name, Integer weight) {
        this.code = code;
        this.parentCode = parentCode;
        this.name = name;
        this.weight = weight;
    }
}
指标实体类

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-27
  • 2021-04-11
  • 2021-12-07
  • 2022-01-17
  • 2021-10-05
猜你喜欢
  • 2021-11-27
  • 2021-09-26
  • 2021-07-26
  • 2022-12-23
  • 2022-12-23
  • 2021-05-26
  • 2018-10-12
相关资源
相似解决方案