package com.ltgk.message.enums;

import com.ltgk.common.utils.enums.CodeDescEnumInterface;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * 消息分类枚举
 *
 * @author Qi ChengBin
 * @date 2025/01/02 10:00:00
 */
@Getter
public enum MessageTypeEnum implements CodeDescEnumInterface {

    INFORMATION_PUBLICITY(1, "信息公示"),
    WORK_HUNTING(2, "工作寻呼"),
    CLIMATIC_METEOROLOGY(3, "气候气象"),
    TIDAL_HYDROLOGY(4, "潮汐水文"),
    WATERWAY_BEACONS(5, "航道灯标"),
    PORT_ACTIVITIES(6, "渔港活动"),
    MANAGE_NEW_RULES(7, "管理新规"),
    FESTIVALS(8, "节庆活动"),
    POLICY_MESSAGES(9, "政策消息"),
    OTHER(10, "其他");

    private final Integer code;
    private final String desc;

    MessageTypeEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    private static final Map<Integer, MessageTypeEnum> CODE_MAP = new HashMap<>();
    static {
        for (MessageTypeEnum value : values()) {
            // 保留首个出现的 code，跳过重复值以保持原逻辑
            if (!CODE_MAP.containsKey(value.code)) {
                CODE_MAP.put(value.code, value);
            }
        }
    }

    public static String getDescByCode(Integer messageType) {
        MessageTypeEnum result = CODE_MAP.get(messageType);
        return result != null ? result.desc : null;
    }
}
