package org.dromara.zhishu.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.dromara.common.core.exception.ServiceException;

import java.util.ArrayList;
import java.util.List;

@Getter
@AllArgsConstructor
public enum TaskTypeEnum {

    PUBLISH_GOODS("1", "发布商品"),

    SYNC_GOODS_KFZ("SYNC_GOODS_KFZ", "孔夫子"),

    SYNC_GOODS_WLN("SYNC_GOODS_WLN", "万里牛");

    /**
     * code
     */
    private final String code;

    /**
     * message
     */
    private final String msg;

    public static List<String> getTaskTypeEnumList() {
        List<String> taskTypeEnumList = new ArrayList<>();
        for (TaskTypeEnum item : values()) {
            taskTypeEnumList.add(item.getCode());
        }
        return taskTypeEnumList;
    }

    public static TaskTypeEnum valueOfCode(String code) {
        for (TaskTypeEnum type : values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        throw new ServiceException("未知操作库存类型code: " + code);
    }

}
