-
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.
Tht server 189 회원가입 시 추가정보 기입 (#193)
* test : UserFrequency Enum converter test * add : UserFrequencyConverter Exception class * add & test: UserReligion enum class * add : user frequency & user religion converter class * remove : unused import * move : test package out * fix : UserSignUpRequest 멤버변수 추가 * remove : unused import * docs : 추가 파라미터 문서화 * remove : unused import * feat : 유저 회원가입 추가정보 파라미터 추가 * test : test 수정
- Loading branch information
Showing
86 changed files
with
541 additions
and
276 deletions.
There are no files selected for viewing
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,9 @@ | ||
package com.tht.api.app.entity.enums; | ||
|
||
public interface EnumModel { | ||
|
||
String getKey(); | ||
|
||
String getValue(); | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/com/tht/api/app/entity/enums/UserFrequency.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,39 @@ | ||
package com.tht.api.app.entity.enums; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.tht.api.exception.custom.EnumStateNotFoundException; | ||
import lombok.AllArgsConstructor; | ||
|
||
import java.util.Arrays; | ||
|
||
@AllArgsConstructor | ||
public enum UserFrequency implements EnumModel{ | ||
|
||
NONE("NONE"), | ||
SOMETIMES("SOMETIMES"), | ||
FREQUENTLY("FREQUENTLY"); | ||
|
||
private final String value; | ||
|
||
@JsonCreator | ||
public static UserFrequency toConverter(final String name) { | ||
return Arrays.stream(UserFrequency.values()) | ||
.filter(userFrequency -> userFrequency.getValue().equals(name)) | ||
.findFirst() | ||
.orElseThrow( | ||
() -> EnumStateNotFoundException.ofUserFrequency(name) | ||
); | ||
} | ||
|
||
|
||
@Override | ||
public String getKey() { | ||
return this.name(); | ||
} | ||
|
||
@Override | ||
public String getValue() { | ||
return value; | ||
} | ||
|
||
} |
41 changes: 41 additions & 0 deletions
41
src/main/java/com/tht/api/app/entity/enums/UserReligion.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,41 @@ | ||
package com.tht.api.app.entity.enums; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.tht.api.exception.custom.EnumStateNotFoundException; | ||
import lombok.AllArgsConstructor; | ||
|
||
import java.util.Arrays; | ||
|
||
@AllArgsConstructor | ||
public enum UserReligion implements EnumModel{ | ||
|
||
NONE("NONE"), | ||
CHRISTIAN("CHRISTIAN"), | ||
CATHOLICISM("CATHOLICISM"), | ||
BUDDHISM("BUDDHISM"), | ||
WON_BUDDHISM("WON_BUDDHISM"), | ||
OTHER("OTHER"); | ||
|
||
private final String value; | ||
|
||
@JsonCreator | ||
public static UserReligion toConverter(final String name) { | ||
return Arrays.stream(UserReligion.values()) | ||
.filter(userReligion -> userReligion.getValue().equals(name)) | ||
.findFirst() | ||
.orElseThrow( | ||
() -> EnumStateNotFoundException.ofUserReligion(name) | ||
); | ||
} | ||
|
||
@Override | ||
public String getKey() { | ||
return this.name(); | ||
} | ||
|
||
@Override | ||
public String getValue() { | ||
return value; | ||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/com/tht/api/app/entity/enums/converter/UserFrequencyConverter.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,23 @@ | ||
package com.tht.api.app.entity.enums.converter; | ||
|
||
import com.tht.api.app.entity.enums.UserFrequency; | ||
import jakarta.persistence.AttributeConverter; | ||
import jakarta.persistence.Converter; | ||
|
||
import java.util.Objects; | ||
|
||
@Converter | ||
public class UserFrequencyConverter implements AttributeConverter<UserFrequency, String> { | ||
@Override | ||
public String convertToDatabaseColumn(UserFrequency userFrequency) { | ||
if (Objects.isNull(userFrequency)) { | ||
throw new NullPointerException("Enum Converting String - UserRole is null"); | ||
} | ||
|
||
return userFrequency.name(); } | ||
|
||
@Override | ||
public UserFrequency convertToEntityAttribute(String dbData) { | ||
return UserFrequency.toConverter(dbData); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/com/tht/api/app/entity/enums/converter/UserReligionConverter.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,26 @@ | ||
package com.tht.api.app.entity.enums.converter; | ||
|
||
import com.tht.api.app.entity.enums.UserReligion; | ||
import jakarta.persistence.AttributeConverter; | ||
|
||
import java.util.Objects; | ||
|
||
public class UserReligionConverter implements AttributeConverter<UserReligion, String> { | ||
|
||
|
||
@Override | ||
public String convertToDatabaseColumn(UserReligion userReligion) { | ||
|
||
if (Objects.isNull(userReligion)) { | ||
throw new NullPointerException("Enum Converting String - UserRole is null"); | ||
} | ||
|
||
return userReligion.name(); | ||
} | ||
|
||
@Override | ||
public UserReligion convertToEntityAttribute(String dbData) { | ||
|
||
return UserReligion.toConverter(dbData); | ||
} | ||
} |
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
Oops, something went wrong.