Skip to content

Commit

Permalink
feat: enum 컨버터 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
drunkenhw committed Aug 7, 2023
1 parent 059af7a commit f181d2d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.carffeine.carffeine.station.config;

import com.carffeine.carffeine.station.domain.congestion.RequestPeriod;

import javax.persistence.AttributeConverter;

public class RequestPeriodConverter implements AttributeConverter<RequestPeriod, Integer> {

@Override
public Integer convertToDatabaseColumn(RequestPeriod attribute) {
return attribute.getSection();
}

@Override
public RequestPeriod convertToEntityAttribute(Integer dbData) {
return RequestPeriod.from(dbData);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.carffeine.carffeine.station.domain.congestion;

import com.carffeine.carffeine.station.config.RequestPeriodConverter;
import com.carffeine.carffeine.station.domain.charger.Charger;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
Expand All @@ -8,6 +9,7 @@

import javax.persistence.Column;
import javax.persistence.ConstraintMode;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
Expand All @@ -31,6 +33,7 @@ public class PeriodicCongestion {

@Enumerated(EnumType.STRING)
private DayOfWeek dayOfWeek;
@Convert(converter = RequestPeriodConverter.class)
private RequestPeriod startTime;
private int useCount;
private int totalCount;
Expand Down

0 comments on commit f181d2d

Please sign in to comment.