Skip to content

Commit

Permalink
v2.3.1 (#722)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sangwook02 authored Aug 30, 2024
2 parents a40d6cd + a3b3312 commit a3ad36d
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,4 @@ public abstract class BaseSemesterEntity extends BaseEntity {

@Enumerated(EnumType.STRING)
private SemesterType semesterType;

protected void updateAcademicYear(Integer academicYear) {
this.academicYear = academicYear;
}

protected void updateSemesterType(SemesterType semesterType) {
this.semesterType = semesterType;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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로 변경된 경우 해당 메서드 제거 및 대체
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@
import java.math.BigDecimal;

public record RecruitmentRoundFullDto(
Long recruitmentId, String name, Period period, BigDecimal fee, RoundType roundType, String roundTypeValue) {
Long recruitmentId,
String name,
Period period,
String feeName,
BigDecimal fee,
RoundType roundType,
String roundTypeValue) {
public static RecruitmentRoundFullDto from(RecruitmentRound recruitmentRound) {
return new RecruitmentRoundFullDto(
recruitmentRound.getId(),
recruitmentRound.getName(),
recruitmentRound.getPeriod(),
recruitmentRound.getRecruitment().getFeeName(),
recruitmentRound.getRecruitment().getFee().getAmount(),
recruitmentRound.getRoundType(),
recruitmentRound.getRoundType().getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}$";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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());
Expand All @@ -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;
}
Expand Down Expand Up @@ -107,4 +114,23 @@ public LocalTime deserialize(JsonParser jsonParser, DeserializationContext deser
return LocalTime.of(hour, minute, second, nano);
}
}

public class ZonedDateTimeSerializer extends JsonSerializer<ZonedDateTime> {
@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<ZonedDateTime> {
@Override
public ZonedDateTime deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
throws IOException {
return ZonedDateTime.parse(
jsonParser.getValueAsString(),
DateTimeFormatter.ofPattern(ZONED_DATETIME).withZone(ZoneId.of("Asia/Seoul")));
}
}
}

0 comments on commit a3ad36d

Please sign in to comment.