-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IdGenerator -> TokenGenerator 기존 Id 생성 역할을 Token 생성으로 변경
- Loading branch information
Showing
3 changed files
with
12 additions
and
10 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
src/main/java/com/seoultech/synergybe/domain/common/generator/TokenGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.seoultech.synergybe.domain.common.generator; | ||
|
||
public interface TokenGenerator { | ||
String generateToken(IdPrefix idPrefix); | ||
} |
8 changes: 4 additions & 4 deletions
8
...n/common/idgenerator/IdGeneratorUUID.java → .../common/generator/TokenGeneratorUUID.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
package com.seoultech.synergybe.domain.common.idgenerator; | ||
package com.seoultech.synergybe.domain.common.generator; | ||
|
||
import com.fasterxml.uuid.Generators; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.UUID; | ||
|
||
@Component | ||
public class IdGeneratorUUID { | ||
public class TokenGeneratorUUID implements TokenGenerator { | ||
|
||
public String generateId(IdPrefix idPrefix) { | ||
public String generateToken(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; | ||
String uuid = idPrefix.getValue() + "_" + uuidStr; | ||
return uuid; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters