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;

/**
 * @Description :
 * @Reference :
 * @Author : wei.peng
 * @CreateDate : 19-12-3 下午5:10
 * @Modify:
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name="BR_POJO_FILTER_ATTR")
@Api(value="对象筛选器",description = "对象筛选器")
public class BrPojoFilterAttr extends BaseBean {

    private static final long serialVersionUID = 7949763397771577851L;
    @Column(name="FILTER_ID")
    @ApiParam(value ="筛选器ID")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long filterId;

    @Column(name="MASTER_ID")
    @ApiParam(value ="主对象ID")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long masterId;
    /************************************** 对象信息 **************************************/

    @Column(name="POJO_ID")
    @ApiParam(value ="对象ID")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long pojoId;

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

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

    @Column(name="POJO_TABLE_NAME_ALIAS_RDD")
    @ApiParam(value ="对象别名")
    private String pojoTableNameAliasRdd;

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

//    @Column(name="POJO_CODE_NAME")
//    @ApiParam(value ="对象属性")
//    private String pojoCodeName;
//
    @Column(name="POJO_TABLE_COLUMN_NAME")
    @ApiParam(value ="对象属性全路径")
    private String pojoTableColumnName;


    /************************************** 属性信息 **************************************/


    @Column(name="ATTR_NAME")
    @ApiParam(value ="属性显示名称")
    private String attrName;

    @Column(name = "VIEW_ATTR_CONTROL_TYPE")
    @ApiParam(value = "控件类型")
    private Integer viewAttrControlType;

    @Column(name = "VIEW_ATTR_CONTROL_REF_KEY")
    @ApiParam(value = "控件引用RefKey")
    private String viewAttrControlRefKey;

    @Column(name="ATTR_SHOW")
    @ApiParam(value ="属性是否显示")
    private Integer attrShow;
    public String getAttrShowTxt(){
        return attrShow == null ? null : CommonEnumUtil.TRUE_OR_FALSE.valueOfDescription(attrShow);
    }


    @Column(name="ATTR_TYPE")
    @ApiParam(value ="属性类型") // 查询条件 ， 分组
    private Integer attrType;
    public String getAttrTypeTxt(){
        return attrType == null ? null : BlockReportEnumUtil.HQL_ATTR_DATA_TYPE.valueOfDescription(attrType);
    }


    @Column(name="FILTER_JOIN_TYPE") // AND OR 与 或 非
    @ApiParam(value ="属性连接类型")
    private Integer filterJoinType;
    public String getFilterJoinTypeTxt(){
        return filterJoinType == null ? null : BlockReportEnumUtil.HQL_WHERE_REF.valueOfDescription(filterJoinType);
    }

    @Column(name="FILTER_ATTR_TYPE") // = ,like,in
    @ApiParam(value ="属性筛选类型")
    private Integer filterAttrType;
    public String getFilterAttrTypeTxt(){
        return filterAttrType == null ? null : CommonEnumUtil.SQL_WHERE.valueOfDescription(filterAttrType);
    }

    @Column(name="ATTR_SORT")
    @ApiParam(value ="属性筛选排序")
    private Integer attrSort;

    @Column(name="ATTR_DEFAULT_VALUE")
    @ApiParam(value ="属性默认值")
    private String attrDefaultValue;

    @Column(name="ATTR_DESCRIPTION")
    @ApiParam(value ="属性描述")
    private String attrDescription;

    @Column(name="ATTR_HQL")
    @ApiParam(value ="属性HQL")
    private String attrHql;

    @Transient
    @ApiParam(value ="表单查询内容")
    private String attrFormValue;
}
