Compare commits
4 Commits
d05db04a19
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| a0f8684798 | |||
| ad6a302867 | |||
| 6aaf35adf6 | |||
| 548dca52c3 |
@@ -27,6 +27,7 @@ public final class ContactConstant {
|
|||||||
Locale.ROOT));
|
Locale.ROOT));
|
||||||
|
|
||||||
public static final String LIST_HEADER_ACCEPT_REGEX = "^[가-힣a-zA-Z0-9()_\\-\\[\\] ]+$";
|
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(
|
public static final List<ListHeaderType> DEFAULT_AND_FILE_TYPE = Stream.concat(
|
||||||
Arrays.stream(ListHeaderTypeDefault.values())
|
Arrays.stream(ListHeaderTypeDefault.values())
|
||||||
|
|||||||
@@ -22,12 +22,18 @@ public enum ListHeaderType implements CodeEnum<Short> {
|
|||||||
EMAIL(ListHeaderTypeSpecific.EMAIL), //31 : 이메일
|
EMAIL(ListHeaderTypeSpecific.EMAIL), //31 : 이메일
|
||||||
FILE(ListHeaderTypeSpecific.FILE), //81 : 파일업로드
|
FILE(ListHeaderTypeSpecific.FILE), //81 : 파일업로드
|
||||||
CONTENT_ITEM(ListHeaderTypeSpecific.CONTENT_ITEM), //91 : 목록형
|
CONTENT_ITEM(ListHeaderTypeSpecific.CONTENT_ITEM), //91 : 목록형
|
||||||
|
MULTILINE_TEXT(ListHeaderTypeSpecific.MULTILINE_TEXT), //98 : 여러 줄 텍스트
|
||||||
TEXT((short) 99); //99 : 텍스트
|
TEXT((short) 99); //99 : 텍스트
|
||||||
|
|
||||||
private final Short code;
|
private final Short code;
|
||||||
|
|
||||||
ListHeaderType(CodeEnum<Short> source) { this.code = source.getCode();}
|
ListHeaderType(CodeEnum<Short> source) { this.code = source.getCode();}
|
||||||
|
|
||||||
|
/** 저장·처리 방식이 일반 텍스트와 동일한 타입 여부 */
|
||||||
|
public boolean isText() {
|
||||||
|
return this == TEXT || this == MULTILINE_TEXT;
|
||||||
|
}
|
||||||
|
|
||||||
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
|
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
|
||||||
public static ListHeaderType fromCode(Short code) {
|
public static ListHeaderType fromCode(Short code) {
|
||||||
if (code == null) {
|
if (code == null) {
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ public enum ListHeaderTypeSpecific implements CodeEnum<Short> {
|
|||||||
TEL_NUM((short) 21), //21 : 전화번호
|
TEL_NUM((short) 21), //21 : 전화번호
|
||||||
EMAIL((short) 31), //31 : 이메일
|
EMAIL((short) 31), //31 : 이메일
|
||||||
FILE((short) 81), //81 : 파일업로드
|
FILE((short) 81), //81 : 파일업로드
|
||||||
CONTENT_ITEM((short) 91); //목록형
|
CONTENT_ITEM((short) 91), //목록형
|
||||||
|
MULTILINE_TEXT((short) 98); //98 : 여러 줄 텍스트 (텍스트 계열)
|
||||||
|
|
||||||
private final Short code;
|
private final Short code;
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
|||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PatchMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
@@ -66,27 +64,4 @@ public class ListCallHistController {
|
|||||||
now
|
now
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "Find list call history by agent session")
|
|
||||||
@GetMapping("/session/{agentSessionId}")
|
|
||||||
public ListCallHistDto findByAgentSessionId(
|
|
||||||
@PathVariable String agentSessionId,
|
|
||||||
RequestUserContext ctx
|
|
||||||
) {
|
|
||||||
return listCallHistService.findByAgentSessionId(
|
|
||||||
agentSessionId,
|
|
||||||
ctx.getUserId(),
|
|
||||||
ctx.getUserCmpn(),
|
|
||||||
ctx.getUserRole()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "Update Call History at Client Hangup")
|
|
||||||
@PatchMapping("hangup/{agentSessionId}")
|
|
||||||
public boolean hangupClient(
|
|
||||||
@PathVariable String agentSessionId,
|
|
||||||
RequestUserContext ctx
|
|
||||||
) {
|
|
||||||
return listCallHistService.hangupClient(agentSessionId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.kri.contact.server.common.enums.ListHeaderType;
|
|||||||
import com.kri.contact.server.persistence.entity.TListHeaderEntity;
|
import com.kri.contact.server.persistence.entity.TListHeaderEntity;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -44,6 +45,9 @@ public class ListHeaderDto {
|
|||||||
@Schema(description = "헤더 타입")
|
@Schema(description = "헤더 타입")
|
||||||
private ListHeaderType listHderTy;
|
private ListHeaderType listHderTy;
|
||||||
|
|
||||||
|
@Schema(description = "헤더 색상 hex (#RRGGBB 또는 #RRGGBBAA, null: 기본색)")
|
||||||
|
private String listHderColor;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Schema(description = "필터 사용 여부")
|
@Schema(description = "필터 사용 여부")
|
||||||
private Boolean useFilter = false;
|
private Boolean useFilter = false;
|
||||||
@@ -68,6 +72,21 @@ public class ListHeaderDto {
|
|||||||
this.listHderNm = listHderNm == null ? null : listHderNm.trim();
|
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) {
|
public static ListHeaderDto fromEntity(TListHeaderEntity entity) {
|
||||||
return ListHeaderDto.builder()
|
return ListHeaderDto.builder()
|
||||||
.prjctIdx(entity.getPrjctIdx())
|
.prjctIdx(entity.getPrjctIdx())
|
||||||
@@ -76,6 +95,7 @@ public class ListHeaderDto {
|
|||||||
.listHderGrad(ListHeaderGrade.fromCode(entity.getListHderGrad()))
|
.listHderGrad(ListHeaderGrade.fromCode(entity.getListHderGrad()))
|
||||||
.listHderNm(entity.getListHderNm())
|
.listHderNm(entity.getListHderNm())
|
||||||
.listHderTy(ListHeaderType.fromCode(entity.getListHderTy()))
|
.listHderTy(ListHeaderType.fromCode(entity.getListHderTy()))
|
||||||
|
.listHderColor(entity.getListHderColor())
|
||||||
.useFilter(entity.getUseFilter())
|
.useFilter(entity.getUseFilter())
|
||||||
.useColView(entity.getUseColView())
|
.useColView(entity.getUseColView())
|
||||||
.useIntrvwerView(entity.getUseIntrvwerView())
|
.useIntrvwerView(entity.getUseIntrvwerView())
|
||||||
@@ -91,6 +111,7 @@ public class ListHeaderDto {
|
|||||||
.listHderGrad(src.getListHderGrad())
|
.listHderGrad(src.getListHderGrad())
|
||||||
.listHderNm(src.getListHderNm())
|
.listHderNm(src.getListHderNm())
|
||||||
.listHderTy(src.getListHderTy())
|
.listHderTy(src.getListHderTy())
|
||||||
|
.listHderColor(src.getListHderColor())
|
||||||
.useFilter(src.getUseFilter())
|
.useFilter(src.getUseFilter())
|
||||||
.useColView(src.getUseColView())
|
.useColView(src.getUseColView())
|
||||||
.useIntrvwerView(src.getUseIntrvwerView())
|
.useIntrvwerView(src.getUseIntrvwerView())
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ public class ListHeaderWithFilterContentDto extends ListHeaderDto {
|
|||||||
.listHderGrad(ListHeaderGrade.fromCode(entity.getListHderGrad()))
|
.listHderGrad(ListHeaderGrade.fromCode(entity.getListHderGrad()))
|
||||||
.listHderNm(entity.getListHderNm())
|
.listHderNm(entity.getListHderNm())
|
||||||
.listHderTy(ListHeaderType.fromCode(entity.getListHderTy()))
|
.listHderTy(ListHeaderType.fromCode(entity.getListHderTy()))
|
||||||
|
.listHderColor(entity.getListHderColor())
|
||||||
.useFilter(entity.getUseFilter())
|
.useFilter(entity.getUseFilter())
|
||||||
.useColView(entity.getUseColView())
|
.useColView(entity.getUseColView())
|
||||||
.useIntrvwerView(entity.getUseIntrvwerView())
|
.useIntrvwerView(entity.getUseIntrvwerView())
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import jakarta.persistence.Table;
|
|||||||
import jakarta.persistence.UniqueConstraint;
|
import jakarta.persistence.UniqueConstraint;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import jakarta.validation.constraints.Size;
|
import jakarta.validation.constraints.Size;
|
||||||
import java.time.Duration;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
@@ -155,19 +154,6 @@ public class TListCallHistEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean markUserHangup(LocalDateTime endDt) {
|
|
||||||
if (this.callStatus == CallStatus.CALL_CLOSE) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
LocalDateTime resolvedEndDt = this.endDt == null ? endDt : this.endDt;
|
|
||||||
int durationSeconds = durationSeconds(this.startDt, resolvedEndDt);
|
|
||||||
this.endDt = resolvedEndDt;
|
|
||||||
this.totalTime = durationSeconds;
|
|
||||||
this.talkTime = durationSeconds;
|
|
||||||
this.callStatus = CallStatus.USER_HANGUP;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static LocalDateTime resolveEndDt(ListCallCloseRequestDto request, LocalDateTime now) {
|
private static LocalDateTime resolveEndDt(ListCallCloseRequestDto request, LocalDateTime now) {
|
||||||
return isCompletedRequest(request) ? now : null;
|
return isCompletedRequest(request) ? now : null;
|
||||||
}
|
}
|
||||||
@@ -181,14 +167,6 @@ public class TListCallHistEntity {
|
|||||||
|| isPositive(request.getTalkTime());
|
|| isPositive(request.getTalkTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int durationSeconds(LocalDateTime startDt, LocalDateTime endDt) {
|
|
||||||
if (startDt == null || endDt == null || endDt.isBefore(startDt)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
long seconds = Duration.between(startDt, endDt).getSeconds();
|
|
||||||
return seconds > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) seconds;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isPositive(Integer value) {
|
private static boolean isPositive(Integer value) {
|
||||||
return value != null && value > 0;
|
return value != null && value > 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,6 +46,10 @@ public class TListHeaderEntity {
|
|||||||
@Column(name = "list_hder_ty", nullable = false)
|
@Column(name = "list_hder_ty", nullable = false)
|
||||||
private Short listHderTy;
|
private Short listHderTy;
|
||||||
|
|
||||||
|
@Size(max = 16)
|
||||||
|
@Column(name = "list_hder_color", length = 16)
|
||||||
|
private String listHderColor;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@ColumnDefault("0")
|
@ColumnDefault("0")
|
||||||
@Column(name = "use_filter", nullable = false)
|
@Column(name = "use_filter", nullable = false)
|
||||||
@@ -103,6 +107,7 @@ public class TListHeaderEntity {
|
|||||||
.listHderGrad(src.getListHderGrad())
|
.listHderGrad(src.getListHderGrad())
|
||||||
.listHderNm(src.getListHderNm() == null ? null : src.getListHderNm().trim())
|
.listHderNm(src.getListHderNm() == null ? null : src.getListHderNm().trim())
|
||||||
.listHderTy(src.getListHderTy())
|
.listHderTy(src.getListHderTy())
|
||||||
|
.listHderColor(src.getListHderColor())
|
||||||
.useFilter(src.getUseFilter())
|
.useFilter(src.getUseFilter())
|
||||||
.useColView(src.getUseColView())
|
.useColView(src.getUseColView())
|
||||||
.useIntrvwerView(src.getUseIntrvwerView())
|
.useIntrvwerView(src.getUseIntrvwerView())
|
||||||
@@ -119,6 +124,7 @@ public class TListHeaderEntity {
|
|||||||
.listHderGrad(dto.getListHderGrad().getCode())
|
.listHderGrad(dto.getListHderGrad().getCode())
|
||||||
.listHderNm(dto.getListHderNm())
|
.listHderNm(dto.getListHderNm())
|
||||||
.listHderTy(dto.getListHderTy().getCode())
|
.listHderTy(dto.getListHderTy().getCode())
|
||||||
|
.listHderColor(dto.getListHderColor())
|
||||||
.useFilter(dto.getUseFilter())
|
.useFilter(dto.getUseFilter())
|
||||||
.useColView(dto.getUseColView())
|
.useColView(dto.getUseColView())
|
||||||
.useIntrvwerView(dto.getUseIntrvwerView())
|
.useIntrvwerView(dto.getUseIntrvwerView())
|
||||||
|
|||||||
@@ -102,24 +102,6 @@ public class ListCallHistService {
|
|||||||
return ListCallHistDto.from(entity);
|
return ListCallHistDto.from(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
|
||||||
public ListCallHistDto findByAgentSessionId(
|
|
||||||
String agentSessionId,
|
|
||||||
String userId,
|
|
||||||
String userCmpn,
|
|
||||||
Integer userRole
|
|
||||||
) {
|
|
||||||
validateAgentSessionId(agentSessionId);
|
|
||||||
TListCallHistEntity entity = listCallHistRepository.findByAgentSessionId(agentSessionId)
|
|
||||||
.orElseThrow(() -> BusinessException.notFound(
|
|
||||||
"CALL_HISTORY_NOT_FOUND",
|
|
||||||
"통화 이력을 찾을 수 없습니다."
|
|
||||||
).with("agentSessionId", agentSessionId));
|
|
||||||
|
|
||||||
validateUsableCallHistory(entity, userId, userCmpn, userRole, "CALL_HISTORY_NOT_FOUND");
|
|
||||||
return ListCallHistDto.from(entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public void validateListCallHistoryForEvent(
|
public void validateListCallHistoryForEvent(
|
||||||
Long listCallHistIdx,
|
Long listCallHistIdx,
|
||||||
@@ -153,16 +135,6 @@ public class ListCallHistService {
|
|||||||
validateUsableCallHistory(entity, userId, userCmpn, userRole, "CALL_HISTORY_FORBIDDEN");
|
validateUsableCallHistory(entity, userId, userCmpn, userRole, "CALL_HISTORY_FORBIDDEN");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public boolean hangupClient(
|
|
||||||
String agentSessionId
|
|
||||||
) {
|
|
||||||
validateAgentSessionId(agentSessionId);
|
|
||||||
return listCallHistRepository.findByAgentSessionId(agentSessionId)
|
|
||||||
.map(entity -> entity.markUserHangup(LocalDateTime.now()))
|
|
||||||
.orElse(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void validateAgentSessionId(String agentSessionId) {
|
private void validateAgentSessionId(String agentSessionId) {
|
||||||
if (!hasText(agentSessionId) || agentSessionId.length() > 64) {
|
if (!hasText(agentSessionId) || agentSessionId.length() > 64) {
|
||||||
throw BusinessException.badRequest(
|
throw BusinessException.badRequest(
|
||||||
|
|||||||
@@ -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.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_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.SYSTEM_USER_NAME;
|
||||||
import static com.kri.contact.server.common.consts.ContactConstant.UPPER_CASE_HEADER_OPTIONS;
|
import static com.kri.contact.server.common.consts.ContactConstant.UPPER_CASE_HEADER_OPTIONS;
|
||||||
|
|
||||||
@@ -245,6 +246,16 @@ public class ListHeaderService {
|
|||||||
.with("invalidHeaderList", invalidHeaderList);
|
.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);
|
validateUniqueHeaderNames(headerList);
|
||||||
|
|
||||||
// headerList에 없는 헤더는 삭제
|
// headerList에 없는 헤더는 삭제
|
||||||
@@ -403,6 +414,7 @@ public class ListHeaderService {
|
|||||||
case TEL_NUM -> ListHeaderType.TEL_NUM;
|
case TEL_NUM -> ListHeaderType.TEL_NUM;
|
||||||
case FILE -> ListHeaderType.FILE;
|
case FILE -> ListHeaderType.FILE;
|
||||||
case CONTENT_ITEM -> ListHeaderType.CONTENT_ITEM;
|
case CONTENT_ITEM -> ListHeaderType.CONTENT_ITEM;
|
||||||
|
case MULTILINE_TEXT -> ListHeaderType.MULTILINE_TEXT;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -380,7 +380,7 @@ public class ListUploadService {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (header.getListHderTy() == ListHeaderType.TEXT) {
|
if (header.getListHderTy() != null && header.getListHderTy().isText()) {
|
||||||
raw = escapeUnsafeText(raw);
|
raw = escapeUnsafeText(raw);
|
||||||
}
|
}
|
||||||
if (header.getListHderTy() == ListHeaderType.EMAIL) {
|
if (header.getListHderTy() == ListHeaderType.EMAIL) {
|
||||||
@@ -631,7 +631,7 @@ public class ListUploadService {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (header.getListHderTy() == ListHeaderType.TEXT) {
|
if (header.getListHderTy() != null && header.getListHderTy().isText()) {
|
||||||
raw = escapeUnsafeText(raw);
|
raw = escapeUnsafeText(raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user