enum 수정
This commit is contained in:
19
src/main/java/com/kamco/cd/kamcoback/common/utils/Enums.java
Normal file
19
src/main/java/com/kamco/cd/kamcoback/common/utils/Enums.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package com.kamco.cd.kamcoback.common.utils;
|
||||
|
||||
import com.kamco.cd.kamcoback.config.enums.EnumType;
|
||||
|
||||
public class Enums {
|
||||
|
||||
// code로 text
|
||||
public static <E extends Enum<E> & EnumType> E fromId(Class<E> enumClass, String id) {
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
for (E e : enumClass.getEnumConstants()) {
|
||||
if (id.equalsIgnoreCase(e.getId())) {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
return null; // 못 찾으면 null
|
||||
}
|
||||
}
|
||||
@@ -5,17 +5,4 @@ public interface EnumType {
|
||||
String getId();
|
||||
|
||||
String getText();
|
||||
|
||||
// code로 text
|
||||
static <E extends Enum<E> & EnumType> E fromId(Class<E> enumClass, String id) {
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
for (E e : enumClass.getEnumConstants()) {
|
||||
if (id.equalsIgnoreCase(e.getId())) {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
return null; // 못 찾으면 null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@ package com.kamco.cd.kamcoback.members.dto;
|
||||
|
||||
import com.kamco.cd.kamcoback.common.enums.RoleType;
|
||||
import com.kamco.cd.kamcoback.common.enums.StatusType;
|
||||
import com.kamco.cd.kamcoback.common.utils.Enums;
|
||||
import com.kamco.cd.kamcoback.common.utils.interfaces.JsonFormatDttm;
|
||||
import com.kamco.cd.kamcoback.config.enums.EnumType;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Size;
|
||||
@@ -32,10 +32,14 @@ public class MembersDto {
|
||||
private String tempPassword;
|
||||
private String status;
|
||||
private String statusName;
|
||||
@JsonFormatDttm private ZonedDateTime createdDttm;
|
||||
@JsonFormatDttm private ZonedDateTime updatedDttm;
|
||||
@JsonFormatDttm private ZonedDateTime firstLoginDttm;
|
||||
@JsonFormatDttm private ZonedDateTime lastLoginDttm;
|
||||
@JsonFormatDttm
|
||||
private ZonedDateTime createdDttm;
|
||||
@JsonFormatDttm
|
||||
private ZonedDateTime updatedDttm;
|
||||
@JsonFormatDttm
|
||||
private ZonedDateTime firstLoginDttm;
|
||||
@JsonFormatDttm
|
||||
private ZonedDateTime lastLoginDttm;
|
||||
|
||||
public Basic(
|
||||
Long id,
|
||||
@@ -67,12 +71,12 @@ public class MembersDto {
|
||||
}
|
||||
|
||||
private String getUserRoleName(String roleId) {
|
||||
RoleType type = EnumType.fromId(RoleType.class, roleId);
|
||||
RoleType type = Enums.fromId(RoleType.class, roleId);
|
||||
return type.getText();
|
||||
}
|
||||
|
||||
private String getStatusName(String status) {
|
||||
StatusType type = EnumType.fromId(StatusType.class, status);
|
||||
StatusType type = Enums.fromId(StatusType.class, status);
|
||||
return type.getText();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user