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 getId();
|
||||||
|
|
||||||
String getText();
|
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.RoleType;
|
||||||
import com.kamco.cd.kamcoback.common.enums.StatusType;
|
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.common.utils.interfaces.JsonFormatDttm;
|
||||||
import com.kamco.cd.kamcoback.config.enums.EnumType;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import jakarta.validation.constraints.Size;
|
import jakarta.validation.constraints.Size;
|
||||||
@@ -32,24 +32,28 @@ public class MembersDto {
|
|||||||
private String tempPassword;
|
private String tempPassword;
|
||||||
private String status;
|
private String status;
|
||||||
private String statusName;
|
private String statusName;
|
||||||
@JsonFormatDttm private ZonedDateTime createdDttm;
|
@JsonFormatDttm
|
||||||
@JsonFormatDttm private ZonedDateTime updatedDttm;
|
private ZonedDateTime createdDttm;
|
||||||
@JsonFormatDttm private ZonedDateTime firstLoginDttm;
|
@JsonFormatDttm
|
||||||
@JsonFormatDttm private ZonedDateTime lastLoginDttm;
|
private ZonedDateTime updatedDttm;
|
||||||
|
@JsonFormatDttm
|
||||||
|
private ZonedDateTime firstLoginDttm;
|
||||||
|
@JsonFormatDttm
|
||||||
|
private ZonedDateTime lastLoginDttm;
|
||||||
|
|
||||||
public Basic(
|
public Basic(
|
||||||
Long id,
|
Long id,
|
||||||
UUID uuid,
|
UUID uuid,
|
||||||
String userRole,
|
String userRole,
|
||||||
String name,
|
String name,
|
||||||
String userId,
|
String userId,
|
||||||
String employeeNo,
|
String employeeNo,
|
||||||
String tempPassword,
|
String tempPassword,
|
||||||
String status,
|
String status,
|
||||||
ZonedDateTime createdDttm,
|
ZonedDateTime createdDttm,
|
||||||
ZonedDateTime updatedDttm,
|
ZonedDateTime updatedDttm,
|
||||||
ZonedDateTime firstLoginDttm,
|
ZonedDateTime firstLoginDttm,
|
||||||
ZonedDateTime lastLoginDttm) {
|
ZonedDateTime lastLoginDttm) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
this.userRole = userRole;
|
this.userRole = userRole;
|
||||||
@@ -67,12 +71,12 @@ public class MembersDto {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getUserRoleName(String roleId) {
|
private String getUserRoleName(String roleId) {
|
||||||
RoleType type = EnumType.fromId(RoleType.class, roleId);
|
RoleType type = Enums.fromId(RoleType.class, roleId);
|
||||||
return type.getText();
|
return type.getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getStatusName(String status) {
|
private String getStatusName(String status) {
|
||||||
StatusType type = EnumType.fromId(StatusType.class, status);
|
StatusType type = Enums.fromId(StatusType.class, status);
|
||||||
return type.getText();
|
return type.getText();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -84,8 +88,8 @@ public class MembersDto {
|
|||||||
public static class SearchReq {
|
public static class SearchReq {
|
||||||
|
|
||||||
@Schema(
|
@Schema(
|
||||||
description = "전체, 관리자(ROLE_ADMIN), 라벨러(ROLE_LABELER), 검수자(ROLE_REVIEWER)",
|
description = "전체, 관리자(ROLE_ADMIN), 라벨러(ROLE_LABELER), 검수자(ROLE_REVIEWER)",
|
||||||
example = "")
|
example = "")
|
||||||
private String userRole;
|
private String userRole;
|
||||||
|
|
||||||
@Schema(description = "키워드", example = "홍길동")
|
@Schema(description = "키워드", example = "홍길동")
|
||||||
@@ -129,7 +133,7 @@ public class MembersDto {
|
|||||||
private String employeeNo;
|
private String employeeNo;
|
||||||
|
|
||||||
public AddReq(
|
public AddReq(
|
||||||
String userRole, String name, String userId, String tempPassword, String employeeNo) {
|
String userRole, String name, String userId, String tempPassword, String employeeNo) {
|
||||||
this.userRole = userRole;
|
this.userRole = userRole;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
|
|||||||
Reference in New Issue
Block a user