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

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 站点图标业务分类，与表字段 {@code cms_site_icon.category} 存储值一致；小程序壳层仅查询 {@link #HOME}。
 *
 * @author jeesharp
 * @since 2026-05-15
 */
@Getter
@AllArgsConstructor
public enum SiteIconCategoryEnum {

    /** 首页场景（壳层 homeIcons） */
    HOME("HOME", "首页"),

    /** 通用素材 */
    COMMON("COMMON", "通用"),

    /** 商城等扩展场景 */
    MALL("MALL", "商城");

    private final String code;
    private final String desc;

    public static SiteIconCategoryEnum fromCode(String code) {
        if (code == null || code.isBlank()) {
            return null;
        }
        String c = code.trim();
        for (SiteIconCategoryEnum e : values()) {
            if (e.getCode().equalsIgnoreCase(c)) {
                return e;
            }
        }
        return null;
    }

    public static String getDescByCode(String code) {
        SiteIconCategoryEnum e = fromCode(code);
        return e != null ? e.getDesc() : "";
    }
}
