package com.lesingle.creation.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 用户类型枚举
 */
@Getter
@AllArgsConstructor
public enum UserTypeEnum {

    ADULT("adult", "成人"),
    CHILD("child", "子女");

    private final String code;
    private final String desc;

    public static UserTypeEnum getByCode(String code) {
        if (code == null) {
            return ADULT;
        }
        for (UserTypeEnum type : values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        return ADULT;
    }
}
