package cn.estsh.i3plus.pojo.report.bean;

import cn.estsh.i3plus.pojo.base.bean.BaseBean;
import cn.estsh.i3plus.pojo.base.enumutil.BlockReportEnumUtil;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.List;

/**
 * @Description :
 * @Reference :
 * @Author : wei.peng
 * @CreateDate : 19-12-3 下午4:01
 * @Modify:
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name="BR_POJO")
@Api(value="报表对象",description = "报表对象")
public class BrPojo extends BaseBean {

    private static final long serialVersionUID = -8490788183629516155L;
    @Column(name="MASTER_ID")
    @ApiParam(value ="主对象ID")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long masterId;

    @Column(name="POJO_TYPE")
    @ApiParam(value ="对象类型")
    private Integer pojoType;

    @Column(name="SOFT_TYPE")
    @ApiParam(value ="产品类型")
    private Integer softType;

    public String getSoftTypeTxt(){
        return softType == null ? null : CommonEnumUtil.SOFT_TYPE.valueOfDescription(softType);
    }

    @Column(name="SOURCE_CODE")
    @ApiParam(value ="数据源编码")
    private String sourceCode;

    @Column(name="SOURCE_TYPE")
    @ApiParam(value ="数据源类型")
    private Integer sourceType;

    @Column(name="SOURCE_NAME")
    @ApiParam(value ="数据源名称")
    private String sourceName;

    @Column(name="POJO_TABLE_NAME")
    @ApiParam(value ="对象表名称")
    private String pojoTableName;

    @Column(name="POJO_TABLE_NAME_ALIAS")
    @ApiParam(value ="对象表别名")
    private String pojoTableNameAlias;

    @Column(name="pojo_name")
    @ApiParam(value ="对象名称")
    private String pojoName;

    @Column(name="POJO_SORT")
    @ApiParam(value ="对象排序")
    private Integer pojoSort;

    @Column(name="POJO_COLUMN_NAME")
    @ApiParam(value ="连接属性")
    private String pojoColumnName;

    @Column(name="JOIN_TYPE")
    @ApiParam(value ="连接关系")
    private Integer joinType;
    public String getJoinTypeTxt(){
        return joinType == null ? null : BlockReportEnumUtil.HQL_REF.valueOfDescription(joinType);
    }

    @Column(name="WHERE_TYPE")
    @ApiParam(value ="连接类型")
    private Integer whereType;
    public String getWhereTypeTxt(){
        return whereType == null ? null : CommonEnumUtil.SQL_WHERE.valueOfDescription(whereType);
    }

    @Column(name="JOIN_POJO_ID")
    @ApiParam(value ="连接对象ID")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long joinPojoId;

    @Column(name="JOIN_POJO_NAME_RDD")
    @ApiParam(value ="连接对象名称")
    private String joinPojoNameRdd;

    @Column(name="JOIN_POJO_CODE_RDD")
    @ApiParam(value ="连接对象名称")
    private String joinTableNameRdd;

    @Column(name="JOIN_POJO_CODE_ALIAS_RDD")
    @ApiParam(value ="连接对象表别名")
    private String joinTableNameAliasRdd;

    @Column(name="JOIN_COLUMN_NAME")
    @ApiParam(value ="连接字段名称")
    private String joinColumnName;

    @Column(name="POJO_SQL")
    @ApiParam(value ="对象名称")
    private String pojoSql;

    @Column(name="POJO_DESCRIPTION")
    @ApiParam(value ="对象描述")
    private String pojoDescription;

    @Transient
    @ApiParam(value = "主对象Pojo 信息")
    private BrPojo masterPojo;

    @Transient
    @ApiParam(value = "连接对象集合")
    private List<BrPojo> joinList;

}
