package jnpf.util;

import org.springframework.stereotype.Component;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * 题库ID生成规则
 */
@Component
public class QuestionBankIDGenerator {

    private static AtomicInteger counter = new AtomicInteger(0);

    public String generateID() {
        int currentCounter = counter.incrementAndGet();
        int letter = currentCounter / 1000;
        char firstChar = (char) (letter + 'A');
        int remainingCounter = currentCounter % 1000;
        String threeDigits = String.format("%03d", remainingCounter);
        return "TK" + firstChar + threeDigits;
    }

//    public static void main(String[] args) {
//        for (int i = 0; i < 10000; i++) {
//            System.out.println(generateID());
//        }
//    }
}
