package com.ruoyi.common.model;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

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

@Data
@NoArgsConstructor
@AllArgsConstructor
public class ExportField {
    private String fieldName;          // 字段名
    private String columnName;         // 列名（显示名称）
    private Integer order;             // 排序
    private Boolean selected;          // 是否选中
    private String parent;             // 父级字段名（用于构建层级）
    private Integer level;             // 层级（0开始）
    private List<ExportField> children; // 子字段
    private Boolean hasChildren;       // 是否有子字段
    private Integer columnSpan;

    // 新增字段，支持行合并
    private Boolean mergeable = false;        // 是否支持行合并
    private String listField;                 // 列表字段名（如 "qualityChecks"）
    private String listProperty;              // 列表属性名（如 "checkItem"）
    private Integer mergeGroup;               // 合并分组

    public Boolean isHasChildren() {
        return hasChildren;
    }

    public ExportField(String fieldName, String columnName, Integer order) {
        this.fieldName = fieldName;
        this.columnName = columnName;
        this.order = order;
        this.selected = true;
        this.level = 0;
        this.children = new ArrayList<>();
        this.hasChildren = false;
    }
    public ExportField(String fieldName, String columnName, Integer order, Integer level,List<ExportField> children,Boolean hasChildren) {
        this.fieldName = fieldName;
        this.columnName = columnName;
        this.order = order;
        this.selected = true;
        this.level = level;
        this.children = children;
        this.hasChildren = hasChildren;
    }
}