package com.rongyichuang.common.enums; /** * 媒体目标类型枚举 * 定义t_media表中target_type字段的所有可能值 */ public enum MediaTargetType { /** * 评委头像 */ JUDGE_AVATAR(1, "评委头像"), /** * 活动媒体 */ ACTIVITY(2, "活动"), /** * 轮播图媒体 */ CAROUSEL(4, "轮播图"), /** * 参赛报名资料 * 对应t_activity_player的记录 */ ACTIVITY_PLAYER_SUBMISSION(5, "参赛报名资料"), /** * 学员头像 */ STUDENT_AVATAR(6, "学员头像"), /** * 用户头像 */ USER_AVATAR(7, "用户头像"); private final int value; private final String description; MediaTargetType(int value, String description) { this.value = value; this.description = description; } /** * 获取枚举值 * @return 数值 */ public int getValue() { return value; } /** * 获取描述 * @return 描述 */ public String getDescription() { return description; } /** * 根据数值获取枚举 * @param value 数值 * @return 对应的枚举,如果没有找到则返回null */ public static MediaTargetType fromValue(int value) { for (MediaTargetType type : MediaTargetType.values()) { if (type.value == value) { return type; } } return null; } /** * 根据数值获取描述 * @param value 数值 * @return 描述,如果没有找到则返回"未知类型" */ public static String getDescriptionByValue(int value) { MediaTargetType type = fromValue(value); return type != null ? type.getDescription() : "未知类型(" + value + ")"; } @Override public String toString() { return String.format("%s(%d)", description, value); } }