Skip to content

Commit 650f22c

Browse files
committed
fix: 날짜 형식 제한 삭제.dto에서 자동 초단위로 절삭
1 parent a57751f commit 650f22c

File tree

3 files changed

+20
-24
lines changed

3 files changed

+20
-24
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/StudyPlanRequest.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,41 @@
1010
import lombok.Setter;
1111

1212
import java.time.LocalDateTime;
13+
import java.time.temporal.ChronoUnit;
1314
import java.util.ArrayList;
1415
import java.util.List;
1516

1617
@Getter
1718
@Setter
1819
@NoArgsConstructor
19-
@AllArgsConstructor
2020
public class StudyPlanRequest {
2121
private String subject;
2222

23-
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss")
2423
private LocalDateTime startDate;
2524

26-
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss")
2725
private LocalDateTime endDate;
2826

2927
private Color color;
3028

3129
// RepeatRule 중첩 객체
3230
private RepeatRuleRequest repeatRule;
31+
// LocalDateTime을 초 단위로 자르기 위한 setter
32+
public void setStartDate(LocalDateTime startDate) {
33+
this.startDate = startDate != null ? startDate.truncatedTo(ChronoUnit.SECONDS) : null;
34+
}
35+
public void setEndDate(LocalDateTime endDate) {
36+
this.endDate = endDate != null ? endDate.truncatedTo(ChronoUnit.SECONDS) : null;
37+
}
38+
39+
// 초 단위로 자른 값을 생성자에서도 설정
40+
public StudyPlanRequest(String subject, LocalDateTime startDate, LocalDateTime endDate,
41+
Color color, RepeatRuleRequest repeatRule) {
42+
this.subject = subject;
43+
this.startDate = startDate != null ? startDate.truncatedTo(ChronoUnit.SECONDS) : null;
44+
this.endDate = endDate != null ? endDate.truncatedTo(ChronoUnit.SECONDS) : null;
45+
this.color = color;
46+
this.repeatRule = repeatRule;
47+
}
3348

3449
@Getter
3550
@Setter

src/main/java/com/back/global/exception/GlobalExceptionHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ public ResponseEntity<RsData<Void>> handleValidationException(MethodArgumentNotV
3434
.body(RsData.fail(ErrorCode.BAD_REQUEST));
3535
}
3636

37-
// PATH VARIABLE, REQUEST PARAMETER 타입 미스매치 예외 처리
38-
// 클라이언트의 데이터 형식이 서버 인자 타입과 안 맞는 경우 예외 (형식 불일치)
37+
// PATH VARIABLE, REQUEST PARAMETER의 validation 예외 처리
38+
// 클라이언트의 데이터 형식이 서버 인자 형식과 안 맞는 경우 예외 (형식 불일치)
3939
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
4040
@ResponseStatus(HttpStatus.BAD_REQUEST)
4141
public ResponseEntity<RsData<Void>> handleMethodArgumentTypeMismatch(MethodArgumentTypeMismatchException ex) {

0 commit comments

Comments
 (0)