Skip to content

Commit

Permalink
#87 feat: UUID 생성기
Browse files Browse the repository at this point in the history
  • Loading branch information
rivkode committed Jun 6, 2024
1 parent 4c4cc38 commit 6de3b72
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.seoultech.synergybe.domain.common.idgenerator;

import com.fasterxml.uuid.Generators;
import org.springframework.stereotype.Component;

import java.util.UUID;

@Component
public class IdGeneratorUUID {

public String generateId(IdPrefix idPrefix) {
UUID originUuid = Generators.timeBasedGenerator().generate();
String[] uuidArr = originUuid.toString().split("-");
String uuidStr = uuidArr[2] + uuidArr[1] + uuidArr[0] + uuidArr[3] + uuidArr[4];
String uuid = idPrefix.getValue() + "-" + uuidStr;
return uuid;
}
}

0 comments on commit 6de3b72

Please sign in to comment.