From 8beef1e548bbdb1752e6d53d22225c5eb356d5df Mon Sep 17 00:00:00 2001 From: lulz1 Date: Wed, 24 Apr 2024 14:51:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=85=AC=E5=91=8A=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/chint/application/system/SystemController.java | 2 +- .../com/chint/domain/service/leg_event/LegEventHandler.java | 5 ++++- .../repository/SystemAnnouncementRepositoryImpl.java | 4 ++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/chint/application/system/SystemController.java b/src/main/java/com/chint/application/system/SystemController.java index e6163acb..3c818a1b 100644 --- a/src/main/java/com/chint/application/system/SystemController.java +++ b/src/main/java/com/chint/application/system/SystemController.java @@ -37,7 +37,7 @@ public class SystemController { } @ApiOperation("新增已查看用户") - @PostMapping("/announcement/save") + @PostMapping("/announcement/employee/save") public Result saveAnnouncementEmployee(@RequestBody SystemAnnouncementDTO systemAnnouncementDTO) { systemAnnouncementRepository.findById(systemAnnouncementDTO.getAnnouncementId()) .ifPresent(systemAnnouncement -> { diff --git a/src/main/java/com/chint/domain/service/leg_event/LegEventHandler.java b/src/main/java/com/chint/domain/service/leg_event/LegEventHandler.java index eb572f38..dba55087 100644 --- a/src/main/java/com/chint/domain/service/leg_event/LegEventHandler.java +++ b/src/main/java/com/chint/domain/service/leg_event/LegEventHandler.java @@ -41,6 +41,7 @@ import java.util.Optional; import static com.chint.infrastructure.constant.BPMConstant.*; import static com.chint.infrastructure.constant.CommonMessageConstant.LEG_CHANGE_MAX_ERROR; +import static com.chint.infrastructure.constant.CommonMessageConstant.NOT_FOUND; import static com.chint.infrastructure.constant.DataMessageConstant.DATA_NOT_FOUND; import static com.chint.infrastructure.constant.LegConstant.*; import static com.chint.infrastructure.constant.OrderConstant.*; @@ -205,7 +206,9 @@ public class LegEventHandler implements LegEventService { OrderLegData data = command.getData(); String orderNo = data.getSelfOrderNo(); RouteOrder routeOrder = routeRequestDomainService.getRouteOrder(orderNo); - + if(routeOrder == null){ + throw new OrderException(NOT_FOUND + ",单号:orderNo"); + } String employeeNo = routeOrder.getUserId(); User byUserEmployeeNo = userRepository.findByUserEmployeeNo(employeeNo); BaseContext.setCurrentUser(byUserEmployeeNo); diff --git a/src/main/java/com/chint/infrastructure/repository/SystemAnnouncementRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/SystemAnnouncementRepositoryImpl.java index 2fc58010..d54117f3 100644 --- a/src/main/java/com/chint/infrastructure/repository/SystemAnnouncementRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/SystemAnnouncementRepositoryImpl.java @@ -4,6 +4,8 @@ import com.chint.domain.aggregates.system.SystemAnnouncement; import com.chint.domain.repository.SystemAnnouncementRepository; import com.chint.infrastructure.repository.jdbc.JdbcSystemAnnouncementRepository; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Repository; import java.util.ArrayList; @@ -17,11 +19,13 @@ public class SystemAnnouncementRepositoryImpl implements SystemAnnouncementRepos @Autowired private JdbcSystemAnnouncementRepository jdbcSystemAnnouncementRepository; + @CacheEvict(value = "SystemAnnouncement", key = "#systemAnnouncement.announcementId") @Override public SystemAnnouncement save(SystemAnnouncement systemAnnouncement) { return jdbcSystemAnnouncementRepository.save(systemAnnouncement); } + @Cacheable(value = "SystemAnnouncement", key = "#id") @Override public Optional findById(Long id) { return jdbcSystemAnnouncementRepository.findById(id);