261116_01_ENH: 리스트 헤더 여러 줄 텍스트 타입(MULTILINE_TEXT) 및 헤더 색상(list_hder_color) 추가 #47
@@ -27,6 +27,7 @@ public final class ContactConstant {
|
||||
Locale.ROOT));
|
||||
|
||||
public static final String LIST_HEADER_ACCEPT_REGEX = "^[가-힣a-zA-Z0-9()_\\-\\[\\] ]+$";
|
||||
public static final String LIST_HEADER_COLOR_REGEX = "^#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$";
|
||||
|
||||
public static final List<ListHeaderType> DEFAULT_AND_FILE_TYPE = Stream.concat(
|
||||
Arrays.stream(ListHeaderTypeDefault.values())
|
||||
|
||||
@@ -22,12 +22,18 @@ public enum ListHeaderType implements CodeEnum<Short> {
|
||||
EMAIL(ListHeaderTypeSpecific.EMAIL), //31 : 이메일
|
||||
FILE(ListHeaderTypeSpecific.FILE), //81 : 파일업로드
|
||||
CONTENT_ITEM(ListHeaderTypeSpecific.CONTENT_ITEM), //91 : 목록형
|
||||
MULTILINE_TEXT(ListHeaderTypeSpecific.MULTILINE_TEXT), //98 : 여러 줄 텍스트
|
||||
TEXT((short) 99); //99 : 텍스트
|
||||
|
||||
private final Short code;
|
||||
|
||||
ListHeaderType(CodeEnum<Short> source) { this.code = source.getCode();}
|
||||
|
||||
/** 저장·처리 방식이 일반 텍스트와 동일한 타입 여부 */
|
||||
public boolean isText() {
|
||||
return this == TEXT || this == MULTILINE_TEXT;
|
||||
}
|
||||
|
||||
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
|
||||
public static ListHeaderType fromCode(Short code) {
|
||||
if (code == null) {
|
||||
|
||||
@@ -15,7 +15,8 @@ public enum ListHeaderTypeSpecific implements CodeEnum<Short> {
|
||||
TEL_NUM((short) 21), //21 : 전화번호
|
||||
EMAIL((short) 31), //31 : 이메일
|
||||
FILE((short) 81), //81 : 파일업로드
|
||||
CONTENT_ITEM((short) 91); //목록형
|
||||
CONTENT_ITEM((short) 91), //목록형
|
||||
MULTILINE_TEXT((short) 98); //98 : 여러 줄 텍스트 (텍스트 계열)
|
||||
|
||||
private final Short code;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.kri.contact.server.common.enums.ListHeaderType;
|
||||
import com.kri.contact.server.persistence.entity.TListHeaderEntity;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
@@ -44,6 +45,9 @@ public class ListHeaderDto {
|
||||
@Schema(description = "헤더 타입")
|
||||
private ListHeaderType listHderTy;
|
||||
|
||||
@Schema(description = "헤더 색상 hex (#RRGGBB 또는 #RRGGBBAA, null: 기본색)")
|
||||
private String listHderColor;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "필터 사용 여부")
|
||||
private Boolean useFilter = false;
|
||||
@@ -68,6 +72,21 @@ public class ListHeaderDto {
|
||||
this.listHderNm = listHderNm == null ? null : listHderNm.trim();
|
||||
}
|
||||
|
||||
public String getListHderColor() {
|
||||
return normalizeColor(listHderColor);
|
||||
}
|
||||
|
||||
public void setListHderColor(String listHderColor) {
|
||||
this.listHderColor = normalizeColor(listHderColor);
|
||||
}
|
||||
|
||||
private static String normalizeColor(String color) {
|
||||
if (color == null || color.isBlank()) {
|
||||
return null;
|
||||
}
|
||||
return color.trim().toUpperCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
public static ListHeaderDto fromEntity(TListHeaderEntity entity) {
|
||||
return ListHeaderDto.builder()
|
||||
.prjctIdx(entity.getPrjctIdx())
|
||||
@@ -76,6 +95,7 @@ public class ListHeaderDto {
|
||||
.listHderGrad(ListHeaderGrade.fromCode(entity.getListHderGrad()))
|
||||
.listHderNm(entity.getListHderNm())
|
||||
.listHderTy(ListHeaderType.fromCode(entity.getListHderTy()))
|
||||
.listHderColor(entity.getListHderColor())
|
||||
.useFilter(entity.getUseFilter())
|
||||
.useColView(entity.getUseColView())
|
||||
.useIntrvwerView(entity.getUseIntrvwerView())
|
||||
@@ -91,6 +111,7 @@ public class ListHeaderDto {
|
||||
.listHderGrad(src.getListHderGrad())
|
||||
.listHderNm(src.getListHderNm())
|
||||
.listHderTy(src.getListHderTy())
|
||||
.listHderColor(src.getListHderColor())
|
||||
.useFilter(src.getUseFilter())
|
||||
.useColView(src.getUseColView())
|
||||
.useIntrvwerView(src.getUseIntrvwerView())
|
||||
|
||||
@@ -32,6 +32,7 @@ public class ListHeaderWithFilterContentDto extends ListHeaderDto {
|
||||
.listHderGrad(ListHeaderGrade.fromCode(entity.getListHderGrad()))
|
||||
.listHderNm(entity.getListHderNm())
|
||||
.listHderTy(ListHeaderType.fromCode(entity.getListHderTy()))
|
||||
.listHderColor(entity.getListHderColor())
|
||||
.useFilter(entity.getUseFilter())
|
||||
.useColView(entity.getUseColView())
|
||||
.useIntrvwerView(entity.getUseIntrvwerView())
|
||||
|
||||
@@ -46,6 +46,10 @@ public class TListHeaderEntity {
|
||||
@Column(name = "list_hder_ty", nullable = false)
|
||||
private Short listHderTy;
|
||||
|
||||
@Size(max = 16)
|
||||
@Column(name = "list_hder_color", length = 16)
|
||||
private String listHderColor;
|
||||
|
||||
@NotNull
|
||||
@ColumnDefault("0")
|
||||
@Column(name = "use_filter", nullable = false)
|
||||
@@ -103,6 +107,7 @@ public class TListHeaderEntity {
|
||||
.listHderGrad(src.getListHderGrad())
|
||||
.listHderNm(src.getListHderNm() == null ? null : src.getListHderNm().trim())
|
||||
.listHderTy(src.getListHderTy())
|
||||
.listHderColor(src.getListHderColor())
|
||||
.useFilter(src.getUseFilter())
|
||||
.useColView(src.getUseColView())
|
||||
.useIntrvwerView(src.getUseIntrvwerView())
|
||||
@@ -119,6 +124,7 @@ public class TListHeaderEntity {
|
||||
.listHderGrad(dto.getListHderGrad().getCode())
|
||||
.listHderNm(dto.getListHderNm())
|
||||
.listHderTy(dto.getListHderTy().getCode())
|
||||
.listHderColor(dto.getListHderColor())
|
||||
.useFilter(dto.getUseFilter())
|
||||
.useColView(dto.getUseColView())
|
||||
.useIntrvwerView(dto.getUseIntrvwerView())
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.kri.contact.server.service;
|
||||
|
||||
import static com.kri.contact.server.common.consts.ContactConstant.EXACT_MATCH_HEADER_TYPE;
|
||||
import static com.kri.contact.server.common.consts.ContactConstant.LIST_HEADER_ACCEPT_REGEX;
|
||||
import static com.kri.contact.server.common.consts.ContactConstant.LIST_HEADER_COLOR_REGEX;
|
||||
import static com.kri.contact.server.common.consts.ContactConstant.SYSTEM_USER_NAME;
|
||||
import static com.kri.contact.server.common.consts.ContactConstant.UPPER_CASE_HEADER_OPTIONS;
|
||||
|
||||
@@ -245,6 +246,16 @@ public class ListHeaderService {
|
||||
.with("invalidHeaderList", invalidHeaderList);
|
||||
}
|
||||
|
||||
List<String> invalidColorHeaderList = headerList.stream()
|
||||
.filter(h -> h.getListHderColor() != null && !h.getListHderColor().matches(LIST_HEADER_COLOR_REGEX))
|
||||
.map(ListHeaderDto::getListHderNm)
|
||||
.toList();
|
||||
|
||||
if (!invalidColorHeaderList.isEmpty()) {
|
||||
throw BusinessException.badRequest("WRONG_HEADER_COLOR", "헤더 색상은 #RRGGBB 또는 #RRGGBBAA 형식이어야 합니다.")
|
||||
.with("invalidHeaderList", invalidColorHeaderList);
|
||||
}
|
||||
|
||||
validateUniqueHeaderNames(headerList);
|
||||
|
||||
// headerList에 없는 헤더는 삭제
|
||||
@@ -403,6 +414,7 @@ public class ListHeaderService {
|
||||
case TEL_NUM -> ListHeaderType.TEL_NUM;
|
||||
case FILE -> ListHeaderType.FILE;
|
||||
case CONTENT_ITEM -> ListHeaderType.CONTENT_ITEM;
|
||||
case MULTILINE_TEXT -> ListHeaderType.MULTILINE_TEXT;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -380,7 +380,7 @@ public class ListUploadService {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (header.getListHderTy() == ListHeaderType.TEXT) {
|
||||
if (header.getListHderTy() != null && header.getListHderTy().isText()) {
|
||||
raw = escapeUnsafeText(raw);
|
||||
}
|
||||
if (header.getListHderTy() == ListHeaderType.EMAIL) {
|
||||
@@ -631,7 +631,7 @@ public class ListUploadService {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (header.getListHderTy() == ListHeaderType.TEXT) {
|
||||
if (header.getListHderTy() != null && header.getListHderTy().isText()) {
|
||||
raw = escapeUnsafeText(raw);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user