|
| 1 | +package boombimapi.domain.congestion.domain.entity; |
| 2 | + |
| 3 | +import boombimapi.domain.place.domain.entity.OfficialPlace; |
| 4 | +import jakarta.persistence.Column; |
| 5 | +import jakarta.persistence.Entity; |
| 6 | +import jakarta.persistence.FetchType; |
| 7 | +import jakarta.persistence.GeneratedValue; |
| 8 | +import jakarta.persistence.GenerationType; |
| 9 | +import jakarta.persistence.Id; |
| 10 | +import jakarta.persistence.JoinColumn; |
| 11 | +import jakarta.persistence.ManyToOne; |
| 12 | +import jakarta.persistence.Table; |
| 13 | +import java.time.LocalDateTime; |
| 14 | +import lombok.AccessLevel; |
| 15 | +import lombok.Builder; |
| 16 | +import lombok.Getter; |
| 17 | +import lombok.NoArgsConstructor; |
| 18 | + |
| 19 | +@Entity |
| 20 | +@Getter |
| 21 | +@Table(name = "official_congestion_forecasts") |
| 22 | +@NoArgsConstructor(access = AccessLevel.PROTECTED) |
| 23 | +public class OfficialCongestionForecast { |
| 24 | + |
| 25 | + @Id |
| 26 | + @GeneratedValue(strategy = GenerationType.IDENTITY) |
| 27 | + private Long id; |
| 28 | + |
| 29 | + @ManyToOne(fetch = FetchType.LAZY) |
| 30 | + @JoinColumn(name = "official_place_id", nullable = false) |
| 31 | + private OfficialPlace officialPlace; |
| 32 | + |
| 33 | + @Column(name = "observed_at", nullable = false) |
| 34 | + private LocalDateTime observedAt; |
| 35 | + |
| 36 | + @Column(name = "forecast_time", nullable = false) |
| 37 | + private LocalDateTime forecastTime; |
| 38 | + |
| 39 | + @ManyToOne(fetch = FetchType.LAZY) |
| 40 | + @JoinColumn(name = "forecast_congestion_level_id", nullable = false) |
| 41 | + private CongestionLevel forecastCongestionLevel; |
| 42 | + |
| 43 | + @Column(name = "forecast_population_min") |
| 44 | + private Long forecastPopulationMin; |
| 45 | + |
| 46 | + @Column(name = "forecast_population_max") |
| 47 | + private Long forecastPopulationMax; |
| 48 | + |
| 49 | + @Builder |
| 50 | + private OfficialCongestionForecast( |
| 51 | + OfficialPlace officialPlace, |
| 52 | + LocalDateTime observedAt, |
| 53 | + LocalDateTime forecastTime, |
| 54 | + CongestionLevel forecastCongestionLevel, |
| 55 | + Long forecastPopulationMin, |
| 56 | + Long forecastPopulationMax |
| 57 | + ) { |
| 58 | + this.officialPlace = officialPlace; |
| 59 | + this.observedAt = observedAt; |
| 60 | + this.forecastTime = forecastTime; |
| 61 | + this.forecastCongestionLevel = forecastCongestionLevel; |
| 62 | + this.forecastPopulationMin = forecastPopulationMin; |
| 63 | + this.forecastPopulationMax = forecastPopulationMax; |
| 64 | + } |
| 65 | + |
| 66 | + public static OfficialCongestionForecast of( |
| 67 | + OfficialPlace officialPlace, |
| 68 | + LocalDateTime observedAt, |
| 69 | + LocalDateTime forecastTime, |
| 70 | + CongestionLevel forecastCongestionLevel, |
| 71 | + Long forecastPopulationMin, |
| 72 | + Long forecastPopulationMax |
| 73 | + ) { |
| 74 | + return OfficialCongestionForecast.builder() |
| 75 | + .officialPlace(officialPlace) |
| 76 | + .observedAt(observedAt) |
| 77 | + .forecastTime(forecastTime) |
| 78 | + .forecastCongestionLevel(forecastCongestionLevel) |
| 79 | + .forecastPopulationMin(forecastPopulationMin) |
| 80 | + .forecastPopulationMax(forecastPopulationMax) |
| 81 | + .build(); |
| 82 | + } |
| 83 | + |
| 84 | +} |
0 commit comments