package com.sifang.modules.sys.util;

import com.jfinal.plugin.activerecord.Record;
import com.sifang.modules.sys.common.utils.StringUtil;

import java.util.Objects;

public class FormSetVo {

    private String id;
    private String type;
    private String stage;
    private String stageName;
    private String partnerName;
    private String groupType;
    private String groupTypeName;
    private String columnType;
    private String columnKey;
    private String columnName;
    private String parentSet;
    private Integer sort;
    private String paramName;
    private String limitFlag;
    private String parentMustFillFlag;
    private String mustFillFlag;
    private String groupFlag;
    private String remarks;
    private String useFlag = "0"; // 是否启用：0.否 1.是

    public String getRemarks() {
        return remarks;
    }

    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getStage() {
        return stage;
    }

    public void setStage(String stage) {
        this.stage = stage;
    }

    public String getStageName() {
        return stageName;
    }

    public void setStageName(String stageName) {
        this.stageName = stageName;
    }

    public String getGroupType() {
        return groupType;
    }

    public void setGroupType(String groupType) {
        this.groupType = groupType;
    }

    public String getGroupTypeName() {
        return groupTypeName;
    }

    public void setGroupTypeName(String groupTypeName) {
        this.groupTypeName = groupTypeName;
    }

    public String getColumnKey() {
        return columnKey;
    }

    public void setColumnKey(String columnKey) {
        this.columnKey = columnKey;
    }

    public String getColumnName() {
        return columnName;
    }

    public void setColumnName(String columnName) {
        this.columnName = columnName;
    }

    public Integer getSort() {
        return sort;
    }

    public void setSort(Integer sort) {
        this.sort = sort;
    }

    public String getParamName() {
        return paramName;
    }

    public void setParamName(String paramName) {
        this.paramName = paramName;
    }

    public String getLimitFlag() {
        return limitFlag;
    }

    public void setLimitFlag(String limitFlag) {
        this.limitFlag = limitFlag;
    }

    public String getParentMustFillFlag() {
        return parentMustFillFlag;
    }

    public void setParentMustFillFlag(String parentMustFillFlag) {
        this.parentMustFillFlag = parentMustFillFlag;
    }

    public String getMustFillFlag() {
        return mustFillFlag;
    }

    public void setMustFillFlag(String mustFillFlag) {
        this.mustFillFlag = mustFillFlag;
    }

    public String getUseFlag() {
        return useFlag;
    }

    public void setUseFlag(String useFlag) {
        this.useFlag = useFlag;
    }

    public String getGroupFlag() {
        return groupFlag;
    }

    public void setGroupFlag(String groupFlag) {
        this.groupFlag = groupFlag;
    }

    public String getPartnerName() {
        return partnerName;
    }

    public void setPartnerName(String partnerName) {
        this.partnerName = partnerName;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getColumnType() {
        return columnType;
    }

    public void setColumnType(String columnType) {
        this.columnType = columnType;
    }

    public String getParentSet() {
        return parentSet;
    }

    public void setParentSet(String parentSet) {
        this.parentSet = parentSet;
    }

    //   s.id, s.type, s.`stage`, cp.name as 'partnerName', fs.`name` AS 'stageName', s.`group_type`, c.sample_graph,
//   s.`column_name`, s.`sort`, c.`param_name`, IFNULL(c.`must_fill_flag`, s.`must_fill_flag`) AS must_fill_flag,
//   s.group_flag, s.column_type, s.`column_key`, s.parent_set, gt.name AS 'group_type_name', c.`id` AS cid
    public void setValues(Record r) {
        this.id = r.getStr("id");
        this.stage = r.getStr("stage");
        this.stageName = r.getStr("stageName");
        this.type = r.getStr("type");
        this.partnerName = r.getStr("partnerName");
        this.groupType = r.getStr("group_type");
        this.groupTypeName = r.getStr("group_type_name");
        this.columnType = r.getStr("column_type");
        this.columnKey = r.getStr("column_key");
        this.columnName = r.getStr("column_name");
        this.parentSet = r.getStr("parent_set");
        this.sort = r.getInt("sort");
        this.limitFlag = r.getStr("limit_flag");
        this.parentMustFillFlag = r.getStr("parent_must_fill_flag");
        if (Objects.equals("1", r.getStr("parent_must_fill_flag"))
                || Objects.equals("1", r.getStr("limit_flag"))) {
            this.mustFillFlag = "1";
        } else if (StringUtil.isBlank(r.getStr("must_fill_flag"))) {
            this.mustFillFlag = r.getStr("parent_must_fill_flag");
        } else {
            this.mustFillFlag = r.getStr("must_fill_flag");
        }
        if (Objects.equals("1", r.getStr("parent_must_fill_flag"))
                || Objects.equals("1", r.getStr("limit_flag"))) {
            this.useFlag = "1";
        } else if (StringUtil.isNotBlank(r.getStr("status"))) {
            this.useFlag = r.getStr("status");
        }

        this.paramName = r.getStr("param_name");
        this.groupFlag = r.getStr("group_flag");
        this.remarks = r.getStr("remarks");
        if (StringUtil.isBlank(paramName)) {
            this.paramName = "";
        }
    }
}
