package com.jeesharp.business.modules.setting.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 首页轮播跳转类型，与 {@code cms_home_banner.jump_type} 一致。
 *
 * @author jeesharp
 * @since 2026-07-03
 */
@Getter
@AllArgsConstructor
public enum HomeBannerJumpTypeEnum {

    NONE(0, "不跳转"),
    BIZ_DETAIL(1, "业务详情"),
    BIZ_LIST(2, "业务列表"),
    CUSTOM_PATH(3, "自定义小程序路径"),
    H5(4, "H5外链");

    private final Integer value;
    private final String desc;

    public static HomeBannerJumpTypeEnum fromValue(Integer value) {
        if (value == null) {
            return NONE;
        }
        for (HomeBannerJumpTypeEnum e : values()) {
            if (e.value.equals(value)) {
                return e;
            }
        }
        return NONE;
    }

    public static String getDescByValue(Integer value) {
        HomeBannerJumpTypeEnum e = fromValue(value);
        return e != null ? e.getDesc() : "";
    }
}
