yujian
2020-05-09 7e7db2fa55a9a3af46d4fd8ede0dee147f101d64
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
package com.yeshi.fanli.service.impl.config;
 
import javax.annotation.Resource;
 
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
 
import com.yeshi.fanli.dao.mybatis.SystemConfigMapper;
import com.yeshi.fanli.entity.system.BusinessSystem;
import com.yeshi.fanli.entity.system.SystemConfig;
import com.yeshi.fanli.exception.NotExistObjectException;
import com.yeshi.fanli.service.inter.config.SystemConfigService;
 
@Service
public class SystemConfigServiceImpl implements SystemConfigService{
 
    @Resource
    private SystemConfigMapper systemConfigMapper;
    
 
    @Cacheable(value={"childSystemCache"}, key="#p0")
    public String get(String sigkey) throws NotExistObjectException {
         SystemConfig systemConfig = systemConfigMapper.getByKey(sigkey);        
         if(systemConfig == null ){
            throw new NotExistObjectException("不存在该参数"); 
        }
        return systemConfig.getValue();
    }
    
    
    @Cacheable(value={"childSystemCache"}, key="#p0+#system.id")
    public String get(String key, BusinessSystem system) {
        if(system==null || system.getId()==0){
            return "";
        }
        SystemConfig systemConfig = systemConfigMapper.getByKeyAndSystemId(key, system.getId());
        if(systemConfig != null){;
            return systemConfig.getValue();
        }
        return "";
    }
    
 
}