Merge pull request '261112_01_CLN: 미사용 통화 이력 세션 조회·사용자 종료 API 및 관련 코드 정리' (#46) from develop into master
Reviewed-on: #46
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user