package cn.estsh.i3plus.pojo.form.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.ApiParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

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

/**
 * @Description : 自定义表单布局
 * @Reference :
 * @Author : yunhao
 * @CreateDate : 2019-03-21 13:54
 * @Modify:
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name = "BF_LAYOUT_ROW")
@Api(value = "自定义表单布局-行")
public class BfLayoutRow extends BaseBean {

    private static final long serialVersionUID = -3327441937912038000L;
    @Column(name = "LAYOUT_ID")
    @ApiParam(value = "布局主键")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long layoutId;

    @Column(name = "ROW_HEIGHT")
    @ApiParam(value = "行高")
    private Integer rowHeight;

    @Column(name = "ROW_SORT")
    @ApiParam(value = "排序")
    private Integer rowSort;

    @Lob
    @Column(name = "ROW_STYLE")
    @ApiParam(value = "行样式")
    private String rowStyle;

    @Column(name = "ROW_COL_NUM")
    @ApiParam(value = "行所关联列数")
    private Integer rowColNum;

    public int getRowColNumValue(){
        if(rowColNum == null){
            return 0;
        }
        return rowColNum.intValue();
    }

    // 行所包含的列
    @Transient
    private List<BfLayoutColumn> bfLayoutColumns;
}
