Skip to content

Commit

Permalink
Modify Datetime Response Form
Browse files Browse the repository at this point in the history
  • Loading branch information
K-Diger committed Dec 20, 2023
1 parent 67f0fec commit 4bf2444
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.whatever.raisedragon.config

import com.fasterxml.jackson.databind.DeserializationFeature
import com.fasterxml.jackson.databind.SerializationFeature
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer
import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.LocalTime
import java.time.format.DateTimeFormatter

@Configuration
class JacksonConfig {
@Bean
fun jackson2ObjectMapperBuilder(): Jackson2ObjectMapperBuilder {
return Jackson2ObjectMapperBuilder()
.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.featuresToDisable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
.serializerByType(LocalDateTime::class.java, LocalDateTimeSerializer(DateTimeFormatter.ISO_LOCAL_DATE_TIME))
.serializerByType(LocalDate::class.java, LocalDateSerializer(DateTimeFormatter.ISO_LOCAL_DATE))
.serializerByType(LocalTime::class.java, LocalTimeSerializer(DateTimeFormatter.ISO_LOCAL_TIME))
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.whatever.raisedragon.controller.goal

import com.fasterxml.jackson.annotation.JsonFormat
import com.whatever.raisedragon.domain.betting.PredictionType
import com.whatever.raisedragon.domain.betting.Result
import com.whatever.raisedragon.domain.goal.BettingType
Expand Down Expand Up @@ -62,11 +61,9 @@ data class GoalResponse(
@Schema(description = "다짐 인증 횟수")
val threshold: Threshold,

@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss")
@Schema(description = "다짐 시작 시간")
val startDate: LocalDateTime,

@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss")
@Schema(description = "다짐 마감 시간")
val endDate: LocalDateTime
) {
Expand All @@ -90,7 +87,6 @@ data class GoalBettingHost(
@Schema(description = "호스트 유저 닉네임")
val nickname: String,

@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss")
@Schema(description = "다짐 생성 시각")
val goalCreatedAt: LocalDateTime,
)
Expand All @@ -111,7 +107,6 @@ data class GoalBettingParticipant(
@Schema(description = "당첨 여부")
val result: Result,

@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss")
@Schema(description = "배팅 한 시각")
val bettingCreatedAt: LocalDateTime,
)
Expand Down

0 comments on commit 4bf2444

Please sign in to comment.