PetPlantResponse의 dDay 필드에 대한 문제점 #165
-
사건의 발단@Getter
@Builder
@NoArgsConstructor(access = AccessLevel.PRIVATE)
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public class PetPlantResponse {
private Long id;
private String nickname;
private String imageUrl;
private String location;
private String flowerpot;
private String light;
private String wind;
private Integer waterCycle;
private Long daySince;
private Long dDay;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate birthDate;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate lastWaterDate;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate nextWaterDate;
private DictionaryPlantResponse dictionaryPlant;
@Getter
@NoArgsConstructor
public static class DictionaryPlantResponse {
private Long id;
private String name;
@Builder
private DictionaryPlantResponse(Long id, String name) {
this.id = id;
this.name = name;
}
}
} 위 객체에서 lombok이 dDay 필드에 대한 Getter를 생성하면서 한가지 문제가 발생했습니다. ![]() lombok은 위와같이 객체를 json 형태로 직렬화하는 과정에서 jackson의 objectMapper는 getter를 참조하여 json을 구성합니다. ![]() 결과는 기대했던 형태의 이 때문에 테스트를 수행하기 위해 객체를 역직렬화 하는 과정에서 json의 ![]() 제안위와 같은 문제상황에서 다음과 같은 해결방안들이 존재합니다.
![]() ![]() 개인적으로는 가장 변경소요가 적은
이에 대한 의견 부탁드립니다 |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 2 replies
-
프론트 분들을 위한 간단 요약백엔드의 구현 및 테스트 과정에서 일부 이슈가 존재해 API 명세에서 필드명을 변경해야하는 상황이 생겼습니다. 영향을 받는 API
{
"data": [
{
"petPlantId": 1,
"image": "image.com",
"nickName": "참새나무",
"dictionaryPlantName": "알로카시아",
"dDay": 3, // 음수면 할일 | 0이면 오늘 | 양수면 지각
"nextWaterDate": "2023-07-07",
},
{
"petPlantId": 2,
"image": "image.com",
"nickName": "그레이나무",
"dictionaryPlantName": "스투키",
"dDay": 3, // 음수면 할일 | 0이면 오늘 | 양수면 지각
"nextWaterDate": "2023-07-16"
}
]
} |
Beta Was this translation helpful? Give feedback.
-
크게 수정할 요소도 없고 |
Beta Was this translation helpful? Give feedback.
-
저도 필드명을 다른 이름으로 변경하거나, |
Beta Was this translation helpful? Give feedback.
-
dday로 가시죠 |
Beta Was this translation helpful? Give feedback.
-
dDay -> dday로 변경하는것으로 결론짓겠습니다! 추가로 {
"data": [
{
"petPlantId": 1,
"image": "image.com",
"nickName": "참새나무",
"dictionaryPlantName": "알로카시아",
"dday": 3, // 음수면 할일 | 0이면 오늘 | 양수면 지각
"nextWaterDate": "2023-07-07",
},
{
"petPlantId": 2,
"image": "image.com",
"nickName": "그레이나무",
"dictionaryPlantName": "스투키",
"dday": 3, // 음수면 할일 | 0이면 오늘 | 양수면 지각
"nextWaterDate": "2023-07-16"
}
]
} |
Beta Was this translation helpful? Give feedback.
dday로 가시죠