首页>代码>基于SpringBoot+Vue实现的二手交易系统>/源代码/后端代码/FleaMarketApi/src/main/java/com/rabbiter/fm/common/utils/IdFactoryUtil.java
package com.rabbiter.fm.common.utils;

import java.util.concurrent.atomic.AtomicInteger;

public class IdFactoryUtil {

    private static AtomicInteger orderIdEnd=new AtomicInteger(1);
    private static AtomicInteger fileIdEnd=new AtomicInteger(1);

    public static String getOrderId(){
        int newI;
        int ord;
        do{
            ord=orderIdEnd.get();
            newI=(ord+1)%10000;
        }
        while (!orderIdEnd.compareAndSet(ord,newI));
        return System.currentTimeMillis()+""+(newI+10000);
    }

    public static String getFileId(){
        int newI;
        int ord;
        do{
            ord=fileIdEnd.get();
            newI=(ord+1)%1000;
        }
        while (!fileIdEnd.compareAndSet(ord,newI));
        return System.currentTimeMillis()+""+(newI+1000);
    }
}
最近下载更多
dadassss  LV5 2024年12月27日
hrbylw  LV9 2024年9月21日
Peny_ZH  LV5 2024年9月20日
yyhrhv  LV8 2024年9月18日
微信网友_7134912998903808  LV15 2024年9月11日
hyt123456  LV3 2024年5月10日
yjCASDAS  LV3 2024年4月20日
鲲凡烦  LV1 2024年4月19日
860421  LV3 2024年4月18日
郭玉婷  LV10 2024年4月11日
最近浏览更多
dadassss  LV5 2024年12月27日
taidan 2024年11月29日
暂无贡献等级
xianyu091012  LV5 2024年11月18日
微信网友_7177544545669120  LV1 2024年9月21日
hrbylw  LV9 2024年9月21日
zvcbnlk  LV2 2024年9月20日
Peny_ZH  LV5 2024年9月20日
abdkfksdkf  LV16 2024年9月18日
微信网友_7134912998903808  LV15 2024年9月11日
yyhrhv  LV8 2024年9月10日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友