package com.sonic.lion.domain.enums;

/**
 * @author: code
 * @date: 2025/06/19
 * @Description: 分配给用户做对手账户的系统账户, 系统账号个数需要为2的n次幂
 * @version: 1.0.0
 */
public enum SystemUser {

    SYSTEM_USER_1(-1, "SYSTEM_USER_1"),

    SYSTEM_USER_2(-2, "SYSTEM_USER_2"),

    SYSTEM_USER_3(-3, "SYSTEM_USER_3"),

    SYSTEM_USER_4(-4, "SYSTEM_USER_4"),

    SYSTEM_USER_5(-5, "SYSTEM_USER_5"),

    SYSTEM_USER_6(-6, "SYSTEM_USER_6"),

    SYSTEM_USER_7(-7, "SYSTEM_USER_7"),

    SYSTEM_USER_8(-8, "SYSTEM_USER_8"),
    ;

    /**
     * 系统用户uid
     */
    private final long value;

    /**
     * 系统用户名称
     */
    private final String desc;

    private static final int N = values().length - 1;

    SystemUser(long value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public long getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }

    /**
     * 根据用户id获取一个系统账号做交易对手账号
     *
     * @param uid
     * @return
     */
    public static SystemUser getByUid(long uid) {
        return values()[(int) (uid & N)];
    }
}
