diff --git a/src/main/java/com/chint/domain/aggregates/order/LegEvent.java b/src/main/java/com/chint/domain/aggregates/order/LegEvent.java index ca7d7d8c..14d5a6d8 100644 --- a/src/main/java/com/chint/domain/aggregates/order/LegEvent.java +++ b/src/main/java/com/chint/domain/aggregates/order/LegEvent.java @@ -2,11 +2,15 @@ package com.chint.domain.aggregates.order; import com.chint.domain.aggregates.base.BaseEntity; import lombok.Data; +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.Table; import static com.chint.infrastructure.constant.Constant.*; @Data +@Table("leg_event") public class LegEvent extends BaseEntity { + @Id private Long legEventId; private Long legId; diff --git a/src/main/java/com/chint/domain/repository/LegRepository.java b/src/main/java/com/chint/domain/repository/LegRepository.java index caa3fa24..c8d96478 100644 --- a/src/main/java/com/chint/domain/repository/LegRepository.java +++ b/src/main/java/com/chint/domain/repository/LegRepository.java @@ -6,8 +6,11 @@ import com.chint.domain.aggregates.order.RouteOrder; import java.util.List; public interface LegRepository { - Leg save(Leg bookingItem); + Leg save(Leg leg); + void deleteById(Long id); + List findByOrder(RouteOrder order); - void saveAll(List bookingItems); + + void saveAll(List legs); } \ No newline at end of file diff --git a/src/main/java/com/chint/infrastructure/repository/LegEventRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/LegEventRepositoryImpl.java new file mode 100644 index 00000000..355e9c4b --- /dev/null +++ b/src/main/java/com/chint/infrastructure/repository/LegEventRepositoryImpl.java @@ -0,0 +1,32 @@ +package com.chint.infrastructure.repository; + +import com.chint.domain.aggregates.order.Leg; +import com.chint.domain.aggregates.order.LegEvent; +import com.chint.domain.repository.LegEventRepository; +import com.chint.infrastructure.repository.jdbc.JdbcLegEventRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public class LegEventRepositoryImpl implements LegEventRepository { + + @Autowired + private JdbcLegEventRepository legEventRepository; + + @Override + public void deleteByLegId(Leg leg) { + legEventRepository.deleteByLegId(leg.getLegId()); + } + + @Override + public List findAllByLegId(Long legId) { + return legEventRepository.findByLegId(legId); + } + + @Override + public LegEvent save(LegEvent legEvent) { + return legEventRepository.save(legEvent); + } +} diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcLegEventRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcLegEventRepository.java new file mode 100644 index 00000000..b5138a90 --- /dev/null +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcLegEventRepository.java @@ -0,0 +1,14 @@ +package com.chint.infrastructure.repository.jdbc; + +import com.chint.domain.aggregates.order.LegEvent; +import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface JdbcLegEventRepository extends CrudRepository { + void deleteByLegId(Long legId); + + List findByLegId(Long legId); +} diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcLegRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcLegRepository.java new file mode 100644 index 00000000..bfaa9b2f --- /dev/null +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcLegRepository.java @@ -0,0 +1,13 @@ +package com.chint.infrastructure.repository.jdbc; + +import com.chint.domain.aggregates.order.Leg; +import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface JdbcLegRepository extends CrudRepository { + + List findByRouteId(Long routeId); +}