package com.qs.mp.common.enums;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.IEnum;
import io.swagger.annotations.ApiModel;

/**
 * 异步任务类型枚举
 * @author Cup
 * @date 2022/6/7
 */
@ApiModel("异步任务类型枚举")
public enum AsyncTaskTypeEnum implements IEnum<Integer> {
    CHANNEL_CONFIRM_RECEIPT(1,"经销商确认收货任务"),
    TICKET_PAY(2,"盲票付款任务"),
    TICKET_GENERATE(3, "盲票生成任务");

    private Integer value;
    private String desc;

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

    public String getDesc() {
        return desc;
    }

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

    public static AsyncTaskTypeEnum getByValue(String value){
        for (AsyncTaskTypeEnum asyncTaskTypeEnum : AsyncTaskTypeEnum.values()) {
            if (asyncTaskTypeEnum.getValue().equals(value)) {
                return asyncTaskTypeEnum;
            }
        }
        return null;
    }

    /**
     * 重写toString，单个转化成json
     * @return
     */
    @Override
    public String toString() {
        JSONObject object = new JSONObject();
        object.put("value",value);
        object.put("desc", desc);
        return object.toString();
    }

}
