Search in sources :

Example 1 with Options

use of cc.ryanc.halo.model.domain.Options in project halo by ruibaby.

the class OptionsServiceImpl method saveOption.

/**
 * 保存单个设置选项
 *
 * @param key key
 * @param value value
 */
@CacheEvict(value = OPTIONS_CACHE_NAME, key = OPTIONS_KEY)
@Override
public void saveOption(String key, String value) {
    Options options = null;
    if ("".equals(value)) {
        options = new Options();
        options.setOptionName(key);
        this.removeOption(options);
    } else {
        if (HaloUtil.isNotNull(key)) {
            // 如果查询到有该设置选项则做更新操作,反之保存新的设置选项
            if (null == optionsRepository.findOptionsByOptionName(key)) {
                options = new Options();
                options.setOptionName(key);
                options.setOptionValue(value);
                optionsRepository.save(options);
            } else {
                options = optionsRepository.findOptionsByOptionName(key);
                options.setOptionValue(value);
                optionsRepository.save(options);
            }
        }
    }
}
Also used : Options(cc.ryanc.halo.model.domain.Options) CacheEvict(org.springframework.cache.annotation.CacheEvict)

Aggregations

Options (cc.ryanc.halo.model.domain.Options)1 CacheEvict (org.springframework.cache.annotation.CacheEvict)1