Skip to content

Commit b82957e

Browse files
KSH0326namgigun
authored andcommitted
Refactor: 변수명 분리 (#142) (#150)
* refact: 응답,요청 dto와 엔티티 변수명 분리(intervalValue) * 주석 추가 * fix: 변수명 누락 수정 * test: test 검증 변수명 수정
1 parent 3b954c2 commit b82957e

File tree

6 files changed

+14
-30
lines changed

6 files changed

+14
-30
lines changed

src/main/java/com/back/domain/study/plan/dto/StudyPlanDeleteRequest.java

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/main/java/com/back/domain/study/plan/dto/StudyPlanResponse.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,25 +42,26 @@ public class StudyPlanResponse {
4242
@AllArgsConstructor
4343
public static class RepeatRuleResponse {
4444
private Frequency frequency;
45-
private Integer repeatInterval;
45+
private Integer intervalValue;
4646
private List<DayOfWeek> byDay = new ArrayList<>(); // "MON" 형태의 enum 문자열 리스트
4747

4848
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
4949
private LocalDate untilDate;
5050

51-
// 엔티티 생성자: 그대로 유지
52-
51+
// RepeatRule 엔티티를 DTO로 변환하는 생성자
52+
// intervalValue의 경우 요청, 응답(프론트)에서는 intervalValue 사용
53+
// 백엔드 내에서는 repeatInterval 사용
5354
public RepeatRuleResponse(com.back.domain.study.plan.entity.RepeatRule repeatRule) {
5455
if (repeatRule != null) {
5556
this.frequency = repeatRule.getFrequency();
56-
this.repeatInterval = repeatRule.getRepeatInterval();
57+
this.intervalValue = repeatRule.getRepeatInterval();
5758
this.byDay = repeatRule.getByDay();
5859
this.untilDate = repeatRule.getUntilDate();
5960
}
6061
}
6162

6263
}
63-
//엔티티를 DTO로 변환하는 생성자
64+
// 엔티티를 DTO로 변환하는 생성자
6465
public StudyPlanResponse(StudyPlan studyPlan) {
6566
if (studyPlan != null) {
6667
this.id = studyPlan.getId();

src/main/java/com/back/domain/study/plan/entity/RepeatRuleEmbeddable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class RepeatRuleEmbeddable {
2121
@Enumerated(EnumType.STRING)
2222
private Frequency frequency;
2323

24-
private Integer intervalValue;
24+
private Integer repeatInterval;
2525
private List<DayOfWeek> byDay = new ArrayList<>();
2626
private LocalDate untilDate; // LocalDateTime → LocalDate 변경
2727
}

src/main/java/com/back/domain/study/plan/entity/StudyPlanException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public enum ExceptionType {
6161
@Column(name = "modified_repeat_rule")
6262
@AttributeOverrides({
6363
@AttributeOverride(name = "frequency", column = @Column(name = "modified_frequency")),
64-
@AttributeOverride(name = "intervalValue", column = @Column(name = "modified_repeat_interval")),
64+
@AttributeOverride(name = "repeatInterval", column = @Column(name = "modified_interval_value")),
6565
@AttributeOverride(name = "byDay", column = @Column(name = "modified_by_day")),
6666
@AttributeOverride(name = "untilDate", column = @Column(name = "modified_until_date"))
6767
})

src/main/java/com/back/domain/study/plan/service/StudyPlanService.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,9 @@ private boolean shouldRepeatOnDate(StudyPlan originalPlan, LocalDate targetDate)
197197

198198
case WEEKLY:
199199
if (repeatRule.getByDay() != null && !repeatRule.getByDay().isEmpty()) {
200-
String targetDayOfWeek = targetDate.getDayOfWeek().name().substring(0, 3);
200+
// string으로 요일을 뽑아낸 뒤 enum으로 변환.
201+
// 비교해서 포함되지 않으면 false
202+
DayOfWeek targetDayOfWeek = DayOfWeek.valueOf(targetDate.getDayOfWeek().name().substring(0, 3));
201203
if (!repeatRule.getByDay().contains(targetDayOfWeek)) {
202204
return false;
203205
}
@@ -259,7 +261,7 @@ private StudyPlanResponse createModifiedVirtualPlan(StudyPlan originalPlan, Stud
259261
RepeatRuleEmbeddable modifiedRule = exception.getModifiedRepeatRule();
260262
StudyPlanResponse.RepeatRuleResponse newRepeatRule = new StudyPlanResponse.RepeatRuleResponse();
261263
newRepeatRule.setFrequency(modifiedRule.getFrequency());
262-
newRepeatRule.setRepeatInterval(modifiedRule.getIntervalValue());
264+
newRepeatRule.setIntervalValue(modifiedRule.getRepeatInterval());
263265
newRepeatRule.setByDay(modifiedRule.getByDay());
264266
newRepeatRule.setUntilDate(modifiedRule.getUntilDate());
265267

@@ -468,7 +470,7 @@ private void updateRepeatRule(RepeatRule repeatRule, StudyPlanRequest.RepeatRule
468470
private RepeatRuleEmbeddable createRepeatRuleEmbeddable(StudyPlanRequest.RepeatRuleRequest request, LocalDateTime startDate) {
469471
RepeatRuleEmbeddable embeddable = new RepeatRuleEmbeddable();
470472
embeddable.setFrequency(request.getFrequency());
471-
embeddable.setIntervalValue(request.getIntervalValue());
473+
embeddable.setRepeatInterval(request.getIntervalValue());
472474

473475
// byDay 자동 설정 (오버로딩된 메서드 사용)
474476
getByDayInWeekly(request, startDate, embeddable);

src/test/java/com/back/domain/study/plan/controller/StudyPlanControllerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ void t2() throws Exception {
201201
.andExpect(jsonPath("$.data.startDate").value("2025-09-26T10:46:00"))
202202
.andExpect(jsonPath("$.data.endDate").value("2025-09-26T11:46:00"))
203203
.andExpect(jsonPath("$.data.repeatRule.frequency").value("DAILY"))
204-
.andExpect(jsonPath("$.data.repeatRule.repeatInterval").value(1))
204+
.andExpect(jsonPath("$.data.repeatRule.intervalValue").value(1))
205205
.andExpect(jsonPath("$.data.repeatRule.byDay", hasSize(0)))
206206
.andExpect(jsonPath("$.data.repeatRule.untilDate").value("2025-12-31"));
207207

0 commit comments

Comments
 (0)