package com.qs.mp.common.enums;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONType;
import com.baomidou.mybatisplus.annotation.IEnum;
import com.qs.mp.common.json.EnumValueDeserializer;
import io.swagger.annotations.ApiModel;

/**
 * 提货订单来源枚举类
 *
 * @author Cup
 * @date 2022/5/23
 */
@ApiModel("提货订单来源枚举类")
@JSONType(deserializer = EnumValueDeserializer.class)
public enum DeliverOrderResourceEnum implements IEnum<Integer> {

    DELIVER(1, "提货订单"),
    PAYMENT(2, "现金购买");

    private final int value;
    private final String desc;


    DeliverOrderResourceEnum(int value, String desc) {
        this.value = value;
        this.desc = desc;
    }


    @Override
    public Integer getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }


    public static DeliverOrderResourceEnum getByValue(Integer value) {
        for (DeliverOrderResourceEnum deliverOrderResourceEnum : DeliverOrderResourceEnum.values()) {
            if (deliverOrderResourceEnum.getValue().equals(value)) {
                return deliverOrderResourceEnum;
            }
        }
        return null;
    }

    @Override
    public String toString() {
        JSONObject object = new JSONObject();
        object.put("value", value);
        object.put("desc", desc);
        return object.toString();
    }
}
