admin
2023-04-12 f06a592dd1a7e995bf313ccb5efe7dff73ccfc4e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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);
 
    }
}