package com.cm.common.plugin.pojo.vos.database.table;

import com.cm.common.annotation.CheckEmptyAnnotation;
import com.cm.common.annotation.CheckNumberAnnotation;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

/**
 * When you feel like quitting. Think about why you started
 * 当你想要放弃的时候，想想当初你为何开始
 *
 * @ClassName: TableColumnVO
 * @Description: 表列表
 * @Author: WangGeng
 * @Date: 2019/11/15 14:47
 * @Version: 1.0
 **/
@ApiModel
public class TableColumnVO {

    @ApiModelProperty(name = "columnName", value = "字段名称")
    @CheckEmptyAnnotation(name = "字段名称")
    private String columnName;

    @ApiModelProperty(name = "columnDefault", value = "默认值")
    private String columnDefault;

    @ApiModelProperty(name = "isNullable", value = "可空")
    @CheckEmptyAnnotation(name = "可空", types = {"YES", "NO"})
    private String isNullable;

    @ApiModelProperty(name = "dataType", value = "类型")
    @CheckEmptyAnnotation(name = "类型", types = {"int", "double", "bigint", "datetime", "date", "varchar", "char", "text", "longtext"})
    private String dataType;

    @ApiModelProperty(name = "columnLength", value = "长度")
    @CheckNumberAnnotation(name = "长度")
    private Integer columnLength;

    @ApiModelProperty(name = "columnFloatLength", value = "小数点")
    private Integer columnFloatLength;

    @ApiModelProperty(name = "columnComment", value = "字段注释")
    private String columnComment;

    public String getColumnName() {
        return columnName == null ? "" : columnName.trim();
    }

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

    public String getColumnDefault() {
        return columnDefault == null ? "" : columnDefault.trim();
    }

    public void setColumnDefault(String columnDefault) {
        this.columnDefault = columnDefault;
    }

    public String getIsNullable() {
        return isNullable == null ? "" : isNullable.trim();
    }

    public void setIsNullable(String isNullable) {
        this.isNullable = isNullable;
    }

    public String getDataType() {
        return dataType;
    }

    public void setDataType(String dataType) {
        this.dataType = dataType;
    }

    public Integer getColumnLength() {
        return columnLength;
    }

    public void setColumnLength(Integer columnLength) {
        this.columnLength = columnLength;
    }

    public Integer getColumnFloatLength() {
        return columnFloatLength;
    }

    public void setColumnFloatLength(Integer columnFloatLength) {
        this.columnFloatLength = columnFloatLength;
    }

    public String getColumnComment() {
        return columnComment == null ? "" : columnComment.trim();
    }

    public void setColumnComment(String columnComment) {
        this.columnComment = columnComment;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("{");
        sb.append("\"columnName\":")
                .append("\"").append(columnName).append("\"");
        sb.append(",\"columnDefault\":")
                .append("\"").append(columnDefault).append("\"");
        sb.append(",\"isNullable\":")
                .append("\"").append(isNullable).append("\"");
        sb.append(",\"dataType\":")
                .append(dataType);
        sb.append(",\"columnLength\":")
                .append(columnLength);
        sb.append(",\"columnFloatLength\":")
                .append(columnFloatLength);
        sb.append(",\"columnComment\":")
                .append("\"").append(columnComment).append("\"");
        sb.append('}');
        return sb.toString();
    }
}
