package com.ylx.point.enums;

import cn.hutool.core.util.ObjectUtil;
import lombok.Getter;

@Getter
public enum PointActivityTaskTypeEnum {

    COMPLETE_ORDER(0, "完成订单"),

    RECHARGE_TASK(1, "充值任务"),

    SHARE_SERVICE(2, "分享服务号"),

    BROWLE_NEWS(3, "浏览动态"),

    BROWLE_MERCHANT(4, "浏览商户");

    private final Integer code;
    private final String info;

    PointActivityTaskTypeEnum(Integer code, String info) {
        this.code = code;
        this.info = info;
    }

    public static PointActivityTaskTypeEnum getByInfo(String info) {

        if (ObjectUtil.isNull(info)) {
            return null;
        }

        for (PointActivityTaskTypeEnum typeEnum : PointActivityTaskTypeEnum.values()) {
            if (typeEnum.getInfo().equals(info)) {
                return typeEnum;
            }
        }
        return null;
    }

    public static PointActivityTaskTypeEnum valueOf(Integer code) {
        if (code == null) {
            return null;
        }
        for (PointActivityTaskTypeEnum value : PointActivityTaskTypeEnum.values()) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        return null;
    }
}
