今日份:

/**
 * @Author: SXD
 * @Description: 操作枚举
 * @Date: create in 2020/3/18 16:11
 */
public enum OperateTypeEnum {

    ADD(1,"新增"),
    EDIT(2,"编辑"),
    VIEW(3,"查看"),
    REAPPLY(4,"重新申请"),
    COPY(5,"复制");

    private Integer value;

    private String desc;

    OperateTypeEnum(Integer type, String desc) {
        this.value = type;
        this.desc = desc;
    }

    public Integer getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }

    /**
     * 根据value值获取枚举对象
     * @param value
     * @return
     */
    public static OperateTypeEnum getOperateType(Integer value){
        OperateTypeEnum[] instances = OperateTypeEnum.values();
        for(OperateTypeEnum instance : instances){
            if(instance.getValue() == value){
                return instance;
            }
        }

        return null;
    }

}

 

=============