diff --git a/src/main/java/com/gdschongik/gdsc/domain/order/dao/OrderQueryMethod.java b/src/main/java/com/gdschongik/gdsc/domain/order/dao/OrderQueryMethod.java index 0af33f5fd..05867f038 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/order/dao/OrderQueryMethod.java +++ b/src/main/java/com/gdschongik/gdsc/domain/order/dao/OrderQueryMethod.java @@ -30,7 +30,7 @@ default BooleanExpression eqMember() { } default BooleanExpression eqRecruitmentRound() { - return order.recruitmentRoundId.eq(recruitment.id); + return order.recruitmentRoundId.eq(recruitmentRound.id); } // TODO: MemberQueryMethod가 interface로 변경된 경우 해당 메서드 제거 및 대체 diff --git a/src/main/java/com/gdschongik/gdsc/global/common/constant/RegexConstant.java b/src/main/java/com/gdschongik/gdsc/global/common/constant/RegexConstant.java index afc38dc0b..d2bf20ab0 100644 --- a/src/main/java/com/gdschongik/gdsc/global/common/constant/RegexConstant.java +++ b/src/main/java/com/gdschongik/gdsc/global/common/constant/RegexConstant.java @@ -9,6 +9,7 @@ public class RegexConstant { public static final String DEPARTMENT = "^D[0-9]{3}$"; public static final String HONGIK_EMAIL = "^[^\\W&=+'-+,<>]+(\\.[^\\W&=+'-+,<>]+)*@g\\.hongik\\.ac\\.kr$"; public static final String DATETIME = "yyyy-MM-dd'T'HH:mm:ss"; + public static final String ZONED_DATETIME = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX"; public static final String DATE = "yyyy-MM-dd"; public static final String ACADEMIC_YEAR = "^[0-9]{4}$"; diff --git a/src/main/java/com/gdschongik/gdsc/global/config/ObjectMapperConfig.java b/src/main/java/com/gdschongik/gdsc/global/config/ObjectMapperConfig.java index ce69b3e8a..b4aae9ed9 100644 --- a/src/main/java/com/gdschongik/gdsc/global/config/ObjectMapperConfig.java +++ b/src/main/java/com/gdschongik/gdsc/global/config/ObjectMapperConfig.java @@ -2,6 +2,7 @@ import static com.gdschongik.gdsc.global.common.constant.RegexConstant.DATE; import static com.gdschongik.gdsc.global.common.constant.RegexConstant.DATETIME; +import static com.gdschongik.gdsc.global.common.constant.RegexConstant.ZONED_DATETIME; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser; @@ -11,11 +12,13 @@ import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.module.SimpleModule; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import java.io.IOException; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -25,7 +28,7 @@ public class ObjectMapperConfig { @Bean public ObjectMapper objectMapper() { ObjectMapper mapper = new ObjectMapper(); - SimpleModule module = new SimpleModule(); + JavaTimeModule module = new JavaTimeModule(); // LocalDate module.addSerializer(LocalDate.class, new LocalDateSerializer()); @@ -39,6 +42,10 @@ public ObjectMapper objectMapper() { module.addSerializer(LocalTime.class, new LocalTimeSerializer()); module.addDeserializer(LocalTime.class, new LocalTimeDeserializer()); + // ZonedDateTime + module.addSerializer(ZonedDateTime.class, new ZonedDateTimeSerializer()); + module.addDeserializer(ZonedDateTime.class, new ZonedDateTimeDeserializer()); + mapper.registerModule(module); return mapper; } @@ -107,4 +114,23 @@ public LocalTime deserialize(JsonParser jsonParser, DeserializationContext deser return LocalTime.of(hour, minute, second, nano); } } + + public class ZonedDateTimeSerializer extends JsonSerializer { + @Override + public void serialize(ZonedDateTime value, JsonGenerator generator, SerializerProvider serializers) + throws IOException { + generator.writeString( + value.format(DateTimeFormatter.ofPattern(DATETIME).withZone(ZoneId.of("Asia/Seoul")))); + } + } + + public class ZonedDateTimeDeserializer extends JsonDeserializer { + @Override + public ZonedDateTime deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) + throws IOException { + return ZonedDateTime.parse( + jsonParser.getValueAsString(), + DateTimeFormatter.ofPattern(ZONED_DATETIME).withZone(ZoneId.of("Asia/Seoul"))); + } + } }