package com.red.circle.common.business.core;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import java.io.Serializable;
import java.math.BigDecimal;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

/**
 * <p>
 * 系统枚举配置
 * </p>
 *
 * @author pengliang
 * @since 2019-10-30
 */
@Data
@Builder
@EqualsAndHashCode(callSuper = false)
@NoArgsConstructor
@AllArgsConstructor
public class EnumConfigCache implements Serializable {

  private static final long serialVersionUID = 1L;

  /**
   * 主键
   */
  @JsonSerialize(using = ToStringSerializer.class)
  private Long id;

  /**
   * 系统.
   */
  private String sysOrigin;

  /**
   * 键
   */
  private String name;

  /**
   * 值
   */
  private String val;

  /**
   * 备注
   */
  private String description;

  /**
   * 分组名称
   */
  private String groupName;

  @JsonIgnore
  public int getValInteger() {
    return Integer.parseInt(this.val);
  }

  @JsonIgnore
  public BigDecimal getValBigDecimal() {
    return new BigDecimal(this.val);
  }

  @JsonIgnore
  public boolean getValBool() {
    return Boolean.parseBoolean(this.val);
  }

}
