Add some logs in save option service

pull/146/head
johnniang 2019-04-08 22:58:30 +08:00
parent 8fb7057cd4
commit edefa7e810
2 changed files with 7 additions and 15 deletions

View File

@ -24,8 +24,6 @@ import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static run.halo.app.model.support.HaloConst.DEFAULT_THEME_NAME;
/** /**
* OptionService implementation class * OptionService implementation class
* *
@ -57,15 +55,18 @@ public class OptionServiceImpl extends AbstractCrudService<Option, Integer> impl
if (StringUtils.isBlank(value)) { if (StringUtils.isBlank(value)) {
// If the value is blank, remove the key // If the value is blank, remove the key
optionRepository.removeByOptionKey(key); optionRepository.removeByOptionKey(key);
log.debug("Removed option key: [{}]", key);
return; return;
} }
// TODO Consider cache options with map // TODO Consider cache options with map
Option option = optionRepository.findByOptionKey(key).map(anOption -> { Option option = optionRepository.findByOptionKey(key).map(anOption -> {
log.debug("Updating option key: [{}], value: from [{}] to [{}]", key, anOption.getOptionValue(), value);
// Exist // Exist
anOption.setOptionValue(value); anOption.setOptionValue(value);
return anOption; return anOption;
}).orElseGet(() -> { }).orElseGet(() -> {
log.debug("Creating option key: [{}], value: [{}]", key, value);
// Not exist // Not exist
Option anOption = new Option(); Option anOption = new Option();
anOption.setOptionKey(key); anOption.setOptionKey(key);
@ -75,7 +76,9 @@ public class OptionServiceImpl extends AbstractCrudService<Option, Integer> impl
}); });
// Save or update the options // Save or update the options
optionRepository.save(option); Option savedOption = optionRepository.save(option);
log.debug("Saved option: [{}]", savedOption);
} }
/** /**

View File

@ -75,13 +75,7 @@ public class ThemeController {
return themeService.getCustomTpl(themeService.getTheme()); return themeService.getCustomTpl(themeService.getTheme());
} }
/** @PostMapping("active")
* Active theme.
*
* @param theme theme name
* @throws TemplateModelException TemplateModelException
*/
@GetMapping(value = "active")
@ApiOperation("Active a theme") @ApiOperation("Active a theme")
public void active(String theme) throws TemplateModelException { public void active(String theme) throws TemplateModelException {
// TODO Check existence of the theme // TODO Check existence of the theme
@ -90,11 +84,6 @@ public class ThemeController {
configuration.setSharedVariable("options", optionService.listOptions()); configuration.setSharedVariable("options", optionService.listOptions());
} }
/**
* Deletes a theme.
*
* @param key theme key
*/
@DeleteMapping("{key}") @DeleteMapping("{key}")
@ApiOperation("Deletes a theme") @ApiOperation("Deletes a theme")
public void deleteBy(@PathVariable("key") String key) { public void deleteBy(@PathVariable("key") String key) {