package com.jcdm.generator.domain;

import java.util.List;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import org.apache.commons.lang3.ArrayUtils;
import com.jcdm.common.constant.GenConstants;
import com.jcdm.common.core.domain.BaseEntity;
import com.jcdm.common.utils.StringUtils;

/**
 * 筝��∴; gen_table
 * 
 * @author jc
 */
public class GenTable extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 膽��� */
    private Long tableId;

    /** 茵���腱� */
    @NotBlank(message = "茵���腱遺��巡減腥�")
    private String tableName;

    /** 茵��菴� */
    @NotBlank(message = "茵��菴遺��巡減腥�")
    private String tableComment;

    /** �活���区;��茵��� */
    private String subTableName;

    /** ��;�活���区;��紊����� */
    private String subTableFkName;

    /** 絎�篏�膠糸��腱�(薤�絖�罸�紊у��) */
    @NotBlank(message = "絎�篏�膠糸��腱遺��巡減腥�")
    private String className;

    /** 篏睡����罔≧�随�crud��茵���篏� tree��茵���篏� sub筝糸�茵���篏�鐚� */
    private String tplCategory;

    /** ��腴�瓜��鐚�element-ui罔∞�� element-plus罔∞��鐚� */
    private String tplWebType;

    /** ������莊�� */
    @NotBlank(message = "������莊��筝��巡減腥�")
    private String packageName;

    /** ����罔≦���� */
    @NotBlank(message = "����罔≦����筝��巡減腥�")
    private String moduleName;

    /** ����筝��≦�� */
    @NotBlank(message = "����筝��≦��筝��巡減腥�")
    private String businessName;

    /** �������遵�� */
    @NotBlank(message = "�������遵��筝��巡減腥�")
    private String functionName;

    /** ����篏��� */
    @NotBlank(message = "篏���筝��巡減腥�")
    private String functionAuthor;

    /** ����篁g���劫�鐚�0zip��膽��� 1���箙�莊��鐚� */
    private String genType;

    /** ����莊��鐚�筝�紂��莅ら々��君緇�鐚� */
    private String genPath;

    /** 筝脂��拭�� */
    private GenTableColumn pkColumn;

    /** 絖�茵�拭�� */
    private GenTable subTable;

    /** 茵���篆≧�� */
    @Valid
    private List<GenTableColumn> columns;

    /** �九�������蕁� */
    private String options;

    /** ��膽���絖�罧� */
    private String treeCode;

    /** ���句���絖�罧� */
    private String treeParentCode;

    /** ����腱医�罧� */
    private String treeName;

    /** 筝�膾ц���ID絖�罧� */
    private String parentMenuId;

    /** 筝�膾ц�����腱医�罧� */
    private String parentMenuName;

    public Long getTableId()
    {
        return tableId;
    }

    public void setTableId(Long tableId)
    {
        this.tableId = tableId;
    }

    public String getTableName()
    {
        return tableName;
    }

    public void setTableName(String tableName)
    {
        this.tableName = tableName;
    }

    public String getTableComment()
    {
        return tableComment;
    }

    public void setTableComment(String tableComment)
    {
        this.tableComment = tableComment;
    }

    public String getSubTableName()
    {
        return subTableName;
    }

    public void setSubTableName(String subTableName)
    {
        this.subTableName = subTableName;
    }

    public String getSubTableFkName()
    {
        return subTableFkName;
    }

    public void setSubTableFkName(String subTableFkName)
    {
        this.subTableFkName = subTableFkName;
    }

    public String getClassName()
    {
        return className;
    }

    public void setClassName(String className)
    {
        this.className = className;
    }

    public String getTplCategory()
    {
        return tplCategory;
    }

    public void setTplCategory(String tplCategory)
    {
        this.tplCategory = tplCategory;
    }

    public String getTplWebType()
    {
        return tplWebType;
    }

    public void setTplWebType(String tplWebType)
    {
        this.tplWebType = tplWebType;
    }

    public String getPackageName()
    {
        return packageName;
    }

    public void setPackageName(String packageName)
    {
        this.packageName = packageName;
    }

    public String getModuleName()
    {
        return moduleName;
    }

    public void setModuleName(String moduleName)
    {
        this.moduleName = moduleName;
    }

    public String getBusinessName()
    {
        return businessName;
    }

    public void setBusinessName(String businessName)
    {
        this.businessName = businessName;
    }

    public String getFunctionName()
    {
        return functionName;
    }

    public void setFunctionName(String functionName)
    {
        this.functionName = functionName;
    }

    public String getFunctionAuthor()
    {
        return functionAuthor;
    }

    public void setFunctionAuthor(String functionAuthor)
    {
        this.functionAuthor = functionAuthor;
    }

    public String getGenType()
    {
        return genType;
    }

    public void setGenType(String genType)
    {
        this.genType = genType;
    }

    public String getGenPath()
    {
        return genPath;
    }

    public void setGenPath(String genPath)
    {
        this.genPath = genPath;
    }

    public GenTableColumn getPkColumn()
    {
        return pkColumn;
    }

    public void setPkColumn(GenTableColumn pkColumn)
    {
        this.pkColumn = pkColumn;
    }

    public GenTable getSubTable()
    {
        return subTable;
    }

    public void setSubTable(GenTable subTable)
    {
        this.subTable = subTable;
    }

    public List<GenTableColumn> getColumns()
    {
        return columns;
    }

    public void setColumns(List<GenTableColumn> columns)
    {
        this.columns = columns;
    }

    public String getOptions()
    {
        return options;
    }

    public void setOptions(String options)
    {
        this.options = options;
    }

    public String getTreeCode()
    {
        return treeCode;
    }

    public void setTreeCode(String treeCode)
    {
        this.treeCode = treeCode;
    }

    public String getTreeParentCode()
    {
        return treeParentCode;
    }

    public void setTreeParentCode(String treeParentCode)
    {
        this.treeParentCode = treeParentCode;
    }

    public String getTreeName()
    {
        return treeName;
    }

    public void setTreeName(String treeName)
    {
        this.treeName = treeName;
    }

    public String getParentMenuId()
    {
        return parentMenuId;
    }

    public void setParentMenuId(String parentMenuId)
    {
        this.parentMenuId = parentMenuId;
    }

    public String getParentMenuName()
    {
        return parentMenuName;
    }

    public void setParentMenuName(String parentMenuName)
    {
        this.parentMenuName = parentMenuName;
    }

    public boolean isSub()
    {
        return isSub(this.tplCategory);
    }

    public static boolean isSub(String tplCategory)
    {
        return tplCategory != null && StringUtils.equals(GenConstants.TPL_SUB, tplCategory);
    }

    public boolean isTree()
    {
        return isTree(this.tplCategory);
    }

    public static boolean isTree(String tplCategory)
    {
        return tplCategory != null && StringUtils.equals(GenConstants.TPL_TREE, tplCategory);
    }

    public boolean isCrud()
    {
        return isCrud(this.tplCategory);
    }

    public static boolean isCrud(String tplCategory)
    {
        return tplCategory != null && StringUtils.equals(GenConstants.TPL_CRUD, tplCategory);
    }

    public boolean isSuperColumn(String javaField)
    {
        return isSuperColumn(this.tplCategory, javaField);
    }

    public static boolean isSuperColumn(String tplCategory, String javaField)
    {
        if (isTree(tplCategory))
        {
            return StringUtils.equalsAnyIgnoreCase(javaField,
                    ArrayUtils.addAll(GenConstants.TREE_ENTITY, GenConstants.BASE_ENTITY));
        }
        return StringUtils.equalsAnyIgnoreCase(javaField, GenConstants.BASE_ENTITY);
    }
}