package com.lesingle.creation.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 可见性枚举
 */
@Getter
@AllArgsConstructor
public enum VisibilityEnum {

    PUBLIC("public", "公开"),
    PRIVATE("private", "私有"),
    DESIGNATED("designated", "指定"),
    INTERNAL("internal", "内部"),
    FRIENDS("friends", "好友可见");

    private final String code;
    private final String desc;

    public static VisibilityEnum getByCode(String code) {
        if (code == null) {
            return PRIVATE;
        }
        for (VisibilityEnum visibility : values()) {
            if (visibility.getCode().equals(code)) {
                return visibility;
            }
        }
        return PRIVATE;
    }
}
