From a335dae46e684c9d3a729d4d21629689e30402ba Mon Sep 17 00:00:00 2001
From: yujian <yujian>
Date: 星期三, 27 三月 2019 09:22:33 +0800
Subject: [PATCH] 系统参数Dao改造(config/clientParams/helpList等)

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/config/SystemConfigServiceImpl.java |  128 +++---------------------------------------
 1 files changed, 10 insertions(+), 118 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/config/SystemConfigServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/config/SystemConfigServiceImpl.java
index ca5d5c4..9087d64 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/config/SystemConfigServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/config/SystemConfigServiceImpl.java
@@ -1,149 +1,41 @@
 package com.yeshi.fanli.service.impl.config;
 
-import java.io.Serializable;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
 import javax.annotation.Resource;
 
 import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
 
-import com.yeshi.fanli.dao.config.SystemConfigDao;
+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.BusinessSystemService;
 import com.yeshi.fanli.service.inter.config.SystemConfigService;
-import com.yeshi.fanli.util.Constant;
-import com.yeshi.fanli.util.Utils;
 
 @Service
 public class SystemConfigServiceImpl implements SystemConfigService{
 
 	@Resource
-	private SystemConfigDao systemConfigDao;
+	private SystemConfigMapper systemConfigMapper;
 	
-	@Resource
-	private BusinessSystemService businessSystemService;
-	
-	public int getCount(BusinessSystem system,String key) {
-		Long lcount;
-		if(system!=null){
-			lcount = systemConfigDao.getCount("select count(sc.id) from SystemConfig sc left join sc.systems s  where s.id=? and sc.name like ?",new Serializable[]{system.getId(),"%"+key+"%"});
-		}else{
-			lcount = systemConfigDao.getCount("select count(sc.id) from SystemConfig sc where sc.name like ?",new Serializable[]{"%"+key+"%"});
-		}
-		return lcount.intValue();
-	}
 
-	public List<SystemConfig> getSystemConfigList(int index,BusinessSystem system, String key) {
-		
-		int start =index * Constant.PAGE_SIZE;
-		List<SystemConfig> list;
-		if(system != null){
-			list = systemConfigDao.list("from SystemConfig sc left outer join fetch sc.systems s where s.id = ? and sc.name like ?",start,Constant.PAGE_SIZE,new Serializable[]{system.getId(),"%"+key+"%"});
-			StringBuffer hql=new StringBuffer("from SystemConfig sc ");
-			Serializable[] params = new Serializable[list.size()];
-			int ii=0;
-			for (SystemConfig sc : list) {
-				if(ii==0){
-					hql.append(" where sc. id = ? ");	
-				}else{
-					hql.append(" or sc. id = ? ");
-				}
-				params[ii]=sc.getId();
-				ii++;
-			}
-			list=systemConfigDao.list(hql.toString(),params);
-		}else{
-			list = systemConfigDao.list("from SystemConfig sc where sc.name like ?",start,Constant.PAGE_SIZE,new Serializable[]{"%"+key+"%"});
-		}
-		
-		return list;
-	}
-
-	public void addSystemConfig(SystemConfig sc) {
-		Set<BusinessSystem> systems = sc.getSystems();
-		Set<BusinessSystem> newSystems=new HashSet<BusinessSystem>();
-		for (BusinessSystem system : systems) {
-			String platform = Utils.getMap().get(String.valueOf(system.getPlatform()));
-			String packages = system.getPackageName();
-			BusinessSystem find = businessSystemService.getBusinessSystem(platform, packages);
-			if(find != null){
-				newSystems.add(find);
-			}
-		}
-		sc.setSystems(newSystems);
-		sc.setUpdatetime(java.lang.System.currentTimeMillis());
-		systemConfigDao.save(sc);
-	}
-
-	public void deleteSystem(long id, BusinessSystem system) throws NotExistObjectException {
-		SystemConfig find = systemConfigDao.find(SystemConfig.class, id);
-		if(find==null){
-			throw new NotExistObjectException("涓嶅瓨鍦ㄨ瀛愮郴缁�");
-		}
-		find.getSystems().remove(system);
-		find.setUpdatetime(java.lang.System.currentTimeMillis());
-		systemConfigDao.update(find);
-	}
-
-	public void addSystem(long id, BusinessSystem system) throws NotExistObjectException {
-		SystemConfig find = systemConfigDao.find(SystemConfig.class, id);
-		if(find==null){
-			throw new NotExistObjectException("涓嶅瓨鍦ㄨ瀛愮郴缁�");
-		}
-		find.getSystems().add(system);
-		find.setUpdatetime(java.lang.System.currentTimeMillis());
-		systemConfigDao.update(find);
-	}
-
-	public SystemConfig getSystemConfig(long id) {
-		
-		return systemConfigDao.find(SystemConfig.class, id);
-	}
-
-	public void updateSystemConfig(SystemConfig sc) throws NotExistObjectException {
-		SystemConfig find = systemConfigDao.find(SystemConfig.class, sc.getId());
-		if(find==null){
-			throw new NotExistObjectException("涓嶅瓨鍦ㄨ瀵硅薄");
-		}
-		sc.setUpdatetime(java.lang.System.currentTimeMillis());
-		Set<BusinessSystem> newSystems=new HashSet<BusinessSystem>();
-		Set<BusinessSystem> systems = sc.getSystems();
-		for (BusinessSystem system : systems) {
-			String platform = Utils.getMap().get(String.valueOf(system.getPlatform()));
-			String packages = system.getPackageName();
-			BusinessSystem sfind = businessSystemService.getBusinessSystem(platform, packages);
-			if(sfind != null){
-				newSystems.add(sfind);
-			}
-		}
-		sc.setSystems(newSystems);
-		systemConfigDao.update(sc);
-	}
-
-	public void deleteSystemConfig(long id) {
-		systemConfigDao.delete(new SystemConfig(id));
-	}
 	@Cacheable(value={"childSystemCache"}, key="#p0")
 	public String get(String sigkey) throws NotExistObjectException {
-		List<SystemConfig> list = systemConfigDao.list("from SystemConfig sc where sc.key = ?", new Serializable[]{sigkey});
-		if(list.size() ==0 ){
+		 SystemConfig systemConfig = systemConfigMapper.getByKey(sigkey);		
+		 if(systemConfig == null ){
 			throw new NotExistObjectException("涓嶅瓨鍦ㄨ鍙傛暟"); 
 		}
-		return list.get(0).getValue();
+		return systemConfig.getValue();
 	}
+	
+	
 	@Cacheable(value={"childSystemCache"}, key="#p0+#system.id")
 	public String get(String key, BusinessSystem system) {
 		if(system==null || system.getId()==0){
 			return "";
 		}
-		List<SystemConfig> list = systemConfigDao.list("select sc from SystemConfig sc join sc.systems syss where sc.key = ? and syss.id=?", new Serializable[]{key,system.getId()});
-		if(list.size() != 0){
-			return list.get(0).getValue();
+		SystemConfig systemConfig = systemConfigMapper.getByKeyAndSystemId(key, system.getId());
+		if(systemConfig != null){;
+			return systemConfig.getValue();
 		}
 		return "";
 	}

--
Gitblit v1.8.0