Search in sources :

Example 6 with Config

use of com.dimple.project.system.domain.Config in project DimpleBlog by martin-chips.

the class ConfigServiceImpl method selectConfigById.

@Override
public Config selectConfigById(Long configId) {
    Config config = new Config();
    config.setId(configId);
    return configMapper.selectConfig(config);
}
Also used : Config(com.dimple.project.system.domain.Config)

Example 7 with Config

use of com.dimple.project.system.domain.Config in project DimpleBlog by martin-chips.

the class ConfigServiceImpl method selectConfigByConfigKey.

@Override
@Cacheable(value = CacheConstants.CACHE_NAME_BACKEND_CONFIG, key = "#key")
@CacheExpire(expire = 5, type = TimeType.HOURS)
public <T> T selectConfigByConfigKey(String key, Class<T> tClass) {
    Config config = new Config();
    config.setConfigKey(key);
    Config retConfig = configMapper.selectConfig(config);
    if (retConfig == null) {
        throw new CustomException("Can not get config by key  " + key);
    }
    return JSON.parseObject(retConfig.getConfigValue(), tClass);
}
Also used : Config(com.dimple.project.system.domain.Config) CustomException(com.dimple.common.exception.CustomException) CacheExpire(com.dimple.framework.config.redis.CacheExpire) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 8 with Config

use of com.dimple.project.system.domain.Config in project DimpleBlog by martin-chips.

the class ConfigServiceImpl method selectConfigByKey.

@Override
public Config selectConfigByKey(String configKey) {
    Config config = new Config();
    config.setConfigKey(configKey);
    Config retConfig = configMapper.selectConfig(config);
    return Objects.isNull(retConfig) ? new Config() : retConfig;
}
Also used : Config(com.dimple.project.system.domain.Config)

Example 9 with Config

use of com.dimple.project.system.domain.Config in project DimpleBlog by martin-chips.

the class SettingController method editEmailSetting.

@PutMapping("emailSetting")
@Log(title = "系统设置-邮件设置", businessType = BusinessType.UPDATE)
@PreAuthorize("@permissionService.hasPermission('system:setting:emailSetting:edit')")
public AjaxResult editEmailSetting(@RequestBody EmailSetting emailSetting) {
    String jsonString = JSON.toJSONString(emailSetting);
    Config config = new Config();
    config.setConfigKey(ConfigKey.CONFIG_KEY_EMAIL_SETTING);
    config.setConfigValue(jsonString);
    return AjaxResult.success(configService.updateConfigByConfigKey(config));
}
Also used : Config(com.dimple.project.system.domain.Config) Log(com.dimple.framework.aspectj.lang.annotation.Log) PutMapping(org.springframework.web.bind.annotation.PutMapping) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 10 with Config

use of com.dimple.project.system.domain.Config in project DimpleBlog by martin-chips.

the class SettingController method editAbout.

@PutMapping("/about")
@Log(title = "系统设置-关于", businessType = BusinessType.UPDATE)
@PreAuthorize("@permissionService.hasPermission('system:setting:about:edit')")
public AjaxResult editAbout(@RequestBody AboutSetting aboutSetting) {
    String jsonString = JSON.toJSONString(aboutSetting);
    Config config = new Config();
    config.setConfigKey(ConfigKey.CONFIG_KEY_ABOUT);
    config.setConfigValue(jsonString);
    return AjaxResult.success(configService.updateConfigByConfigKey(config));
}
Also used : Config(com.dimple.project.system.domain.Config) Log(com.dimple.framework.aspectj.lang.annotation.Log) PutMapping(org.springframework.web.bind.annotation.PutMapping) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

Config (com.dimple.project.system.domain.Config)10 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)4 Log (com.dimple.framework.aspectj.lang.annotation.Log)3 PutMapping (org.springframework.web.bind.annotation.PutMapping)3 QiNiuConfig (com.dimple.project.common.domain.QiNiuConfig)2 CustomException (com.dimple.common.exception.CustomException)1 CacheExpire (com.dimple.framework.config.redis.CacheExpire)1 EmailSetting (com.dimple.project.system.domain.EmailSetting)1 Cacheable (org.springframework.cache.annotation.Cacheable)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1