Skip to content

Commit

Permalink
【服务管理】更新、删除服务后更新其国际化内容。
Browse files Browse the repository at this point in the history
  • Loading branch information
xezzon committed Feb 10, 2025
1 parent 3980846 commit ad5fa17
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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;

/**

Check warning

Code scanning / Checkstyle (MegaLinter JAVA_CHECKSTYLE)

Summary javadoc is missing. Warning

Summary javadoc is missing.
Expand All @@ -11,6 +16,8 @@
public class AppService {

private final AppDAO appDAO;
@Resource
private ApplicationEventPublisher eventPublisher;

public AppService(final AppDAO appDAO) {

Check warning

Code scanning / Checkstyle (MegaLinter JAVA_CHECKSTYLE)

Missing a Javadoc comment. Warning

Missing a Javadoc comment.
this.appDAO = appDAO;
Expand All @@ -37,14 +44,24 @@ List<App> listApp() {
* @param app 服务信息
*/
void updateApp(App app) {

Check warning

Code scanning / PMD (MegaLinter JAVA_PMD)

Parameter 'req' is not assigned and could be declared final Warning

Parameter 'app' is not assigned and could be declared final
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));
}

/**
* 删除服务
* @param id 服务ID
*/
void deleteApp(String id) {

Check warning

Code scanning / PMD (MegaLinter JAVA_PMD)

Parameter 'req' is not assigned and could be declared final Warning

Parameter 'id' is not assigned and could be declared final
final Optional<App> app = appDAO.get().findById(id);
if (app.isEmpty()) {
return;
}
appDAO.get().deleteById(id);
/* 后置处理 */
eventPublisher.publishEvent(new I18nMessageDeletedEvent(app.get()));
}
}

0 comments on commit ad5fa17

Please sign in to comment.