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

import cn.estsh.i3plus.pojo.base.bean.BaseBean;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
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      : wei.peng
 * @Date        : 2018-10-22 16:58:43.550
 * @Modify      :
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name="SYS_DICTIONARY")
@Api(value="系统字典",description = "系统字典")
public class SysDictionary extends BaseBean {

    private static final long serialVersionUID = 593801368328634592L;
    @Column(name="NAME")
    @ApiParam(value ="字典名称")
    private String name;

    @Column(name="DICTIONARY_CODE")
    @ApiParam(value ="字典代码")
    private String dictionaryCode;

    //枚举 CommonEnumUtil.SOFT_TYPE
    @Column(name="DICTIONARY_SOFT_TYPE")
    @ApiParam(value ="字典所属模块")
    private Integer dictionarySoftType;

    //枚举 ImppEnumUtil.DICTIONARY_GROUP
    @Column(name="DICTIONARY_GROUP")
    @ApiParam(value ="字典分组")
    private Integer dictionaryGroup;

    // 根节点-1
    @Column(name="PARENT_ID")
    @ApiParam(value ="父节点" , example = "-1")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long parentId;

    public long getParentIdVal(){
        if(parentId == null){
            return 0;
        } else {
            return parentId.longValue();
        }
    }

    @Column(name="PARENT_NAME_RDD")
    @ApiParam(value ="父级节点名称")
    private String parentNameRdd;

    @Column(name="PARENT_CODEE_RDD")
    @ApiParam(value ="父级节点代码")
    private String parentCodeRdd;

    // 枚举 ImppEnumUtil.SYS_VALUE_TYPE
    @Column(name="DICTIONARY_VALUE_TYPE")
    @ApiParam(value ="字典值类型")
    private Integer dictionaryValueType;

    @Column(name="DICTIONARY_VALUE")
    @ApiParam(value ="字典值")
    private String dictionaryValue;

    @Column(name="DICTIONARY_SORT")
    @ApiParam(value ="排序" , example ="1")
    private Integer dictionarySort;

    @Column(name="IS_DEFAULT")
    @ApiParam(value = "是否默认",example = "2")
    private Integer isDefault;

    public int getIsDefaultVal(){
        if(this.isDefault == null){
            return 0;
        }
        return isDefault.intValue();
    }

    @Column(name="DICTIONARY_DESCRIPTION")
    @ApiParam(value ="描述")
    private String dictionaryDescription;

}
