package org.jeecg.modules.stm.base.classify.vo;

import org.jeecg.modules.stm.base.classify.entity.StClassify;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: yzh
 * @Date 2023/4/8 22:09
 * @Description:
 */
public class ClassifyVo {
    private String label;
    private String value;
    private List<ClassifyVo> options;

    public static ClassifyVo bulidByStClassify(StClassify stClassify) {
        ClassifyVo classifyVo = new ClassifyVo();
        classifyVo.setLabel(stClassify.getClassifyName());
        classifyVo.setValue(stClassify.getClassifyCode());
        return classifyVo;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public List<ClassifyVo> getOptions() {
        return options;
    }

    public void setOptions(List<ClassifyVo> options) {
        this.options = options;
    }

    public void buildOptions(List<StClassify> childClassifys) {
        if(this.options==null){
            this.options = new ArrayList<>();
            ClassifyVo all = new ClassifyVo();
            all.setLabel("全部");
            all.setValue("all");
            this.options.add(all);
        }
        for(StClassify stClassify:childClassifys){
            this.options.add(bulidByStClassify(stClassify));
        }
    }
}
