package org.example.Entity.System;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.example.Enums.SystemTypeEnums;
import org.example.Utils.DataTableUtil;
import org.example.Utils.PublicUtil;
import org.example.Utils.NativeExtensionUtils;

import java.util.Map;

/**
 * 移动端卡片实体类
 * 创建时间：2020-07-22 18:07:38
 */
public class MobileCard {
    private Map<String, Object> row;

    // 构造方法
    public MobileCard() {
    }

    public MobileCard(Map<String, Object> row) {
        this();
        this.row = row;
    }

    // 分组名称
    private String groupName;

    @JsonIgnore
    public String getGroupName() {
        if (groupName == null) {
            groupName = DataTableUtil.getStringValue(row, "groupname", "");
        }
        return groupName;
    }

    public void setGroupName(String groupName) {
        this.groupName = groupName;
    }

    // 列名
    private String colName;

    @JsonIgnore
    public String getColName() {
        if (colName == null) {
            colName = DataTableUtil.getStringValue(row, "colname", "");
        }
        return colName;
    }

    public void setColName(String colName) {
        this.colName = colName;
    }

    // 分组可见性
    private String groupVisible;

    @JsonIgnore
    public boolean isGroupVisible() {
        if (groupVisible == null) {
            groupVisible = DataTableUtil.getStringValue(row, "groupvisible", "");
        }
        return !"0".equals(groupVisible);
    }

    // 分组详情
    private String groupDetail;

    @JsonIgnore
    public String getGroupDetail() {
        if (groupDetail == null) {
            groupDetail = DataTableUtil.getStringValue(row, "groupdetail", "");
        }
        return groupDetail;
    }

    // 行号
    private Integer rowId;
    @JsonProperty("RowId")
    public int getRowId() {
        if (rowId == null) {
            rowId = NativeExtensionUtils.ToInt32(DataTableUtil.getStringValue(row, "rowid", ""));
        }
        return rowId;
    }

    public void setRowId(int rowId) {
        this.rowId = rowId;
    }

    private Integer _colId;

    @JsonProperty("ColId")
    public int getColId() {
        return (int) ( NativeExtensionUtils.ToInt32(DataTableUtil.getStringValue(row, "colid", "")));
    }

    public void setColId(int _colId) {
        this._colId = _colId;
    }
    // 明细ID
    private Integer mxId;

    @JsonIgnore
    public int getMxId() {
        if (mxId == null) {
            mxId = NativeExtensionUtils.ToInt32(DataTableUtil.getStringValue(row, "mxid", ""));
        }
        return mxId;
    }

    public void setMxId(int mxId) {
        this.mxId = mxId;
    }

    // 行高
    private Integer rowHeight;
    @JsonProperty("RowHeight")
    public int getRowHeight() {
        if (rowHeight == null) {
            rowHeight = NativeExtensionUtils.ToInt32(DataTableUtil.getStringValue(row, "rowheight", ""));
        }
        return rowHeight;
    }

    public void setRowHeight(int rowHeight) {
        this.rowHeight = rowHeight;
    }

    // 宽度
    private String width;
    @JsonProperty("width")
    public String getWidth() {
        if (width == null) {
            width = DataTableUtil.getStringValue(row, "width", "");
        }
        return width;
    }

    public void setWidth(String width) {
        this.width = width;
    }

    // 下边线
    private Boolean splitLine;
    @JsonProperty("SplitLine")
    public boolean isSplitLine() {
        if (splitLine == null) {
            splitLine = NativeExtensionUtils.toBoolean(DataTableUtil.getStringValue(row, "splitline", "0"));
        }
        return splitLine;
    }

    public void setSplitLine(boolean splitLine) {
        this.splitLine = splitLine;
    }

    // 行内容
    private String displayText;

    @JsonProperty("Content")
    public String getContent() {
        if (displayText == null) {
            displayText = DataTableUtil.getStringValue(row, "displaytext", "");
        }
        return displayText;
    }

    public void setContent(String content) {
        this.displayText = content;
    }

    // 字体
    private String fontFamilyt;
    @JsonProperty("FontFamily")
    public String getFontFamily() {
        if (fontFamilyt == null) {
            fontFamilyt = DataTableUtil.getStringValue(row, "fontname", "");
        }
        return fontFamilyt;
    }

    public void setFontFamily(String fontFamily) {
        this.fontFamilyt = fontFamily;
    }

    // 字体大小
    private Integer fontSize;
    @JsonProperty("FontSize")
    public int getFontSize() {
        if (fontSize == null) {
            fontSize = NativeExtensionUtils.ToInt32(DataTableUtil.getStringValue(row, "fontsize", ""));
        }
        return fontSize;
    }

    public void setFontSize(int fontSize) {
        this.fontSize = fontSize;
    }

    // 字体颜色
    private String fColor;
    @JsonProperty("FColor")
    public String getFColor() {
        if (fColor == null) {
            fColor = DataTableUtil.getStringValue(row, "fcolor", "");
        }
        return fColor;
    }

    public void setFColor(String fColor) {
        this.fColor = fColor;
    }

    // 背景颜色
    private String bgColor;
    @JsonProperty("BgColor")
    public String getBgColor() {
        if (bgColor == null) {
            bgColor = DataTableUtil.getStringValue(row, "bcolor", "");
        }
        return bgColor;
    }

    public void setBgColor(String bgColor) {
        this.bgColor = bgColor;
    }

    // dbColor属性
    private String dbColor;
    @JsonProperty("DbColor")
    public String getDbColor() {
        if (dbColor == null) {
            dbColor = DataTableUtil.getStringValue(row, "dbcolor", "");
        }
        return dbColor;
    }

    public void setDbColor(String dbColor) {
        this.dbColor = dbColor;
    }

    // dfColor属性
    private String dfColor;
    @JsonProperty("DfColor")
    public String getDfColor() {
        if (dfColor == null) {
            dfColor = DataTableUtil.getStringValue(row, "dfcolor", "");
        }
        return dfColor;
    }

    public void setDfColor(String dfColor) {
        this.dfColor = dfColor;
    }

    // 加粗
    private Boolean bold;
    @JsonProperty("Bold")
    public boolean isBold() {
        if (bold == null) {
            bold = NativeExtensionUtils.toBoolean(DataTableUtil.getStringValue(row, "fbold", "0"));
        }
        return bold;
    }

    public void setBold(boolean bold) {
        this.bold = bold;
    }

    // 倾斜
    private Boolean fitalic;
    @JsonProperty("Fitalic")
    public boolean isFitalic() {
        if (fitalic == null) {
            fitalic = NativeExtensionUtils.toBoolean(DataTableUtil.getStringValue(row, "fitalic", "0"));
        }
        return fitalic;
    }

    public void setFitalic(boolean fitalic) {
        this.fitalic = fitalic;
    }

    // 删除线
    private Boolean fstrikeline;
    @JsonProperty("FStrikeLine")
    public boolean isFStrikeLine() {
        if (fstrikeline == null) {
            fstrikeline = NativeExtensionUtils.toBoolean(DataTableUtil.getStringValue(row, "fstrikeline", "0"));
        }
        return fstrikeline;
    }

    public void setFStrikeLine(boolean fstrikeline) {
        this.fstrikeline = fstrikeline;
    }

    // 靠右对齐
    private Boolean rightAlign;
    @JsonProperty("RightAlign")
    public boolean isRightAlign() {
        if (rightAlign == null) {
            rightAlign = NativeExtensionUtils.toBoolean(DataTableUtil.getStringValue(row, "RightAlign", "0"));
        }
        return rightAlign;
    }

    public void setRightAlign(boolean rightAlign) {
        this.rightAlign = rightAlign;
    }

    // 显示类型 --0=普通，1=电话，2=QQ，3=微信，4=网站，5=地图
    private Integer displayType;
    @JsonProperty("DType")
    public int getDType() {
        if (displayType == null) {
            displayType = NativeExtensionUtils.ToInt32(DataTableUtil.getStringValue(row, "displayType", ""));
        }
        return displayType;
    }

    public void setDType(int dType) {
        this.displayType = dType;
    }

    // 显示条件
    private String displayCond;
    @JsonProperty("Cond")
    public String getCond() {
        if (displayCond != null) {
            return displayCond;
        }
        displayCond = DataTableUtil.getStringValue(row, "displayCond", null);
        if (displayCond != null && !displayCond.isEmpty()) {
            displayCond = PublicUtil.ReqSqlPmsByRow(
                    null,
                    null,
                    PublicUtil.SqlToCode(displayCond),
                    SystemTypeEnums.PmType.ignorenull
            );
        }
        return displayCond;
    }

    public void setCond(String cond) {
        this.displayCond = cond;
    }

    // 文字居中方式 1，2,3 左，中，右
    private Integer align;
    @JsonProperty("Align")
    public int getAlign() {
        if (align == null) {
            align = NativeExtensionUtils.ToInt32(DataTableUtil.getStringValue(row, "textAlign", "1"));
        }
        return align;
    }

    public void setAlign(int align) {
        this.align = align;
    }
}