| | |
| | | package com.yeshi.fanli.service.impl.config;
|
| | |
|
| | | 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.mybatis.BusinessSystemMapper;
|
| | | import com.yeshi.fanli.entity.system.BusinessSystem;
|
| | | import com.yeshi.fanli.service.inter.config.BusinessSystemService;
|
| | |
|
| | | @Service
|
| | | public class BusinessSystemServiceImpl implements BusinessSystemService {
|
| | |
|
| | | @Resource
|
| | | private BusinessSystemMapper businessSystemMapper;
|
| | |
|
| | | 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);
|
| | | }
|
| | |
|
| | | @Override
|
| | | @Cacheable(value = "sysCache", key = "'getBusinessSystem-'+#platform+'-'+#packages")
|
| | | public BusinessSystem getBusinessSystem(String platform, String packages) {
|
| | | if (platform == null || packages == null) {
|
| | | return null;
|
| | | }
|
| | | platform = platform.toUpperCase();
|
| | | Integer platformInt = map.get(platform);
|
| | |
|
| | | List<BusinessSystem> list = businessSystemMapper.listByPlatformAndPackage(platformInt, packages);
|
| | | if (list == null || list.size() == 0) {
|
| | | return null;
|
| | | }
|
| | | return list.get(0);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public BusinessSystem getBusinessSystemCache(String platform, String packages) {
|
| | | return getBusinessSystem(platform, packages);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public BusinessSystem getById(long id) {
|
| | | return businessSystemMapper.selectByPrimaryKey(id);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<BusinessSystem> getBusinessSystems() {
|
| | | return businessSystemMapper.listAll();
|
| | | }
|
| | |
|
| | | }
|
| | | package com.yeshi.fanli.service.impl.config; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.yeshi.fanli.entity.SystemEnum; |
| | | import org.springframework.cache.annotation.Cacheable; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.yeshi.fanli.dao.mybatis.BusinessSystemMapper; |
| | | import com.yeshi.fanli.entity.system.BusinessSystem; |
| | | import com.yeshi.fanli.service.inter.config.BusinessSystemService; |
| | | |
| | | @Service |
| | | public class BusinessSystemServiceImpl implements BusinessSystemService { |
| | | |
| | | @Resource |
| | | private BusinessSystemMapper businessSystemMapper; |
| | | |
| | | private static final String ANDROID = "ANDROID"; |
| | | private static final String IOS = "IOS"; |
| | | private static final String WEB = "WEB"; |
| | | private static final String WXMP = "WXMP"; |
| | | |
| | | private static final Map<String, Integer> map = new HashMap<String, Integer>(); |
| | | |
| | | static { |
| | | map.put(ANDROID, 1); |
| | | map.put(IOS, 2); |
| | | map.put(WEB, 3); |
| | | map.put(WXMP, 4); |
| | | } |
| | | |
| | | @Override |
| | | public BusinessSystem getBusinessSystem(String platform, String packages, SystemEnum system) { |
| | | if (platform == null || packages == null) { |
| | | return null; |
| | | } |
| | | platform = platform.toUpperCase(); |
| | | Integer platformInt = map.get(platform); |
| | | |
| | | List<BusinessSystem> list = businessSystemMapper.listByPlatformAndPackage(platformInt, packages,system); |
| | | if (list == null || list.size() == 0) { |
| | | return null; |
| | | } |
| | | return list.get(0); |
| | | } |
| | | |
| | | @Cacheable(value = "sysCache", key = "'getBusinessSystem-'+#platform+'-'+#packages+'-'+#system") |
| | | @Override |
| | | public BusinessSystem getBusinessSystemCache(String platform, String packages, SystemEnum system) { |
| | | return getBusinessSystem(platform, packages,system); |
| | | } |
| | | |
| | | @Override |
| | | public BusinessSystem getById(long id) { |
| | | return businessSystemMapper.selectByPrimaryKey(id); |
| | | } |
| | | |
| | | @Override |
| | | public List<BusinessSystem> getBusinessSystems() { |
| | | return businessSystemMapper.listAll(); |
| | | } |
| | | |
| | | } |