package com.lesingle.creation.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 用户来源枚举
 */
@Getter
@AllArgsConstructor
public enum UserSourceEnum {

    ADMIN_CREATED("admin_created", "管理员创建"),
    SELF_REGISTERED("self_registered", "自主注册"),
    CHILD_MIGRATED("child_migrated", "子女账号迁移");

    private final String code;
    private final String desc;

    public static UserSourceEnum getByCode(String code) {
        if (code == null) {
            return ADMIN_CREATED;
        }
        for (UserSourceEnum source : values()) {
            if (source.getCode().equals(code)) {
                return source;
            }
        }
        return ADMIN_CREATED;
    }
}
