feat: add entity and swagger

This commit is contained in:
ilhamtahir committed 2024-11-16 19:12:56 +08:00
1 parent 0416c356b8
commit 346742b157
12 files changed
+652 -66

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
import SnowflakeID from 'snowflake-id';
export class SnowflakeUtil {
private static instance: SnowflakeID;
static initialize(workerId: number = 1, datacenterId: number = 1): void {
this.instance = new SnowflakeID({
workerId, // 机器 ID
datacenterId, // 数据中心 ID
});
}
static generateId(): string {
if (!this.instance) {
throw new Error('SnowflakeUtil is not initialized.');
}
return this.instance.generate().toString();
}
}