Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/main/java/com/project/core/util/BatchTriggerClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import com.project.core.controller.dto.request.BatchTriggerRequest;
import com.project.core.controller.dto.request.UpdateBatchScheduleRequest;
import com.project.core.infra.entity.batch.BatchJobType;
import com.project.global.config.CloudFunctionProperties;
import com.project.global.exception.code.domain.core.CoreErrorCode;
import com.project.global.exception.core.OperationFailedException;
Expand All @@ -27,13 +28,14 @@ public class BatchTriggerClient {

public void trigger(String job, String invMonth) {

String title = BatchJobType.getTitleByJobName(job);
Comment on lines 29 to +31
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

잡 이름 변환 로직이 추가되면서 job 파라미터는 이제 jobName을 나타냅니다. 명확성을 위해 파라미터 이름을 jobName으로 변경하는 것을 고려해 보세요. 이렇게 하면 코드의 가독성이 향상됩니다.

Suggested change
public void trigger(String job, String invMonth) {
String title = BatchJobType.getTitleByJobName(job);
public void trigger(String jobName, String invMonth) {
String title = BatchJobType.getTitleByJobName(jobName);

String url = properties.getBaseUrl() + "/run-now";
log.info("[BatchTrigger] calling url={}", url);

HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);

BatchTriggerRequest body = new BatchTriggerRequest(job, invMonth);
BatchTriggerRequest body = new BatchTriggerRequest(title, invMonth);

HttpEntity<BatchTriggerRequest> request = new HttpEntity<>(body, headers);

Expand All @@ -49,12 +51,13 @@ public void trigger(String job, String invMonth) {

public void schedule(String job, String cron) {

String title = BatchJobType.getTitleByJobName(job);
Comment on lines 52 to +54
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

여기에서도 job 파라미터 이름을 jobName으로 변경하여 일관성과 명확성을 유지하는 것이 좋습니다. 또한, trigger 메소드와 schedule 메소드에 중복되는 BatchJobType.getTitleByJobName 호출 로직을 별도의 private 헬퍼 메소드로 추출하여 코드 중복을 줄이는 것을 고려해 보세요. 예를 들어:

private String getJobTitle(String jobName) {
    return BatchJobType.getTitleByJobName(jobName);
}
Suggested change
public void schedule(String job, String cron) {
String title = BatchJobType.getTitleByJobName(job);
public void schedule(String jobName, String cron) {
String title = BatchJobType.getTitleByJobName(jobName);

String url = properties.getBaseUrl() + "/schedule";

HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);

UpdateBatchScheduleRequest body = new UpdateBatchScheduleRequest(job, cron);
UpdateBatchScheduleRequest body = new UpdateBatchScheduleRequest(title, cron);

HttpEntity<UpdateBatchScheduleRequest> request = new HttpEntity<>(body, headers);

Expand Down