package com.yeshi.fanli.system.service.impl.common;
|
|
import java.io.Serializable;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
import javax.annotation.Resource;
|
|
import org.fanli.facade.system.entity.common.SystemManage;
|
import org.fanli.facade.system.service.common.SystemManageService;
|
import org.springframework.cache.annotation.Cacheable;
|
|
import com.alibaba.dubbo.config.annotation.Service;
|
import com.yeshi.fanli.system.dao.common.SystemManageDao;
|
|
@Service(version = "1.0.0")
|
public class SystemManageServiceImpl implements SystemManageService {
|
|
@Resource
|
private SystemManageDao 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 SystemManage getSystem(String platform, String packages) {
|
if (platform == null || packages == null) {
|
return null;
|
}
|
platform = platform.toUpperCase();
|
Integer platformInt = map.get(platform);
|
|
List<SystemManage> list = systemDao.list("from SystemManage where platform=? and packageName=?",
|
new Serializable[] { platformInt, packages });
|
if (list == null || list.size() == 0) {
|
return null;
|
}
|
return list.get(0);
|
}
|
|
public List<SystemManage> getSystems() {
|
return systemDao.list("from SystemManage");
|
}
|
|
@Cacheable(value = "configCache", key = "'getSystemManage-'+#platform+'-'+#packages")
|
@Override
|
public SystemManage getSystemCache(String platform, String packages) {
|
return getSystem(platform, packages);
|
}
|
|
|
@Override
|
public SystemManage getById(long id) {
|
return systemDao.find(SystemManage.class, id);
|
}
|
|
}
|