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

import cn.estsh.i3plus.pojo.base.annotation.AnnoOutputColumn;
import cn.estsh.i3plus.pojo.base.bean.BaseBean;
import cn.estsh.i3plus.pojo.base.enumutil.BlockSoftSwitchEnumUtil;
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-08-13 9:21
 * @Modify:
 */
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name = "BS_SUIT_CASE_DATA_SOURCE_TABLE")
@Api(value = "数据库表操作", description = "数据库表操作")
public class BsSuitCaseDataSourceTable extends BaseBean {

    private static final long serialVersionUID = 3674958775373712985L;
    @Column(name = "SUIT_CASE_ID")
    @ApiParam(value = "套件id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long suitCaseId;

    @Column(name = "OPERATE_NAME")
    @ApiParam(value = "操作名称")
    private String operateName;

    @Column(name = "OPERATE_TYPE_ID")
    @ApiParam(value = "操作类型")
    @AnnoOutputColumn(refClass = BlockSoftSwitchEnumUtil.DATABASE_OPERATE_TYPE.class)
    private Integer operateTypeId;

    public int getOperateTypeIdVal() {
        if (operateTypeId == null) {
            return -1;
        }
        return operateTypeId.intValue();
    }


    public String getOperateTypeIdTxt() {
        return operateTypeId == null ? "无" : BlockSoftSwitchEnumUtil.DATABASE_OPERATE_TYPE.valueOfDescription(operateTypeId);
    }

    @Column(name = "EXECUTE_SQL")
    @ApiParam(value = "执行sql")
    private String executeSql;

    @Column(name = "OPERATE_SORT")
    @ApiParam(value = "操作顺序")
    private Integer operateSort;

    @Column(name = "IS_RETURN")
    @ApiParam(value = "是否有返回")
    private Integer isReturn;

    public int getIsReturnVal() {
        if (isReturn == null) {
            return -1;
        }
        return isReturn.intValue();
    }


}

