package com.cool.bang.modules.generate.domain.po;


import com.cool.bang.common.constant.GenConstant;
import com.cool.bang.common.constant.enums.StatusType;
import com.cool.bang.common.tools.secure.SecurityUtil;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * database table info
 *
 * @author PeiZhi Guo
 * 2021-3-26 11:35
 */
public class TableInfo implements Serializable {

    private static final long serialVersionUID = 1L;

    private Long id;

    /** 表名称 */
    private String tableName;

    /** 表描述 */
    private String tableComment;

    /** 表前缀 */
    private String tablePrefix;

    /** 实体类名称 */
    private String className;

    /** 开发者名称 */
    private String functionAuthor;

    /** 模版类型 */
    private String template;

    /** 生成代码统类型 [0 zip压缩包 1 自定义路径] */
    private String genType;

    /** 生成路径 */
    private String genPath;

    /** 包路径 */
    private String packageName;

    /** 模块名 */
    private String moduleName;

    /** 业务名 */
    private String businessName;

    /** 功能名称 */
    private String functionName;

    private Long parentMenu;

    /** 创建时间 */
    private Date createTime;

    /** 创建人 */
    private Long createBy;

    /** 更新时间 */
    private Date updateTime;

    /** 更新人 */
    private Long updateBy;

    /** 备注说明 */
    private String remark;

    /** 删除标识 0 删除 1正常 */
    private Integer delFlag;

    /** 表字段 */
    private List<TableColumnInfo> columns;

    public void insertConfigure() {
        Long userId = SecurityUtil.getCurrentUser().getId();
        this.createBy = userId;
        this.updateBy = userId;
        this.createTime = new Date();
        this.updateTime = new Date();
        this.delFlag = StatusType.ENABLE.ordinal();
    }

    public void updateConfigure() {
        Long userId = SecurityUtil.getCurrentUser().getId();
        this.updateTime = new Date();
        this.updateBy = userId;
    }

    public boolean isSuperColumn(String javaField) {
        return StringUtils.equalsAnyIgnoreCase(javaField, GenConstant.BASE_ENTITY);
    }

    public Long getId() {
        return id;
    }

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

    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 getTablePrefix() {
        return tablePrefix;
    }

    public void setTablePrefix(String tablePrefix) {
        this.tablePrefix = tablePrefix;
    }

    public String getClassName() {
        return className;
    }

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

    public String getFunctionAuthor() {
        return functionAuthor;
    }

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

    public String getTemplate() {
        return template;
    }

    public void setTemplate(String template) {
        this.template = template;
    }

    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 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 Long getParentMenu() {
        return parentMenu;
    }

    public void setParentMenu(Long parentMenu) {
        this.parentMenu = parentMenu;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Long getCreateBy() {
        return createBy;
    }

    public void setCreateBy(Long createBy) {
        this.createBy = createBy;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public Long getUpdateBy() {
        return updateBy;
    }

    public void setUpdateBy(Long updateBy) {
        this.updateBy = updateBy;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Integer getDelFlag() {
        return delFlag;
    }

    public void setDelFlag(Integer delFlag) {
        this.delFlag = delFlag;
    }

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

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