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.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 * @Description :
 * @Reference :
 * @Author : yunhao
 * @CreateDate : 2019-03-21 19:07
 * @Modify:
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name="BF_INTERCEPT_DETAIL")
@Api(value="拦截器明细")
public class BfInterceptDetail extends BaseBean {

    private static final long serialVersionUID = -2813973524088674573L;
    @Column(name="INTERCEPT_ID")
    @ApiParam(value ="拦截器id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long interceptId;

    @Column(name="INTERCEPT_NAME_RDD")
    @ApiParam(value ="拦截器名称")
    private String interceptNameRdd;

    @Column(name="INTERCEPT_TYPE")
    @ApiParam(value ="拦截器类型")
    private Integer interceptType;

    // 枚举 BlockFormEnumUtil.INTERCEPT_POSITION
    @Column(name="INTERCEPT_POSITION")
    @ApiParam(value ="拦截器位置")
    private Integer interceptPosition;

    public int getInterceptPositionVal() {
        if(this.interceptPosition == null){
            return 0;
        } else {
            return this.interceptPosition.intValue();
        }
    }

    @Column(name="INTERCEPT_TARGET_ID")
    @ApiParam(value ="拦截目标id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long interceptTargetId;

    @Column(name="INTERCEPT_TARGET_NAME_RDD")
    @ApiParam(value ="拦截目标名称")
    private String interceptTargetNameRdd;

    @Column(name="INTERCEPT_PROCESS_RESULT")
    @ApiParam(value ="拦截器业务结果处理")
    private Integer interceptProcessResult;

    public int getInterceptProcessResultVal(){
        if(interceptProcessResult == null ){
            return 0;
        }
        return interceptProcessResult.intValue();
    }

    @Column(name="INTERCEPT_EXECUTE_SORT")
    @ApiParam(value ="拦截器业务执行顺序")
    private Integer interceptExecuteSort;

    public int getInterceptExecuteSortVal(){
        if(interceptExecuteSort == null ){
            return 0;
        }
        return interceptExecuteSort.intValue();
    }

    @Transient
    @ApiParam(value = "拦截器")
    private BfIntercept intercept;

}
