Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: (#757) Jackson 생성자 지정 #758

Merged
merged 2 commits into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import team.aliens.dms.domain.outing.spi.QueryOutingTypePort
import team.aliens.dms.domain.outing.spi.vo.CurrentOutingApplicationVO
import team.aliens.dms.domain.outing.spi.vo.OutingCompanionDetailsVO
import team.aliens.dms.domain.outing.spi.vo.OutingHistoryVO

import java.time.DayOfWeek
import java.time.LocalDate
import java.util.UUID
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package team.aliens.dms.domain.student.dto

import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
import com.fasterxml.jackson.annotation.JsonProperty
import team.aliens.dms.domain.manager.spi.vo.StudentWithTag
import team.aliens.dms.domain.student.model.Sex
import team.aliens.dms.domain.student.model.Student
Expand Down Expand Up @@ -46,17 +49,17 @@ data class StudentNameResponse(
val name: String
)

data class StudentDetailsResponse(
Copy link
Member

Choose a reason for hiding this comment

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

@4mjeo 궁금한 부분이 있는데

  1. 역직렬화시에 기본생성자가 필요한 경우가 StudentDetailsResponse 밖에 없었던건가요?
  2. 그리고 기본생성자가 없는게 문제라면 이 글처럼 필드 기본값을 넣어주거나, 기본생성자를 직접 정의하는 방법이 더 깔끔할 것 같은데 @JsonCreator를 사용하신 이유가 따로 있나요?

val id: UUID,
val name: String,
val gcn: String,
val profileImageUrl: String,
val sex: Sex? = null,
val bonusPoint: Int? = null,
val minusPoint: Int? = null,
val roomNumber: String? = null,
val roomMates: List<RoomMate>? = null,
val tags: List<TagResponse>? = null
data class StudentDetailsResponse @JsonCreator constructor(
@JsonProperty("id") val id: UUID,
@JsonProperty("name") val name: String,
@JsonProperty("gcn") val gcn: String,
@JsonProperty("profileImageUrl") val profileImageUrl: String,
@JsonProperty("sex") val sex: Sex? = null,
@JsonProperty("bonusPoint") val bonusPoint: Int? = null,
@JsonProperty("minusPoint") val minusPoint: Int? = null,
@JsonProperty("roomNumber") val roomNumber: String? = null,
@JsonProperty("roomMates") val roomMates: List<RoomMate>? = null,
@JsonProperty("tags") val tags: List<TagResponse>? = null
) {
data class RoomMate(
val id: UUID,
Expand Down
Loading