mirror of https://github.com/halo-dev/halo
* fix: #1068 * add: ThemeSettingService.save add SERIALIZABLE level * add: saveSettingsByThemeId Api add @CacheLockpull/1072/head
parent
504e6e187e
commit
ed46ab7031
|
@ -5,6 +5,7 @@ import org.springframework.http.HttpStatus;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import run.halo.app.annotation.DisableOnCondition;
|
||||
import run.halo.app.cache.lock.CacheLock;
|
||||
import run.halo.app.handler.theme.config.support.Group;
|
||||
import run.halo.app.handler.theme.config.support.ThemeProperty;
|
||||
import run.halo.app.model.params.ThemeContentParam;
|
||||
|
@ -144,6 +145,7 @@ public class ThemeController {
|
|||
|
||||
@PostMapping("{themeId}/settings")
|
||||
@ApiOperation("Saves theme settings")
|
||||
@CacheLock(prefix = "save_theme_setting_by_themeId")
|
||||
public void saveSettingsBy(@PathVariable("themeId") String themeId,
|
||||
@RequestBody Map<String, Object> settings) {
|
||||
themeSettingService.save(settings, themeId);
|
||||
|
|
|
@ -4,6 +4,7 @@ import freemarker.template.Configuration;
|
|||
import freemarker.template.TemplateModelException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.data.domain.Example;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
@ -87,7 +88,10 @@ public class ThemeSettingServiceImpl extends AbstractCrudService<ThemeSetting, I
|
|||
log.debug("Creating theme setting: [{}]", setting);
|
||||
return setting;
|
||||
});
|
||||
|
||||
// Determine whether the data already exists
|
||||
if (themeSettingRepository.findOne(Example.of(themeSetting)).isPresent()) {
|
||||
return null;
|
||||
}
|
||||
// Save the theme setting
|
||||
return themeSettingRepository.save(themeSetting);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue