Compare commits
16 Commits
d5be6c9b8f
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| a0f8684798 | |||
| ad6a302867 | |||
| 6aaf35adf6 | |||
| 548dca52c3 | |||
| d05db04a19 | |||
| 86e4a02759 | |||
| 47d350d3f5 | |||
| 5f11e3184e | |||
| 3197c4e16f | |||
| 27dfb4d26f | |||
| ab0eed8587 | |||
| 2ea40970cd | |||
| c4ef361c3d | |||
| b15035cb32 | |||
| 88e0ddc274 | |||
| cdb63683d8 |
@@ -38,7 +38,7 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "com.kri.common:starter:beta.1.7.0"
|
||||
implementation "com.kri.common:starter:beta.1.7.1"
|
||||
|
||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-security'
|
||||
|
||||
@@ -23,10 +23,11 @@ public final class ContactConstant {
|
||||
public static final int OUTSOURCE_USER_ROLE = 4000;
|
||||
public static final int FIELDWORK_USER_ROLE = 9000;
|
||||
public static final StreamingReadOptions UPPER_CASE_HEADER_OPTIONS =
|
||||
new StreamingReadOptions(null, 0, 1, header -> header == null ? null : header.toUpperCase(
|
||||
new StreamingReadOptions(null, 0, 1, header -> header == null ? null : header.trim().toUpperCase(
|
||||
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;
|
||||
|
||||
|
||||
@@ -16,10 +16,6 @@ public enum ChannelType implements CodeEnum<Short> {
|
||||
|
||||
private final Short code;
|
||||
|
||||
ChannelType(CodeEnum<Short> source) {
|
||||
this.code = source.getCode();
|
||||
}
|
||||
|
||||
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
|
||||
public static ChannelType fromCode(Short code) {
|
||||
if (code == null) {
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.contact.server.common.external.notihub.dto.NotiHubBulkSendCreateRequestDto;
|
||||
import com.kri.contact.server.common.external.notihub.dto.NotiHubBulkSendInfoDto;
|
||||
import com.kri.contact.server.common.external.notihub.dto.NotiHubBulkSendResponseDto;
|
||||
import com.kri.contact.server.common.external.notihub.dto.NotiHubKkoSenderProfileDto;
|
||||
import com.kri.contact.server.common.external.notihub.dto.NotiHubKkoTemplateDetailDto;
|
||||
import com.kri.contact.server.common.external.notihub.dto.NotiHubKkoTemplateDetailRequestDto;
|
||||
import com.kri.contact.server.common.external.notihub.dto.NotiHubKkoTemplateListRequestDto;
|
||||
@@ -132,6 +133,13 @@ public class NotiHubApiClient {
|
||||
return sendBulk("/send-kko/bulk", request);
|
||||
}
|
||||
|
||||
public ResponseEntity<List<NotiHubKkoSenderProfileDto>> getKkoSenderProfiles(
|
||||
HttpServletRequest request,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
return relay(request, null, new ParameterizedTypeReference<>() {}, ctx);
|
||||
}
|
||||
|
||||
public ResponseEntity<NotiHubKkoTemplateListResponseDto> getKkoTemplateList(
|
||||
NotiHubKkoTemplateListRequestDto body,
|
||||
HttpServletRequest request,
|
||||
@@ -198,6 +206,13 @@ public class NotiHubApiClient {
|
||||
return relay(request, null, NotiHubTemplateDetailDto.class, ctx);
|
||||
}
|
||||
|
||||
public ResponseEntity<byte[]> deleteTemplate(
|
||||
HttpServletRequest request,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
return forward(request, null, null, ctx);
|
||||
}
|
||||
|
||||
public ResponseEntity<NotiHubTemplateDetailDto> createTemplate(
|
||||
NotiHubTemplateBasicDto template,
|
||||
List<MultipartFile> files,
|
||||
|
||||
11
src/main/java/com/kri/contact/server/common/external/notihub/dto/NotiHubKkoSenderProfileDto.java
vendored
Normal file
11
src/main/java/com/kri/contact/server/common/external/notihub/dto/NotiHubKkoSenderProfileDto.java
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
package com.kri.contact.server.common.external.notihub.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
@Schema(description = "Kakao sender profile")
|
||||
public record NotiHubKkoSenderProfileDto(
|
||||
String senderKey,
|
||||
String name,
|
||||
String uuid
|
||||
) {
|
||||
}
|
||||
@@ -1,11 +1,14 @@
|
||||
package com.kri.contact.server.common.external.notihub.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
public record NotiHubKkoTemplateDetailRequestDto(
|
||||
|
||||
@Schema(description = "Selected sender profile key; validated by NotiHub", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
String senderKey,
|
||||
@NotBlank
|
||||
@Size(max = 30)
|
||||
@Pattern(regexp = "[A-Za-z0-9_-]+")
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.kri.contact.server.common.external.notihub.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
public record NotiHubKkoTemplateListRequestDto(
|
||||
|
||||
@Schema(description = "Selected sender profile key; validated by NotiHub", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
String senderKey,
|
||||
@Size(min = 2, max = 50)
|
||||
String keyword
|
||||
) {
|
||||
|
||||
@@ -27,7 +27,7 @@ public class NotiHubTemplateBasicDto extends NotiHubExtensibleDto {
|
||||
private Short tmplatPurpose;
|
||||
|
||||
@NotBlank
|
||||
@Size(max = 32)
|
||||
@Size(max = 128)
|
||||
private String tmplatNm;
|
||||
|
||||
@Size(max = 128)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.kri.contact.server.controller;
|
||||
|
||||
import com.kri.common.feature.auth.dto.JwtUserClaimsDto;
|
||||
import com.kri.common.feature.datetime.DateTimeUtil;
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.contact.server.dto.auth.LoginRequestDto;
|
||||
@@ -11,6 +12,10 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.CacheControl;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.core.annotation.CurrentSecurityContext;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
@@ -40,6 +45,14 @@ public class AuthController {
|
||||
return response;
|
||||
}
|
||||
|
||||
@Operation(summary = "현재 인증 사용자 조회")
|
||||
@GetMapping("/my-info")
|
||||
public ResponseEntity<JwtUserClaimsDto> myInfo(
|
||||
@CurrentSecurityContext(expression = "authentication.details") JwtUserClaimsDto user
|
||||
) {
|
||||
return ResponseEntity.ok().cacheControl(CacheControl.noStore()).body(user);
|
||||
}
|
||||
|
||||
@Operation(summary = "로그아웃 요청")
|
||||
@PostMapping("/logout/{userId}")
|
||||
public boolean logout(@PathVariable String userId, RequestUserContext ctx) {
|
||||
|
||||
@@ -11,8 +11,6 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import java.time.LocalDateTime;
|
||||
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.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
@@ -66,27 +64,4 @@ public class ListCallHistController {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.kri.contact.server.controller;
|
||||
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.contact.server.common.external.notihub.dto.NotiHubKkoSenderProfileDto;
|
||||
import com.kri.contact.server.common.external.notihub.dto.NotiHubKkoTemplateDetailDto;
|
||||
import com.kri.contact.server.common.external.notihub.dto.NotiHubKkoTemplateDetailRequestDto;
|
||||
import com.kri.contact.server.common.external.notihub.dto.NotiHubKkoTemplateListRequestDto;
|
||||
@@ -16,6 +17,7 @@ import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PatchMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
@@ -36,6 +38,14 @@ public class MessageTemplateController {
|
||||
|
||||
private final MessageTemplateService messageTemplateService;
|
||||
|
||||
@GetMapping("/kko/profiles")
|
||||
public ResponseEntity<List<NotiHubKkoSenderProfileDto>> getKkoSenderProfiles(
|
||||
HttpServletRequest request,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
return messageTemplateService.getKkoSenderProfiles(request, ctx);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/kko/list", consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<NotiHubKkoTemplateListResponseDto> getKkoTemplateList(
|
||||
@Valid @RequestBody NotiHubKkoTemplateListRequestDto body,
|
||||
@@ -72,6 +82,15 @@ public class MessageTemplateController {
|
||||
return messageTemplateService.getTemplate(request, ctx);
|
||||
}
|
||||
|
||||
@DeleteMapping("/{tmplatIdx:[0-9]+}")
|
||||
public ResponseEntity<byte[]> deleteTemplate(
|
||||
@PathVariable Long tmplatIdx,
|
||||
HttpServletRequest request,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
return messageTemplateService.deleteTemplate(tmplatIdx, request, ctx);
|
||||
}
|
||||
|
||||
@GetMapping("/{tmplatIdx:[0-9]+}/attachment")
|
||||
public ResponseEntity<byte[]> getAttachment(
|
||||
@PathVariable Long tmplatIdx,
|
||||
|
||||
@@ -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;
|
||||
@@ -60,6 +64,29 @@ public class ListHeaderDto {
|
||||
@Schema(description = "면접원 수정가능 여부")
|
||||
private Boolean useIntrvwerEdit = false;
|
||||
|
||||
public String getListHderNm() {
|
||||
return listHderNm == null ? null : listHderNm.trim();
|
||||
}
|
||||
|
||||
public void setListHderNm(String listHderNm) {
|
||||
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())
|
||||
@@ -68,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())
|
||||
@@ -83,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())
|
||||
@@ -96,7 +125,7 @@ public class ListHeaderDto {
|
||||
.listHderId(headerId)
|
||||
.listHderOrder((short) headerId)
|
||||
.listHderGrad(ListHeaderGrade.COMMON)
|
||||
.listHderNm(headerName)
|
||||
.listHderNm(headerName == null ? null : headerName.trim())
|
||||
.listHderTy(type)
|
||||
.useFilter(true)
|
||||
.useColView(true)
|
||||
@@ -109,13 +138,13 @@ public class ListHeaderDto {
|
||||
return Objects.equals(listHderId, dto.listHderId) &&
|
||||
Objects.equals(listHderOrder, dto.listHderOrder) &&
|
||||
Objects.equals(listHderGrad, dto.listHderGrad) &&
|
||||
Objects.equals(listHderNm, dto.listHderNm) &&
|
||||
Objects.equals(getListHderNm(), dto.getListHderNm()) &&
|
||||
Objects.equals(listHderTy, dto.listHderTy);
|
||||
}
|
||||
|
||||
public boolean isEqualSimple(ListHeaderDto dto) {
|
||||
return Objects.equals(listHderId, dto.listHderId) &&
|
||||
Objects.equals(listHderGrad, dto.listHderGrad) &&
|
||||
Objects.equals(listHderNm, dto.listHderNm);
|
||||
Objects.equals(getListHderNm(), dto.getListHderNm());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.kri.contact.server.dto.message;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import lombok.Builder;
|
||||
|
||||
@Builder
|
||||
@Schema(description = "MessageFailedChunkDto")
|
||||
public record MessageFailedChunkDto(
|
||||
|
||||
@Schema(description = "chunkIndex")
|
||||
int chunkIndex,
|
||||
|
||||
@Schema(description = "from")
|
||||
int from,
|
||||
|
||||
@Schema(description = "to")
|
||||
int to,
|
||||
|
||||
@Schema(description = "targetCount")
|
||||
int targetCount,
|
||||
|
||||
@Schema(description = "errorMessage")
|
||||
String errorMessage
|
||||
) {
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package com.kri.contact.server.dto.message;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import lombok.Builder;
|
||||
|
||||
@Builder
|
||||
@Schema(description = "MessageBulkSendResponseDto")
|
||||
public record MessageSendBulkResponseDto(
|
||||
|
||||
@Schema(description = "bulkSendKey")
|
||||
String bulkSendKey,
|
||||
|
||||
@Schema(description = "targetCount")
|
||||
int targetCount,
|
||||
|
||||
@Schema(description = "requestCount")
|
||||
int requestCount,
|
||||
|
||||
@Schema(description = "acceptCount")
|
||||
int acceptCount,
|
||||
|
||||
@Schema(description = "failCount")
|
||||
int failCount,
|
||||
|
||||
@Schema(description = "failedChunks")
|
||||
List<MessageFailedChunkDto> failedChunks
|
||||
) {
|
||||
|
||||
public static class MessageSendBulkResponseDtoBuilder {
|
||||
private boolean failedChunksSet;
|
||||
private List<MessageFailedChunkDto> failedChunks;
|
||||
|
||||
public MessageSendBulkResponseDtoBuilder failedChunks(List<MessageFailedChunkDto> failedChunks) {
|
||||
this.failedChunks = failedChunks;
|
||||
this.failedChunksSet = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MessageSendBulkResponseDto build() {
|
||||
return new MessageSendBulkResponseDto(
|
||||
bulkSendKey, targetCount, requestCount, acceptCount, failCount,
|
||||
failedChunksSet ? failedChunks : new ArrayList<>()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,6 @@ import jakarta.persistence.Table;
|
||||
import jakarta.persistence.UniqueConstraint;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.AllArgsConstructor;
|
||||
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) {
|
||||
return isCompletedRequest(request) ? now : null;
|
||||
}
|
||||
@@ -181,14 +167,6 @@ public class TListCallHistEntity {
|
||||
|| 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) {
|
||||
return value != null && value > 0;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
@@ -101,8 +105,9 @@ public class TListHeaderEntity {
|
||||
.id(TListHeaderEntityId.create(prjctIdx, src.getListHderId()))
|
||||
.listHderOrder(src.getListHderOrder())
|
||||
.listHderGrad(src.getListHderGrad())
|
||||
.listHderNm(src.getListHderNm())
|
||||
.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())
|
||||
|
||||
@@ -220,20 +220,5 @@ public class ListResetJdbcSupport {
|
||||
);
|
||||
}
|
||||
|
||||
public DeleteCounts plus(DeleteCounts other) {
|
||||
return new DeleteCounts(
|
||||
fileCount + other.fileCount,
|
||||
callHistCount + other.callHistCount,
|
||||
eventHistCount + other.eventHistCount,
|
||||
eventLatestCount + other.eventLatestCount,
|
||||
updateHistCount + other.updateHistCount,
|
||||
itemCount + other.itemCount,
|
||||
listCount + other.listCount,
|
||||
assignUserCount + other.assignUserCount,
|
||||
assignCmpnCount + other.assignCmpnCount,
|
||||
resveCount + other.resveCount
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,10 +4,14 @@ import com.kri.contact.server.persistence.entity.TPrjctMainTmplatEntity;
|
||||
import com.kri.contact.server.persistence.entity.id.TPrjctMainTmplatEntityId;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
public interface ProjectMainTemplateRepository extends JpaRepository<TPrjctMainTmplatEntity, TPrjctMainTmplatEntityId> {
|
||||
|
||||
Optional<TPrjctMainTmplatEntity> findByIdPrjctIdxAndIdChnnlTy(Long prjctIdx, Short chnnlTy);
|
||||
|
||||
long deleteByIdPrjctIdxAndIdChnnlTy(Long prjctIdx, Short chnnlTy);
|
||||
|
||||
@Transactional
|
||||
long deleteByTmplatIdx(Long tmplatIdx);
|
||||
}
|
||||
|
||||
@@ -21,17 +21,6 @@ public class ListResetPersistenceSupport {
|
||||
private final ListDeleteSessionContext deleteSessionContext;
|
||||
private final EntityManager entityManager;
|
||||
|
||||
public int resetWithAuditContext(
|
||||
Long prjctIdx,
|
||||
Collection<String> sids,
|
||||
ListResetMode mode,
|
||||
String listResetLogId,
|
||||
String delUser,
|
||||
int chunkSize
|
||||
) {
|
||||
return resetWithAuditContext(prjctIdx, sids, mode, listResetLogId, delUser, chunkSize, false);
|
||||
}
|
||||
|
||||
public int resetChunkWithAuditContext(Long projectId, Collection<String> sids, ListResetMode mode,
|
||||
String logId, String user, int chunkSize) {
|
||||
return resetWithAuditContext(projectId, sids, mode, logId, user, chunkSize, true);
|
||||
|
||||
@@ -102,24 +102,6 @@ public class ListCallHistService {
|
||||
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)
|
||||
public void validateListCallHistoryForEvent(
|
||||
Long listCallHistIdx,
|
||||
@@ -153,16 +135,6 @@ public class ListCallHistService {
|
||||
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) {
|
||||
if (!hasText(agentSessionId) || agentSessionId.length() > 64) {
|
||||
throw BusinessException.badRequest(
|
||||
|
||||
@@ -24,7 +24,6 @@ import com.kri.contact.server.persistence.repository.ProjectRepository;
|
||||
import com.kri.contact.server.persistence.repository.ProjectSurveyRepository;
|
||||
import com.kri.contact.server.persistence.repository.ResultCodeRepository;
|
||||
import com.kri.contact.server.service.file.ListItemFileService;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.time.LocalDateTime;
|
||||
@@ -112,18 +111,6 @@ public class ListDownloadService {
|
||||
default void beforeWrite() { checkCancelled(); }
|
||||
}
|
||||
|
||||
private static final DownloadObserver NO_OBSERVER = new DownloadObserver() {};
|
||||
|
||||
public byte[] downloadList(
|
||||
Long prjctIdx,
|
||||
ListFilterDto listFilter,
|
||||
boolean includeResult
|
||||
) {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
writeList(prjctIdx, listFilter, includeResult, out, NO_OBSERVER);
|
||||
return out.toByteArray();
|
||||
}
|
||||
|
||||
public void writeList(
|
||||
Long prjctIdx,
|
||||
ListFilterDto listFilter,
|
||||
@@ -189,20 +176,6 @@ public class ListDownloadService {
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] downloadListWithEventHist(
|
||||
Long prjctIdx,
|
||||
ListFilterDto listFilter,
|
||||
Collection<ResultCodeType> resultCodeTypes,
|
||||
ListEventHistoryBase searchBase,
|
||||
DateRangeDto dateRange,
|
||||
ListEventHistoryOrder historyOrder,
|
||||
boolean includeResult
|
||||
) {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
writeListWithEventHist(prjctIdx, listFilter, resultCodeTypes, searchBase, dateRange, historyOrder, includeResult, out, NO_OBSERVER);
|
||||
return out.toByteArray();
|
||||
}
|
||||
|
||||
public void writeListWithEventHist(
|
||||
Long prjctIdx,
|
||||
ListFilterDto listFilter,
|
||||
@@ -309,12 +282,6 @@ public class ListDownloadService {
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] downloadSidWithUpdateHist(Long prjctIdx, ListFilterDto listFilter) {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
writeSidWithUpdateHist(prjctIdx, listFilter, out, NO_OBSERVER);
|
||||
return out.toByteArray();
|
||||
}
|
||||
|
||||
public void writeSidWithUpdateHist(Long prjctIdx, ListFilterDto listFilter, OutputStream out, DownloadObserver observer) {
|
||||
observer.checkCancelled();
|
||||
int maxHistoryGroupCount = findMaxUpdateHistoryGroupCount(prjctIdx, listFilter, observer);
|
||||
@@ -367,12 +334,6 @@ public class ListDownloadService {
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] downloadItemFile(Long prjctIdx, ListFilterDto listFilter) {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
writeItemFile(prjctIdx, listFilter, out, NO_OBSERVER);
|
||||
return out.toByteArray();
|
||||
}
|
||||
|
||||
public void writeItemFile(Long prjctIdx, ListFilterDto listFilter, OutputStream out, DownloadObserver observer) {
|
||||
observer.checkCancelled();
|
||||
List<ListHeaderDto> fileHeaders = getSortedHeaders(prjctIdx).stream()
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -116,6 +117,10 @@ public class ListHeaderService {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
excelHeaders = excelHeaders.stream()
|
||||
.map(name -> name == null ? null : name.trim())
|
||||
.toList();
|
||||
|
||||
List<ListHeaderDto> defaultHeaders = listHeaderRepository.findDefaultHeader().stream()
|
||||
.map(ListHeaderDto::fromEntity)
|
||||
.sorted(Comparator.comparing(ListHeaderDto::getListHderId))
|
||||
@@ -241,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에 없는 헤더는 삭제
|
||||
@@ -340,7 +355,7 @@ public class ListHeaderService {
|
||||
Map<String, Integer> headerIdByName = createHeaderIdByNameMap(getHeader(prjctIdx));
|
||||
if (!ignoreUnknownHeaders) {
|
||||
Set<String> missingHeaderNames = contentsByHeaderName.keySet().stream()
|
||||
.filter(name -> !headerIdByName.containsKey(name))
|
||||
.filter(name -> !headerIdByName.containsKey(name == null ? null : name.trim()))
|
||||
.collect(LinkedHashSet::new, LinkedHashSet::add, LinkedHashSet::addAll);
|
||||
|
||||
if (!missingHeaderNames.isEmpty()) {
|
||||
@@ -351,7 +366,7 @@ public class ListHeaderService {
|
||||
|
||||
Map<Integer, String> contentsByHeaderId = new LinkedHashMap<>();
|
||||
contentsByHeaderName.forEach((name, value) -> {
|
||||
Integer headerId = headerIdByName.get(name);
|
||||
Integer headerId = headerIdByName.get(name == null ? null : name.trim());
|
||||
if (headerId != null) {
|
||||
contentsByHeaderId.put(headerId, value);
|
||||
}
|
||||
@@ -399,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;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package com.kri.contact.server.service;
|
||||
|
||||
import static com.kri.contact.server.common.util.SidUtil.requireValidFilterConditions;
|
||||
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import com.kri.contact.server.common.consts.ContactConstant;
|
||||
import com.kri.contact.server.common.enums.ListResetMode;
|
||||
import com.kri.contact.server.dto.list.ListFilterDto;
|
||||
import com.kri.contact.server.dto.list.ListResetRequestDto;
|
||||
import com.kri.contact.server.dto.list.ListResetScopeDto;
|
||||
import com.kri.contact.server.persistence.entity.TListResetLogEntity;
|
||||
@@ -26,7 +24,6 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
public class ListResetService {
|
||||
|
||||
private final ListResetLogRepository listResetLogRepository;
|
||||
private final ListSearchService listSearchService;
|
||||
private final ListResetPersistenceSupport listResetPersistenceSupport;
|
||||
private final ProjectSurveyRepository projectSurveyRepository;
|
||||
|
||||
@@ -75,39 +72,6 @@ public class ListResetService {
|
||||
return BusinessException.badRequest("INVALID_LIST_RESET", message);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public int resetByFilter(
|
||||
Long prjctIdx,
|
||||
ListFilterDto filter,
|
||||
ListResetMode mode,
|
||||
String regUser,
|
||||
LocalDateTime regDt
|
||||
) {
|
||||
requireValidFilterConditions(filter == null ? null : filter.getSidSet());
|
||||
Set<String> sids = listSearchService.findTargetSids(prjctIdx, filter);
|
||||
return resetBySids(prjctIdx, sids, mode, regUser, regDt);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public int resetBySids(
|
||||
Long prjctIdx,
|
||||
Set<String> sids,
|
||||
ListResetMode mode,
|
||||
String regUser,
|
||||
LocalDateTime regDt
|
||||
) {
|
||||
if (sids == null || sids.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
if (mode == null) {
|
||||
throw BusinessException.badRequest("EMPTY_MODE", "mode는 필수 입니다.");
|
||||
}
|
||||
|
||||
String listResetLogId = createResetLog(prjctIdx, mode, 0, regUser, regDt);
|
||||
return listResetPersistenceSupport.resetWithAuditContext(
|
||||
prjctIdx, sids, mode, listResetLogId, regUser, ContactConstant.INSERT_CHUNK_SIZE);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public String createResetLog(
|
||||
Long prjctIdx,
|
||||
|
||||
@@ -21,8 +21,6 @@ import com.kri.contact.server.common.enums.ListHeaderTypeSpecific;
|
||||
import com.kri.contact.server.common.enums.ListIsUse;
|
||||
import com.kri.contact.server.common.enums.ListResetMode;
|
||||
import com.kri.contact.server.common.enums.ListUploadMode;
|
||||
import com.kri.contact.server.common.util.ExcelUploadResultUtil;
|
||||
import com.kri.contact.server.dto.excel.ExcelUploadResultDto;
|
||||
import com.kri.contact.server.dto.excel.ListUploadErrorDto;
|
||||
import com.kri.contact.server.dto.list.ListFilterDto;
|
||||
import com.kri.contact.server.dto.list.ListHeaderDto;
|
||||
@@ -196,124 +194,6 @@ public class ListUploadService {
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public ExcelUploadResultDto uploadExcel(
|
||||
Long prjctIdx,
|
||||
MultipartFile file,
|
||||
ListUploadRequestDto request,
|
||||
String uploadUser,
|
||||
LocalDateTime uploadDt
|
||||
) {
|
||||
Path listFilePath = listFileService.saveListFile(file, prjctIdx);
|
||||
|
||||
List<String> excelHeaders = ExcelMapper.readHeaderStreaming(listFilePath,
|
||||
UPPER_CASE_HEADER_OPTIONS);
|
||||
List<ListUploadErrorDto> headerErrorList = new ArrayList<>();
|
||||
|
||||
List<ListHeaderDto> resolvedHeaders = listHeaderService.resolveUploadHeaders(
|
||||
prjctIdx,
|
||||
excelHeaders,
|
||||
request,
|
||||
headerErrorList
|
||||
);
|
||||
if (!headerErrorList.isEmpty()) {
|
||||
listFilePath = markUploadFailed(prjctIdx, listFilePath, null);
|
||||
return buildErrorResponse(0, headerErrorList, listFilePath);
|
||||
}
|
||||
|
||||
List<ListHeaderDto> existingHeaders = listHeaderService.getHeader(prjctIdx).stream()
|
||||
.map(ListHeaderDto.class::cast)
|
||||
.toList();
|
||||
List<ListHeaderDto> existingCommon = existingHeaders.stream()
|
||||
.filter(h -> Objects.equals(h.getListHderGrad(), ListHeaderGrade.COMMON))
|
||||
.sorted(Comparator.comparing(ListHeaderDto::getListHderOrder))
|
||||
.toList();
|
||||
|
||||
if (!existingCommon.isEmpty() && !listHeaderService.isEqualHeader(existingHeaders, resolvedHeaders, true)) {
|
||||
listFilePath = markUploadFailed(prjctIdx, listFilePath, null);
|
||||
headerErrorList.add(ListUploadErrorDto.of(1, "헤더", "기존 헤더와 업로드 헤더가 일치하지 않습니다."));
|
||||
return buildErrorResponse(0, headerErrorList, listFilePath);
|
||||
}
|
||||
|
||||
List<String> prjctAssignList = assignService.getPrjctFieldworkAssign(prjctIdx);
|
||||
List<String> prjctAssignCmpnList = assignService.getPrjctCmpnAssign(prjctIdx);
|
||||
Map<String, Integer> userRoleByUserId = assignService.findActiveUserRoleMap(prjctAssignList);
|
||||
Map<String, Short> assignRoleByHeaderName = createAssignRoleByHeaderName(resolvedHeaders);
|
||||
Map<Short, Set<String>> allowedUserRolesByAssignRole =
|
||||
assignService.findAllowedUserRolesByAssignRole(new LinkedHashSet<>(assignRoleByHeaderName.values()));
|
||||
Map<String, TCmpnEntity> cmpnByUploadText = createCmpnByUploadText(resolvedHeaders, listFilePath);
|
||||
|
||||
TListUploadLogEntity uploadLog = createPendingLog(
|
||||
prjctIdx,
|
||||
listFilePath,
|
||||
request,
|
||||
uploadUser,
|
||||
uploadDt
|
||||
);
|
||||
|
||||
ValidationSummary validation = validateFile(
|
||||
prjctIdx,
|
||||
listFilePath,
|
||||
request,
|
||||
resolvedHeaders,
|
||||
prjctAssignList,
|
||||
prjctAssignCmpnList,
|
||||
userRoleByUserId,
|
||||
assignRoleByHeaderName,
|
||||
allowedUserRolesByAssignRole,
|
||||
cmpnByUploadText,
|
||||
uploadLog.getListUploadLogId()
|
||||
);
|
||||
|
||||
markValidated(uploadLog, validation.totalCount());
|
||||
|
||||
if (!validation.errors().isEmpty()) {
|
||||
listUploadJdbcSupport.deleteTemp(uploadLog.getListUploadLogId());
|
||||
listFilePath = markUploadFailed(prjctIdx, listFilePath, uploadLog);
|
||||
return buildErrorResponse(validation.totalCount(), validation.errors(), listFilePath);
|
||||
}
|
||||
|
||||
if (existingCommon.isEmpty()) {
|
||||
listHeaderService.upsertHeader(prjctIdx, resolvedHeaders, uploadUser, uploadDt);
|
||||
}
|
||||
|
||||
persistUpload(
|
||||
prjctIdx,
|
||||
listFilePath,
|
||||
request,
|
||||
resolvedHeaders,
|
||||
cmpnByUploadText,
|
||||
uploadLog.getListUploadLogId(),
|
||||
validation.uploadedSids(),
|
||||
uploadUser,
|
||||
uploadDt
|
||||
);
|
||||
|
||||
markSuccess(uploadLog, validation.totalCount());
|
||||
listUploadJdbcSupport.deleteTemp(uploadLog.getListUploadLogId());
|
||||
|
||||
//목록형 헤더의 값들 최신화
|
||||
listContentItemService.refreshListContentItem(prjctIdx, resolvedHeaders);
|
||||
|
||||
return ExcelUploadResultDto.success(validation.totalCount(), validation.totalCount());
|
||||
}
|
||||
|
||||
private Path markUploadFailed(Long prjctIdx, Path listFilePath, TListUploadLogEntity uploadLog) {
|
||||
Path failedFilePath = listFileService.renameFailedListFile(prjctIdx, listFilePath);
|
||||
if (uploadLog != null) {
|
||||
uploadLog.setFileNm(failedFilePath.getFileName().toString());
|
||||
listUploadLogRepository.save(uploadLog);
|
||||
}
|
||||
return failedFilePath;
|
||||
}
|
||||
|
||||
private Map<String, TCmpnEntity> createCmpnByUploadText(
|
||||
List<ListHeaderDto> resolvedHeaders,
|
||||
Path listFilePath
|
||||
) {
|
||||
return createCmpnByUploadText(resolvedHeaders, listFilePath, () -> {});
|
||||
}
|
||||
|
||||
private Map<String, TCmpnEntity> createCmpnByUploadText(List<ListHeaderDto> resolvedHeaders,
|
||||
Path listFilePath, Runnable checkCancelled) {
|
||||
String outsourceHeaderName = findOptionalHeaderNameByType(resolvedHeaders, ListHeaderType.OUTSOURCE);
|
||||
@@ -422,40 +302,6 @@ public class ListUploadService {
|
||||
listUploadLogRepository.save(uploadLog);
|
||||
}
|
||||
|
||||
private void persistUpload(
|
||||
Long prjctIdx,
|
||||
Path listFilePath,
|
||||
ListUploadRequestDto request,
|
||||
List<ListHeaderDto> resolvedHeaders,
|
||||
Map<String, TCmpnEntity> cmpnByUploadText,
|
||||
String listUploadLogId,
|
||||
Set<String> uploadedSids,
|
||||
String uploadUser,
|
||||
LocalDateTime uploadDt
|
||||
) {
|
||||
if (request.uploadMode() == ListUploadMode.RESET_AND_INSERT) {
|
||||
listResetService.resetByFilter(
|
||||
prjctIdx,
|
||||
null,
|
||||
ListResetMode.ALL,
|
||||
uploadUser,
|
||||
uploadDt
|
||||
);
|
||||
}
|
||||
else if (request.uploadMode() == ListUploadMode.ADD_AND_CHANGE && !uploadedSids.isEmpty()) {
|
||||
listResetService.resetBySids(
|
||||
prjctIdx,
|
||||
uploadedSids,
|
||||
ListResetMode.LIST_UPLOAD,
|
||||
uploadUser,
|
||||
uploadDt
|
||||
);
|
||||
}
|
||||
|
||||
readUploadChunks(prjctIdx, listFilePath, resolvedHeaders, cmpnByUploadText,
|
||||
listUploadLogId, uploadUser, uploadDt, () -> {}, this::insertUploadChunk);
|
||||
}
|
||||
|
||||
public record UploadChunk(List<ListRowInsert> lists, List<ListItemRowInsert> items,
|
||||
List<ListAssignRowInsert> users, List<ListAssignCmpnRowInsert> companies) {
|
||||
public List<String> sids() { return lists.stream().map(ListRowInsert::sid).toList(); }
|
||||
@@ -534,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) {
|
||||
@@ -677,24 +523,6 @@ public class ListUploadService {
|
||||
listUploadJdbcSupport.batchInsertListAssignCmpn(chunk.companies(), ContactConstant.INSERT_CHUNK_SIZE);
|
||||
}
|
||||
|
||||
private ValidationSummary validateFile(
|
||||
Long prjctIdx,
|
||||
Path listFilePath,
|
||||
ListUploadRequestDto request,
|
||||
List<ListHeaderDto> resolvedHeaders,
|
||||
List<String> prjctAssignList,
|
||||
List<String> prjctAssignCmpnList,
|
||||
Map<String, Integer> userRoleByUserId,
|
||||
Map<String, Short> assignRoleByHeaderName,
|
||||
Map<Short, Set<String>> allowedUserRolesByAssignRole,
|
||||
Map<String, TCmpnEntity> cmpnByUploadText,
|
||||
String listUploadLogId
|
||||
) {
|
||||
return validateFile(prjctIdx, listFilePath, request, resolvedHeaders, prjctAssignList,
|
||||
prjctAssignCmpnList, userRoleByUserId, assignRoleByHeaderName, allowedUserRolesByAssignRole,
|
||||
cmpnByUploadText, listUploadLogId, () -> {}, true);
|
||||
}
|
||||
|
||||
private ValidationSummary validateFile(Long prjctIdx, Path listFilePath, ListUploadRequestDto request,
|
||||
List<ListHeaderDto> resolvedHeaders, List<String> prjctAssignList, List<String> prjctAssignCmpnList,
|
||||
Map<String, Integer> userRoleByUserId, Map<String, Short> assignRoleByHeaderName,
|
||||
@@ -803,7 +631,7 @@ public class ListUploadService {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (header.getListHderTy() == ListHeaderType.TEXT) {
|
||||
if (header.getListHderTy() != null && header.getListHderTy().isText()) {
|
||||
raw = escapeUnsafeText(raw);
|
||||
}
|
||||
|
||||
@@ -900,31 +728,6 @@ public class ListUploadService {
|
||||
return result;
|
||||
}
|
||||
|
||||
private ExcelUploadResultDto buildErrorResponse(
|
||||
int totalCount,
|
||||
List<ListUploadErrorDto> errorList,
|
||||
Path sourceFile
|
||||
) {
|
||||
String origin = sourceFile.getFileName().toString();
|
||||
String errorFileName = origin.endsWith(".xlsx")
|
||||
? origin.substring(0, origin.length() - 5) + "_error.xlsx"
|
||||
: origin + "_error.xlsx";
|
||||
int failCount = errorList.stream()
|
||||
.map(ListUploadErrorDto::getRowNumber)
|
||||
.distinct()
|
||||
.toList()
|
||||
.size();
|
||||
|
||||
return ExcelUploadResultUtil.buildUploadResult(
|
||||
totalCount,
|
||||
0,
|
||||
failCount,
|
||||
errorList,
|
||||
ListUploadErrorDto.class,
|
||||
errorFileName
|
||||
);
|
||||
}
|
||||
|
||||
private Map<Integer, ListHeaderDto> toHeaderById(List<ListHeaderDto> headers) {
|
||||
Map<Integer, ListHeaderDto> map = new LinkedHashMap<>();
|
||||
for (ListHeaderDto h : headers) {
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.kri.contact.server.service;
|
||||
|
||||
import static com.kri.contact.server.common.consts.ContactConstant.REQUEST_SERVICE;
|
||||
import static com.kri.contact.server.common.util.SidUtil.requireSid;
|
||||
import static com.kri.contact.server.common.util.SidUtil.requireValidFilterConditions;
|
||||
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
@@ -18,8 +17,6 @@ import com.kri.contact.server.common.external.notihub.dto.NotiHubSendRequestSing
|
||||
import com.kri.contact.server.common.external.notihub.dto.NotiHubSendSingleResponseDto;
|
||||
import com.kri.contact.server.common.external.notihub.dto.NotiHubTemplateDto;
|
||||
import com.kri.contact.server.dto.list.ListHeaderDto;
|
||||
import com.kri.contact.server.dto.message.MessageSendBulkResponseDto;
|
||||
import com.kri.contact.server.dto.message.MessageFailedChunkDto;
|
||||
import com.kri.contact.server.dto.message.MessageSendBulkRequestDto;
|
||||
import com.kri.contact.server.dto.message.MessageSendSingleRequestDto;
|
||||
import com.kri.contact.server.dto.message.MessageSendSingleResponseDto;
|
||||
@@ -50,7 +47,6 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class MessageSendService {
|
||||
private static final int BULK_SEND_CHUNK_SIZE = 1_000;
|
||||
private static final Pattern TEMPLATE_PARAM_PATTERN = Pattern.compile("(?:\\[\\$|#\\{)([^\\]}]+)(?:]|})");
|
||||
|
||||
private final ProjectService projectService;
|
||||
@@ -92,16 +88,6 @@ public class MessageSendService {
|
||||
return sendSingle(prjctIdx, request, ctx, ChannelType.SMS);
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public MessageSendBulkResponseDto sendEmailBulk(Long prjctIdx, MessageSendBulkRequestDto request, RequestUserContext ctx) {
|
||||
return sendBulk(prjctIdx, request, ctx, ChannelType.EMAIL);
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public MessageSendBulkResponseDto sendSmsBulk(Long prjctIdx, MessageSendBulkRequestDto request, RequestUserContext ctx) {
|
||||
return sendBulk(prjctIdx, request, ctx, ChannelType.SMS);
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public MessageSendSingleResponseDto sendKkoSingle(
|
||||
Long prjctIdx,
|
||||
@@ -111,15 +97,6 @@ public class MessageSendService {
|
||||
return sendSingle(prjctIdx, request, ctx, ChannelType.KKO_AT);
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public MessageSendBulkResponseDto sendKkoBulk(
|
||||
Long prjctIdx,
|
||||
MessageSendBulkRequestDto request,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
return sendBulk(prjctIdx, request, ctx, ChannelType.KKO_AT);
|
||||
}
|
||||
|
||||
private MessageSendSingleResponseDto sendSingle(
|
||||
Long prjctIdx,
|
||||
MessageSendSingleRequestDto request,
|
||||
@@ -172,101 +149,6 @@ public class MessageSendService {
|
||||
return MessageSendSingleResponseDto.from(response);
|
||||
}
|
||||
|
||||
private MessageSendBulkResponseDto sendBulk(
|
||||
Long prjctIdx,
|
||||
MessageSendBulkRequestDto request,
|
||||
RequestUserContext ctx,
|
||||
ChannelType channelType
|
||||
) {
|
||||
validateDestinationHeaders(request.destHeaderIds());
|
||||
requireValidFilterConditions(
|
||||
request.listFilter() == null ? null : request.listFilter().getSidSet()
|
||||
);
|
||||
|
||||
MessageContext messageContext = createMessageContext(prjctIdx, request.tmplatIdx(), request.destHeaderIds());
|
||||
List<NotiHubDestInfoDto> destInfos = createAllDestInfos(
|
||||
prjctIdx,
|
||||
request,
|
||||
messageContext,
|
||||
channelType,
|
||||
request.dedupe()
|
||||
);
|
||||
if (destInfos.isEmpty()) {
|
||||
throw BusinessException.badRequest("NO_DESTINATION", "발송 대상 이메일 또는 전화번호가 없습니다.");
|
||||
}
|
||||
|
||||
String bulkSendKey = createBulkSendKey(request, ctx, messageContext, destInfos.size(), channelType);
|
||||
int requestCount = 0;
|
||||
int acceptCount = 0;
|
||||
int failCount = 0;
|
||||
List<MessageFailedChunkDto> failedChunks = new ArrayList<>();
|
||||
|
||||
for (int start = 0, chunkIndex = 1; start < destInfos.size(); start += BULK_SEND_CHUNK_SIZE, chunkIndex++) {
|
||||
int end = Math.min(start + BULK_SEND_CHUNK_SIZE, destInfos.size());
|
||||
List<NotiHubDestInfoDto> chunk = destInfos.subList(start, end);
|
||||
try {
|
||||
NotiHubBulkSendResponseDto response = sendBulkChunk(bulkSendKey, chunk, channelType);
|
||||
requestCount += defaultInt(response.requestCount());
|
||||
acceptCount += defaultInt(response.acceptCount());
|
||||
failCount += defaultInt(response.failCount());
|
||||
} catch (RuntimeException e) {
|
||||
requestCount += chunk.size();
|
||||
failCount += chunk.size();
|
||||
failedChunks.add(MessageFailedChunkDto.builder()
|
||||
.chunkIndex(chunkIndex)
|
||||
.from(start + 1)
|
||||
.to(end)
|
||||
.targetCount(chunk.size())
|
||||
.errorMessage(e.getMessage())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
||||
return MessageSendBulkResponseDto.builder()
|
||||
.bulkSendKey(bulkSendKey)
|
||||
.targetCount(destInfos.size())
|
||||
.requestCount(requestCount)
|
||||
.acceptCount(acceptCount)
|
||||
.failCount(failCount)
|
||||
.failedChunks(failedChunks)
|
||||
.build();
|
||||
}
|
||||
|
||||
private List<NotiHubDestInfoDto> createAllDestInfos(
|
||||
Long prjctIdx,
|
||||
MessageSendBulkRequestDto request,
|
||||
MessageContext messageContext,
|
||||
ChannelType channelType,
|
||||
boolean dedupe
|
||||
) {
|
||||
List<NotiHubDestInfoDto> destInfos = new ArrayList<>();
|
||||
Set<String> dedupeKeys = new LinkedHashSet<>();
|
||||
String lastSid = null;
|
||||
|
||||
while (true) {
|
||||
List<ListSearchService.DownloadListRow> rows = listSearchService.findDownloadListRows(
|
||||
prjctIdx,
|
||||
request.listFilter(),
|
||||
lastSid
|
||||
);
|
||||
if (rows.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
|
||||
destInfos.addAll(createDestInfos(
|
||||
rows,
|
||||
request.destHeaderIds(),
|
||||
request.destNameHeaderId(),
|
||||
messageContext,
|
||||
channelType,
|
||||
dedupeKeys,
|
||||
dedupe
|
||||
));
|
||||
lastSid = rows.get(rows.size() - 1).sid();
|
||||
}
|
||||
return destInfos;
|
||||
}
|
||||
|
||||
private List<NotiHubDestInfoDto> createDestInfos(
|
||||
Collection<ListSearchService.DownloadListRow> rows,
|
||||
List<Integer> destHeaderIds,
|
||||
@@ -537,10 +419,6 @@ public class MessageSendService {
|
||||
return trimmed.isEmpty() ? null : trimmed;
|
||||
}
|
||||
|
||||
private int defaultInt(Integer value) {
|
||||
return value == null ? 0 : value;
|
||||
}
|
||||
|
||||
public record MessageContext(
|
||||
ProjectInfoDto project,
|
||||
NotiHubTemplateDto template,
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.kri.contact.server.service;
|
||||
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.contact.server.common.external.notihub.dto.NotiHubKkoSenderProfileDto;
|
||||
import com.kri.contact.server.common.external.notihub.dto.NotiHubKkoTemplateDetailDto;
|
||||
import com.kri.contact.server.common.external.notihub.dto.NotiHubKkoTemplateDetailRequestDto;
|
||||
import com.kri.contact.server.common.external.notihub.dto.NotiHubKkoTemplateListRequestDto;
|
||||
@@ -10,6 +11,7 @@ import com.kri.contact.server.common.external.notihub.dto.NotiHubTemplateBasicDt
|
||||
import com.kri.contact.server.common.external.notihub.dto.NotiHubTemplateDetailDto;
|
||||
import com.kri.contact.server.common.external.notihub.dto.NotiHubTemplateSummaryDto;
|
||||
import com.kri.contact.server.common.external.notihub.NotiHubApiClient;
|
||||
import com.kri.contact.server.persistence.repository.ProjectMainTemplateRepository;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -22,6 +24,14 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
public class MessageTemplateService {
|
||||
|
||||
private final NotiHubApiClient notiHubApiClient;
|
||||
private final ProjectMainTemplateRepository projectMainTemplateRepository;
|
||||
|
||||
public ResponseEntity<List<NotiHubKkoSenderProfileDto>> getKkoSenderProfiles(
|
||||
HttpServletRequest request,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
return notiHubApiClient.getKkoSenderProfiles(request, ctx);
|
||||
}
|
||||
|
||||
public ResponseEntity<NotiHubKkoTemplateListResponseDto> getKkoTemplateList(
|
||||
NotiHubKkoTemplateListRequestDto body,
|
||||
@@ -53,6 +63,19 @@ public class MessageTemplateService {
|
||||
return notiHubApiClient.getTemplate(request, ctx);
|
||||
}
|
||||
|
||||
public ResponseEntity<byte[]> deleteTemplate(
|
||||
Long tmplatIdx,
|
||||
HttpServletRequest request,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
validateTemplateManager(ctx);
|
||||
ResponseEntity<byte[]> response = notiHubApiClient.deleteTemplate(request, ctx);
|
||||
if (response.getStatusCode().is2xxSuccessful()) {
|
||||
projectMainTemplateRepository.deleteByTmplatIdx(tmplatIdx);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
public ResponseEntity<byte[]> getAttachment(
|
||||
HttpServletRequest request,
|
||||
RequestUserContext ctx
|
||||
|
||||
@@ -191,11 +191,6 @@ public class ListAsyncJobStore {
|
||||
finishLocked(lock(key), errorCode, null);
|
||||
}
|
||||
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||
public void finish(String key, String errorCode, Integer failedChunkNo) {
|
||||
finishLocked(lock(key), errorCode, failedChunkNo);
|
||||
}
|
||||
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||
public void finish(String key, String errorCode, Integer failedChunkNo,
|
||||
Map<String, Object> failureDetail) {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.kri.contact.server.service.file;
|
||||
|
||||
import com.kri.common.feature.datetime.DateTimeUtil;
|
||||
import com.kri.common.feature.util.CommonUtil;
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import java.io.IOException;
|
||||
@@ -27,37 +26,11 @@ public abstract class AbstractFileService {
|
||||
return "";
|
||||
}
|
||||
|
||||
protected String extractBaseName(String originalFileName) {
|
||||
if (originalFileName == null || originalFileName.isBlank()) {
|
||||
return "file";
|
||||
}
|
||||
|
||||
String fileName = java.nio.file.Paths.get(originalFileName).getFileName().toString();
|
||||
int dot = fileName.lastIndexOf('.');
|
||||
|
||||
if (dot > 0) {
|
||||
return fileName.substring(0, dot);
|
||||
}
|
||||
|
||||
return fileName;
|
||||
}
|
||||
|
||||
protected String buildFileName(MultipartFile file) {
|
||||
String original = Optional.ofNullable(file.getOriginalFilename()).orElse("file");
|
||||
return CommonUtil.uuid32() + extractExtension(original);
|
||||
}
|
||||
|
||||
protected String buildFileNameWithTime(MultipartFile file, String prefix) {
|
||||
String original = Optional.ofNullable(file.getOriginalFilename()).orElse("file");
|
||||
String baseName = extractBaseName(original);
|
||||
String ext = extractExtension(original);
|
||||
|
||||
String timestamp = DateTimeUtil.nowKstLocalDateTime()
|
||||
.format(java.time.format.DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss"));
|
||||
|
||||
return prefix + "_" + timestamp + "_" + baseName + ext;
|
||||
}
|
||||
|
||||
protected Path createDirectories(Path dir) throws IOException {
|
||||
return Files.createDirectories(dir.toAbsolutePath().normalize());
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -26,19 +25,6 @@ public class ListFileService extends AbstractFileService {
|
||||
return Paths.get(properties.getListBaseDir()).toAbsolutePath().normalize();
|
||||
}
|
||||
|
||||
public Path saveListFile(MultipartFile file, Long prjctIdx) {
|
||||
String newFileName = buildFileNameWithTime(file, prjctIdx.toString());
|
||||
Path dir = getBaseDir().resolve(prjctIdx.toString()).toAbsolutePath().normalize();
|
||||
Path savedPath = dir.resolve(newFileName).toAbsolutePath().normalize();
|
||||
|
||||
try {
|
||||
saveFile(dir, file, newFileName);
|
||||
return savedPath;
|
||||
} catch (IOException e) {
|
||||
throw BusinessException.internalError("FAIL_LIST_UPLOAD", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public Path saveAsyncListFile(MultipartFile file, Long projectId) {
|
||||
if (file == null || file.isEmpty()) {
|
||||
throw BusinessException.badRequest("EMPTY_FILE", "업로드할 파일이 없습니다.");
|
||||
@@ -95,33 +81,6 @@ public class ListFileService extends AbstractFileService {
|
||||
});
|
||||
}
|
||||
|
||||
public Path renameFailedListFile(Long prjctIdx, Path sourceFilePath) {
|
||||
String failPrefix = "uploadfail_";
|
||||
Path dir = getBaseDir().resolve(prjctIdx.toString()).toAbsolutePath().normalize();
|
||||
Path source = sourceFilePath.toAbsolutePath().normalize();
|
||||
|
||||
if (!source.startsWith(dir)) {
|
||||
throw BusinessException.badRequest("WRONG_FILE_PATH", "Wrong file path.");
|
||||
}
|
||||
|
||||
String sourceFileName = source.getFileName().toString();
|
||||
if (sourceFileName.startsWith(failPrefix)) {
|
||||
return source;
|
||||
}
|
||||
|
||||
Path target = dir.resolve(failPrefix + sourceFileName).toAbsolutePath().normalize();
|
||||
if (!target.startsWith(dir)) {
|
||||
throw BusinessException.badRequest("WRONG_FILE_PATH", "Wrong file path.");
|
||||
}
|
||||
|
||||
try {
|
||||
Files.move(source, target, StandardCopyOption.REPLACE_EXISTING);
|
||||
return target;
|
||||
} catch (IOException e) {
|
||||
throw BusinessException.internalError("FAIL_RENAME_LIST_UPLOAD_FILE", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] readListFile(Long prjctIdx, String fileName) {
|
||||
Path dir = getBaseDir().resolve(prjctIdx.toString()).toAbsolutePath().normalize();
|
||||
Path filePath = dir.resolve(fileName).toAbsolutePath().normalize();
|
||||
|
||||
Reference in New Issue
Block a user