package com.red.circle.other.app.enums.violation;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 违规目标类型枚举
 *
 * @author Claude
 * @date 2025-01-15
 */
@Getter
@AllArgsConstructor
public enum TargetTypeEnum {

    /**
     * 用户
     */
    USER(1, "用户"),

    /**
     * 房间
     */
    ROOM(2, "房间");

    /**
     * 类型编码
     */
    private final Integer code;

    /**
     * 类型描述
     */
    private final String desc;

    /**
     * 根据编码获取枚举
     */
    public static TargetTypeEnum getByCode(Integer code) {
        if (code == null) {
            return null;
        }
        return Arrays.stream(values())
                .filter(e -> e.getCode().equals(code))
                .findFirst()
                .orElse(null);
    }
}
