Skip to content

Commit 6569c9d

Browse files
committed
CLAP-257 Fix : 순환 의존성(circular dependency) 문제 해결
1 parent 507559f commit 6569c9d

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

src/main/java/clap/server/adapter/outbound/api/AgitClient.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@
22

33
import clap.server.adapter.outbound.api.dto.PushNotificationTemplate;
44
import clap.server.adapter.outbound.persistense.entity.notification.constant.NotificationType;
5+
import clap.server.application.port.inbound.domain.TaskService;
56
import clap.server.application.port.outbound.webhook.SendAgitPort;
67
import clap.server.application.service.task.UpdateTaskService;
78
import clap.server.common.annotation.architecture.ExternalApiAdapter;
89
import clap.server.domain.model.task.Task;
10+
import clap.server.exception.ApplicationException;
11+
import clap.server.exception.code.NotificationErrorCode;
12+
import com.fasterxml.jackson.core.JsonProcessingException;
13+
import com.fasterxml.jackson.databind.JsonNode;
14+
import com.fasterxml.jackson.databind.ObjectMapper;
915
import lombok.RequiredArgsConstructor;
1016
import org.springframework.beans.factory.annotation.Value;
1117
import org.springframework.http.HttpEntity;
@@ -21,8 +27,9 @@ public class AgitClient implements SendAgitPort {
2127
@Value("${webhook.agit.url}")
2228
private String AGIT_WEBHOOK_URL;
2329

24-
private final UpdateTaskService updateTaskService;
2530
private final AgitTemplateBuilder agitTemplateBuilder;
31+
private final ObjectMapper objectMapper;
32+
private final TaskService taskService;
2633

2734
@Override
2835
public void sendAgit(PushNotificationTemplate request, Task task) {
@@ -33,10 +40,20 @@ public void sendAgit(PushNotificationTemplate request, Task task) {
3340
if (request.notificationType() == NotificationType.TASK_REQUESTED) {
3441
ResponseEntity<String> responseEntity = restTemplate.exchange(
3542
AGIT_WEBHOOK_URL, HttpMethod.POST, entity, String.class);
36-
updateTaskService.updateAgitPostId(responseEntity, task);
43+
updateAgitPostId(responseEntity, task);
3744
}
3845
else {
3946
restTemplate.exchange(AGIT_WEBHOOK_URL, HttpMethod.POST, entity, String.class);
4047
}
4148
}
49+
50+
private void updateAgitPostId(ResponseEntity<String> responseEntity, Task task) {
51+
try {
52+
JsonNode jsonNode = objectMapper.readTree(responseEntity.getBody());
53+
task.updateAgitPostId(jsonNode.get("id").asLong());
54+
taskService.upsert(task);
55+
} catch (JsonProcessingException e) {
56+
throw new ApplicationException(NotificationErrorCode.AGIT_SEND_FAILED);
57+
}
58+
}
4259
}

src/main/java/clap/server/application/service/task/UpdateTaskService.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,16 +124,6 @@ public UpdateTaskResponse updateTaskLabel(Long taskId, Long userId, UpdateTaskLa
124124
return TaskResponseMapper.toUpdateTaskResponse(updatetask);
125125
}
126126

127-
public void updateAgitPostId(ResponseEntity<String> responseEntity, Task task) {
128-
try {
129-
JsonNode jsonNode = objectMapper.readTree(responseEntity.getBody());
130-
task.updateAgitPostId(jsonNode.get("id").asLong());
131-
taskService.upsert(task);
132-
} catch (JsonProcessingException e) {
133-
throw new ApplicationException(NotificationErrorCode.AGIT_SEND_FAILED);
134-
}
135-
}
136-
137127
private void updateAttachments(List<Long> attachmentIdsToDelete, List<MultipartFile> files, Task task) {
138128
List<Attachment> attachmentsToDelete = validateAndGetAttachments(attachmentIdsToDelete, task);
139129
attachmentsToDelete.forEach(Attachment::softDelete);

0 commit comments

Comments
 (0)