From ad5fa17b4f6502c4f48fb725becf9a5a6e796ad8 Mon Sep 17 00:00:00 2001 From: xezzon Date: Mon, 10 Feb 2025 20:42:12 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=9C=8D=E5=8A=A1=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E3=80=91=E6=9B=B4=E6=96=B0=E3=80=81=E5=88=A0=E9=99=A4=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E5=90=8E=E6=9B=B4=E6=96=B0=E5=85=B6=E5=9B=BD=E9=99=85?= =?UTF-8?q?=E5=8C=96=E5=86=85=E5=AE=B9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../github/xezzon/zeroweb/app/AppService.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/zeroweb-service/zeroweb-service-admin/src/main/java/io/github/xezzon/zeroweb/app/AppService.java b/zeroweb-service/zeroweb-service-admin/src/main/java/io/github/xezzon/zeroweb/app/AppService.java index d38c84d7..f837ffa4 100644 --- a/zeroweb-service/zeroweb-service-admin/src/main/java/io/github/xezzon/zeroweb/app/AppService.java +++ b/zeroweb-service/zeroweb-service-admin/src/main/java/io/github/xezzon/zeroweb/app/AppService.java @@ -1,7 +1,12 @@ package io.github.xezzon.zeroweb.app; import io.github.xezzon.zeroweb.app.domain.App; +import io.github.xezzon.zeroweb.locale.event.I18nMessageChangedEvent; +import io.github.xezzon.zeroweb.locale.event.I18nMessageDeletedEvent; +import jakarta.annotation.Resource; import java.util.List; +import java.util.Optional; +import org.springframework.context.ApplicationEventPublisher; import org.springframework.stereotype.Service; /** @@ -11,6 +16,8 @@ public class AppService { private final AppDAO appDAO; + @Resource + private ApplicationEventPublisher eventPublisher; public AppService(final AppDAO appDAO) { this.appDAO = appDAO; @@ -37,7 +44,11 @@ List listApp() { * @param app 服务信息 */ void updateApp(App app) { - appDAO.partialUpdate(app); + final App entity = appDAO.get().findById(app.getId()).orElseThrow(); + final App oldValue = new App(); + appDAO.getCopier().copy(entity, oldValue); + /* 后置处理 */ + eventPublisher.publishEvent(new I18nMessageChangedEvent(oldValue, app)); } /** @@ -45,6 +56,12 @@ void updateApp(App app) { * @param id 服务ID */ void deleteApp(String id) { + final Optional app = appDAO.get().findById(id); + if (app.isEmpty()) { + return; + } appDAO.get().deleteById(id); + /* 后置处理 */ + eventPublisher.publishEvent(new I18nMessageDeletedEvent(app.get())); } }