Administrator
2018-10-30 c0c91fbda1ba601c4c8cb6d12fd43dfbe02eea5d
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
50
51
52
53
54
55
56
57
58
59
package com.yeshi.fanli.service.impl.config;
 
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import javax.annotation.Resource;
 
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
 
import com.yeshi.fanli.dao.config.SystemDao;
import com.yeshi.fanli.entity.system.System;
import com.yeshi.fanli.service.inter.config.SystemService;
 
@Service
public class SystemServiceImpl implements SystemService {
 
    @Resource
    private SystemDao systemDao;
 
    private static final String ANDROID = "ANDROID";
    private static final String IOS = "IOS";
    private static final String WEB = "WEB";
 
    private static final Map<String, Integer> map = new HashMap<String, Integer>();
 
    static {
        map.put(ANDROID, 1);
        map.put(IOS, 2);
        map.put(WEB, 3);
    }
    @Cacheable(value = "sysCache", key = "#platform+'-'+#packages")
    public System getSystem(String platform, String packages) {
        if (platform == null || packages == null) {
            return null;
        }
        platform = platform.toUpperCase();
        Integer platformInt = map.get(platform);
 
        List<System> list = systemDao.list("from System where platform=? and packageName=?",
                new Serializable[] { platformInt, packages });
        if (list == null || list.size() == 0) {
            return null;
        }
        return list.get(0);
    }
 
    public List<System> getSystems() {
        return systemDao.list("from System");
    }
    
    @Cacheable(value = "configCache", key = "'getSystem-'+#platform+'-'+#packages")
    @Override
    public System getSystemCache(String platform, String packages) {
        return getSystem(platform, packages);
    }
}