From 615e81968ca0082abd3211787b3b79bddce984fe Mon Sep 17 00:00:00 2001 From: lulz1 Date: Thu, 1 Feb 2024 17:20:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=AC=AC=E4=B8=89=E6=96=B9?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/aggregates/order/LegEvent.java | 4 +++ .../domain/repository/LegRepository.java | 7 ++-- .../repository/LegEventRepositoryImpl.java | 32 +++++++++++++++++++ .../jdbc/JdbcLegEventRepository.java | 14 ++++++++ .../repository/jdbc/JdbcLegRepository.java | 13 ++++++++ 5 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/chint/infrastructure/repository/LegEventRepositoryImpl.java create mode 100644 src/main/java/com/chint/infrastructure/repository/jdbc/JdbcLegEventRepository.java create mode 100644 src/main/java/com/chint/infrastructure/repository/jdbc/JdbcLegRepository.java 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); +}