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

import cn.estsh.i3plus.pojo.base.annotation.AnnoOutputColumn;
import cn.estsh.i3plus.pojo.base.bean.BaseBean;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
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-12 14:45
 * @Modify:
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name="SYS_BARCODE_RULE")
@Api(value="条码规则",description = "条码规则")
public class SysBarcodeRule extends BaseBean {

    private static final long serialVersionUID = -2041412527908996307L;
    @Column(name = "NAME")
    @ApiParam(value = "规则名称")
    private String name;

    @Column(name = "BARCODE_RULE_CODE")
    @ApiParam(value = "规则代码")
    private String barcodeRuleCode;

    @Column(name = "BARCODE_RULE")
    @ApiParam(value = "条码规则")
    private String barcodeRule;

    @Column(name = "BARCODE_SEPARATOR")
    @ApiParam(value = "条码分隔符")
    private String barcodeSeparator;

    @Column(name="BARCODE_RULE_DESCRIPTION")
    @ApiParam(value ="条码规则描述")
    private String barcodeRuleDescription;

    @Column(name = "CHECK_MODE")
    @ApiParam(value ="校验模式")
    @AnnoOutputColumn(refClass = CommonEnumUtil.BARCODE_CHECK_MODE.class)
    private Integer checkMode;

    public int getCheckModeVal() {
        return checkMode == null ? CommonEnumUtil.BARCODE_CHECK_MODE.SEPARATOR_NUM.getValue() : checkMode;
    }

}
