package com.fzm.mall.server.admin.util;

import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.time.Clock;
import java.util.Date;
import java.util.UUID;

@Component
public class SerialIdsUtil {

    private SerialIdsUtil() {
    }

    public static String createSerialNumber() {// 流水号
        Long now = Clock.systemUTC().millis();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
        String dateStr = sdf.format(new Date(now));
        return dateStr;
    }

    /**
     * 创建当前时间年月日格式的字符串
     */
    public static String createDateStr() {
        Long now = Clock.systemUTC().millis();
        String dateFloderName = DateUtil.DF2.get().format(new Date(now));
        return dateFloderName;
    }

    public static String getUUID() {
        return UUID.randomUUID().toString().replaceAll("-", "");
    }


    public static String createFileName(String fileType) {// 流水号
        return createSerialNumber() + "_" + NewCodeUtil.getSixRadomCode() + fileType;
    }
}
