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;

/**
 * @Description :
 * @Reference :
 * @Author : yunhao
 * @CreateDate : 2019-03-21 20:21
 * @Modify:
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name = "BF_BUTTON")
@Api(value = "表单按钮", description = "表单按钮")
public class BfButton extends BaseBean {

    private static final long serialVersionUID = -1675967061983417558L;
    @Column(name = "BUTTON_NAME")
    @ApiParam(value = "按钮名称")
    private String buttonName;

    // 枚举:BlockFormEnumUtil.BUTTON_TRIGGER_EFFECT
    @Column(name = "TRIGGER_MODE")
    @ApiParam(value = "触发方式")
    private Integer triggerMode;

    public int getTriggerModeVal() {
        if (triggerMode == null) {
            return 0;
        } else {
            return triggerMode.intValue();
        }
    }

    @Column(name = "IS_NEED_SELECT_DATA")
    @ApiParam(value = "是否需要选中数据")
    private Integer isNeedSelectData;

    @Column(name = "IS_REFRESH")
    @ApiParam(value = "是否刷新")
    private Integer isRefresh;


    // 关联表单功能表id
    @Column(name = "METHOD_ID")
    @ApiParam(value = "表单功能id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long methodId;

    @Column(name = "METHOD_NAME_RDD")
    @ApiParam(value = "表单功能名称")
    private String methodNameRdd;

    // 执行类方法,sql,脚本
    @Column(name = "METHOD_CONTENT")
    @ApiParam(value = "执行内容")
    private String methodContent;

    @Column(name = "BUTTON_DESCRIPTION")
    @ApiParam(value = "按钮描述")
    private String buttonDescription;
}
