package com.ycwl.basic.puzzle.fill.enums;

import lombok.Getter;

/**
 * 数据源类型枚举
 */
@Getter
public enum DataSourceType {

    /**
     * 人脸URL(来自face表的face_url)
     */
    FACE_URL("FACE_URL", "人脸URL"),

    /**
     * 素材图片(来自source表,type=2)
     */
    SOURCE_IMAGE("SOURCE_IMAGE", "素材图片"),

    /**
     * 素材视频(来自source表,type=1)
     */
    SOURCE_VIDEO("SOURCE_VIDEO", "素材视频"),

    /**
     * 设备图片(根据deviceIndex指定第N个设备的图片)
     */
    DEVICE_IMAGE("DEVICE_IMAGE", "设备图片"),
    DEVICE_THUMB_IMAGE("DEVICE_THUMB_IMAGE", "设备缩略图片"),

    /**
     * 静态值(直接使用fallbackValue)
     */
    STATIC_VALUE("STATIC_VALUE", "静态值"),

    /**
     * 微信小程序二维码(生成小程序二维码)
     */
    WECHAT_QRCODE("WECHAT_QRCODE", "微信小程序二维码");

    private final String code;
    private final String description;

    DataSourceType(String code, String description) {
        this.code = code;
        this.description = description;
    }

    /**
     * 根据code获取枚举
     */
    public static DataSourceType fromCode(String code) {
        for (DataSourceType type : values()) {
            if (type.code.equals(code)) {
                return type;
            }
        }
        throw new IllegalArgumentException("未知的数据源类型: " + code);
    }
}
