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

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

import javax.persistence.*;
import java.util.List;

/**
 * @Description : 报表实例
 * @Reference :
 * @Author : alwaysfrin
 * @CreateDate : 2018-12-25 19:54
 * @Modify:
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name="BR_REPORT")
@Api(value="自定义报表",description = "所有报表实例，生成最后的报表")
public class BrReport extends BaseBean {

    @Column(name="REPORT_NAME")
    @ApiParam(value ="报表名称")
    private String reportName;

    @Column(name="LAYOUT_ID")
    @ApiParam(value ="布局主键")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long layoutId;

    //get单独处理
    public Long getLayoutId() {
        if(layoutId != null) {
            return layoutId.longValue();
        }else{
            return layoutId;
        }
    }

    @Column(name="LAYOUT_NAME_RDD")
    @ApiParam(value ="布局名称")
    private String layoutNameRdd;

    @Lob
    @Column(name="LAYOUT_HTML")
    @ApiParam(value ="报表html")
    private String reportHtml;

    @Column(name="SEQ")
    @ApiParam(value ="排序")
    private Integer seq;

    @Column(name="TEMPLATE_NUM")
    @ApiParam(value ="模板数量")
    private Integer templateNum;

    @Column(name="ELEMENT_NUM")
    @ApiParam(value ="元素数量")
    private Integer elementNum;

    @Lob
    @Column(name = "REPORT_DESCRIPTION")
    @ApiParam(value ="报表描述")
    private String reportDescription;

    @Transient
    @ApiParam(value = "报表关联布局对象")
    private BrLayout brLayout;

    @Transient
    @ApiParam(value = "报表排版关系")
    private List<BrRefReportTypeset> brRefReportTypesetList;
}
