package com.yeshi.buwan.service.imp.system;
|
|
import com.yeshi.buwan.dao.system.SystemConfigDao;
|
import com.yeshi.buwan.domain.system.SystemConfig;
|
import com.yeshi.buwan.service.inter.system.SystemConfigService;
|
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
import java.util.Date;
|
|
@Service
|
public class SystemConfigServiceImpl implements SystemConfigService {
|
|
@Resource
|
private SystemConfigDao systemConfigDao;
|
|
|
@Override
|
public SystemConfig getConfigByKey(String key) {
|
return systemConfigDao.get(key);
|
}
|
|
@Cacheable(value = "configCache", key = "'system-getConfigByKey'+'-'+#key")
|
@Override
|
public SystemConfig getConfigByKeyCache(String key) {
|
return getConfigByKey(key);
|
}
|
|
@Cacheable(value = "configCache", key = "'system-getConfigValueByKey'+'-'+#key")
|
@Override
|
public String getConfigValueByKeyCache(String key) {
|
SystemConfig config = getConfigByKeyCache(key);
|
if (config == null)
|
return null;
|
return config.getValue();
|
}
|
|
@Override
|
public void setValue(String key, String value) {
|
SystemConfig config = getConfigByKeyCache(key);
|
if (config == null)
|
return;
|
config.setValue(value);
|
config.setUpdateTime(new Date());
|
systemConfigDao.save(config);
|
|
}
|
}
|