|  | @ -3,8 +3,6 @@ package com.yihu.hos.system.service;
 | 
	
		
			
				|  |  | import com.fasterxml.jackson.databind.ObjectMapper;
 | 
	
		
			
				|  |  | import com.yihu.hos.common.constants.ContextAttributes;
 | 
	
		
			
				|  |  | import com.yihu.hos.config.MongoConfig;
 | 
	
		
			
				|  |  | import com.yihu.hos.core.datatype.StringUtil;
 | 
	
		
			
				|  |  | import com.yihu.hos.core.encrypt.DES;
 | 
	
		
			
				|  |  | import com.yihu.hos.core.log.Logger;
 | 
	
		
			
				|  |  | import com.yihu.hos.core.log.LoggerFactory;
 | 
	
		
			
				|  |  | import com.yihu.hos.interceptor.LocalContext;
 | 
	
	
		
			
				|  | @ -18,16 +16,13 @@ import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Value;
 | 
	
		
			
				|  |  | import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  | import org.springframework.transaction.annotation.Transactional;
 | 
	
		
			
				|  |  | import org.springframework.web.multipart.commons.CommonsMultipartFile;
 | 
	
		
			
				|  |  | import org.zbus.broker.ZbusBroker;
 | 
	
		
			
				|  |  | import org.zbus.mq.Producer;
 | 
	
		
			
				|  |  | import org.zbus.net.http.Message;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import javax.annotation.Resource;
 | 
	
		
			
				|  |  | import java.io.IOException;
 | 
	
		
			
				|  |  | import java.io.OutputStream;
 | 
	
		
			
				|  |  | import java.util.Map;
 | 
	
		
			
				|  |  | import java.util.UUID;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | /**
 | 
	
		
			
				|  |  |  * Created by chenweida on 2016/1/21.
 | 
	
	
		
			
				|  | @ -69,24 +64,39 @@ public class AppManager {
 | 
	
		
			
				|  |  |         return appDao.getEntity(SystemApp.class, id);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public SystemApp getAppByCode(String code) throws Exception {
 | 
	
		
			
				|  |  |         return appDao.findByCode(code);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Transactional
 | 
	
		
			
				|  |  |     public Result addApp(SystemApp obj) throws Exception {
 | 
	
		
			
				|  |  |         appDao.saveEntity(obj);
 | 
	
		
			
				|  |  |         return Result.success("保存成功");
 | 
	
		
			
				|  |  |         SystemApp appByCode = getAppByCode(obj.getCode());
 | 
	
		
			
				|  |  |         if (appByCode == null) {
 | 
	
		
			
				|  |  |             appDao.saveEntity(obj);
 | 
	
		
			
				|  |  |             return Result.success("保存成功");
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             return Result.error("保存失败,应用Code已存在");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Transactional
 | 
	
		
			
				|  |  |     public Result updateApp(SystemApp obj) throws Exception {
 | 
	
		
			
				|  |  |         SystemApp systemApp = appDao.getEntity(SystemApp.class, obj.getId());
 | 
	
		
			
				|  |  |         systemApp.setName(obj.getName());
 | 
	
		
			
				|  |  |         systemApp.setCode(obj.getCode());
 | 
	
		
			
				|  |  |         systemApp.setAppKey(obj.getAppKey());
 | 
	
		
			
				|  |  |         systemApp.setAppSecret(obj.getAppSecret());
 | 
	
		
			
				|  |  |         systemApp.setAppUrl(obj.getAppUrl());
 | 
	
		
			
				|  |  |         systemApp.setDeveloper(obj.getDeveloper());
 | 
	
		
			
				|  |  |         systemApp.setIcon(obj.getIcon());
 | 
	
		
			
				|  |  |         systemApp.setStatus(obj.getStatus());
 | 
	
		
			
				|  |  |         return Result.success("更新成功");
 | 
	
		
			
				|  |  |         SystemApp appByCode = getAppByCode(obj.getCode());
 | 
	
		
			
				|  |  |         if (appByCode == null) {
 | 
	
		
			
				|  |  |             SystemApp systemApp = appDao.getEntity(SystemApp.class, obj.getId());
 | 
	
		
			
				|  |  |             systemApp.setName(obj.getName());
 | 
	
		
			
				|  |  |             systemApp.setCode(obj.getCode());
 | 
	
		
			
				|  |  |             systemApp.setAppKey(obj.getAppKey());
 | 
	
		
			
				|  |  |             systemApp.setAppSecret(obj.getAppSecret());
 | 
	
		
			
				|  |  |             systemApp.setAppUrl(obj.getAppUrl());
 | 
	
		
			
				|  |  |             systemApp.setDeveloper(obj.getDeveloper());
 | 
	
		
			
				|  |  |             systemApp.setIcon(obj.getIcon());
 | 
	
		
			
				|  |  |             systemApp.setStatus(obj.getStatus());
 | 
	
		
			
				|  |  |             return Result.success("更新成功");
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             return Result.error("更新失败,应用Code已存在");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Transactional
 |