package com.seamew.lottery.domain.support.ids.policy;

import com.seamew.lottery.common.Constants;
import com.seamew.lottery.domain.support.ids.IIdGenerator;
import com.seamew.lottery.domain.support.ids.annotation.IdMode;
import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.stereotype.Component;

/**
 * @Author: seamew
 * @Title: RandomNumeric
 * @CreateTime: 2023年02月16日 10:35:00
 * @Description: 随机算法，用于生成策略ID
 * @Version: 1.0
 */
@Component
@IdMode(idMode = Constants.Ids.RandomNumeric)
public class RandomNumeric implements IIdGenerator {

    @Override
    public synchronized long nextId() {
        return Long.parseLong(RandomStringUtils.randomNumeric(11));
    }
}
