From edefa7e810b3648499409eaf08f200fb3d0afe54 Mon Sep 17 00:00:00 2001 From: johnniang Date: Mon, 8 Apr 2019 22:58:30 +0800 Subject: [PATCH] Add some logs in save option service --- .../halo/app/service/impl/OptionServiceImpl.java | 9 ++++++--- .../web/controller/admin/api/ThemeController.java | 13 +------------ 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/main/java/run/halo/app/service/impl/OptionServiceImpl.java b/src/main/java/run/halo/app/service/impl/OptionServiceImpl.java index bf1f26b75..631aca3f9 100644 --- a/src/main/java/run/halo/app/service/impl/OptionServiceImpl.java +++ b/src/main/java/run/halo/app/service/impl/OptionServiceImpl.java @@ -24,8 +24,6 @@ import java.util.Map; import java.util.Optional; import java.util.stream.Collectors; -import static run.halo.app.model.support.HaloConst.DEFAULT_THEME_NAME; - /** * OptionService implementation class * @@ -57,15 +55,18 @@ public class OptionServiceImpl extends AbstractCrudService impl if (StringUtils.isBlank(value)) { // If the value is blank, remove the key optionRepository.removeByOptionKey(key); + log.debug("Removed option key: [{}]", key); return; } // TODO Consider cache options with map Option option = optionRepository.findByOptionKey(key).map(anOption -> { + log.debug("Updating option key: [{}], value: from [{}] to [{}]", key, anOption.getOptionValue(), value); // Exist anOption.setOptionValue(value); return anOption; }).orElseGet(() -> { + log.debug("Creating option key: [{}], value: [{}]", key, value); // Not exist Option anOption = new Option(); anOption.setOptionKey(key); @@ -75,7 +76,9 @@ public class OptionServiceImpl extends AbstractCrudService impl }); // Save or update the options - optionRepository.save(option); + Option savedOption = optionRepository.save(option); + + log.debug("Saved option: [{}]", savedOption); } /** diff --git a/src/main/java/run/halo/app/web/controller/admin/api/ThemeController.java b/src/main/java/run/halo/app/web/controller/admin/api/ThemeController.java index 7e8fe1720..32f7d629f 100644 --- a/src/main/java/run/halo/app/web/controller/admin/api/ThemeController.java +++ b/src/main/java/run/halo/app/web/controller/admin/api/ThemeController.java @@ -75,13 +75,7 @@ public class ThemeController { return themeService.getCustomTpl(themeService.getTheme()); } - /** - * Active theme. - * - * @param theme theme name - * @throws TemplateModelException TemplateModelException - */ - @GetMapping(value = "active") + @PostMapping("active") @ApiOperation("Active a theme") public void active(String theme) throws TemplateModelException { // TODO Check existence of the theme @@ -90,11 +84,6 @@ public class ThemeController { configuration.setSharedVariable("options", optionService.listOptions()); } - /** - * Deletes a theme. - * - * @param key theme key - */ @DeleteMapping("{key}") @ApiOperation("Deletes a theme") public void deleteBy(@PathVariable("key") String key) {