Browse Source

创建广告主时同步内存广告主数据

jun.zhou 9 years ago
parent
commit
7c1f9c8a22

+ 0 - 2
src/main/java/com/cloudcross/ssp/listener/ApplicationListener.java

@@ -39,7 +39,5 @@ public class ApplicationListener implements ServletContextListener{
 		}
 		AdvertiserLoader.setAgentIdAdvertiserIdMap();
 	}
-
 	
-
 }

+ 4 - 5
src/main/java/com/cloudcross/ssp/loader/AdvertiserLoader.java

@@ -67,9 +67,9 @@ public class AdvertiserLoader {
 			}
 			agentKeyMap.put(agentId, advList);
 		}
-		for(Map.Entry<Long, List<Advertiser>> entry:agentKeyMap.entrySet()){
+		/*for(Map.Entry<Long, List<Advertiser>> entry:agentKeyMap.entrySet()){
 			log.debug("key="+entry.getKey()+":value="+entry.getValue());
-		}
+		}*/
 		return agentKeyMap;
 	}
 	
@@ -92,9 +92,9 @@ public class AdvertiserLoader {
 			str = str + list.get(count-1).getId();
 			AGENTID_ADVERTISERID_MAP.put(l, str);
 		}
-		for(Map.Entry<Long,String>entry:AGENTID_ADVERTISERID_MAP.entrySet()){
+		/*for(Map.Entry<Long,String>entry:AGENTID_ADVERTISERID_MAP.entrySet()){
 			log.debug("key="+entry.getKey()+":value="+entry.getValue());
-		}
+		}*/
 	}
 	
 	/**
@@ -104,7 +104,6 @@ public class AdvertiserLoader {
 	 */
 	public static String getAgentIdAdvertiserIdMap(Long agentId){
 		if(AGENTID_ADVERTISERID_MAP != null && AGENTID_ADVERTISERID_MAP.size()>0){
-			log.debug(AGENTID_ADVERTISERID_MAP.get(agentId));
 			return AGENTID_ADVERTISERID_MAP.get(agentId);
 		}else{
 			log.debug("无法从内存获取数据");

+ 16 - 0
src/main/java/com/cloudcross/ssp/web/advertiser/main/ad/AdvertiserController.java

@@ -23,6 +23,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseBody;
 
+import com.cloudcross.ssp.listener.ApplicationListener;
+import com.cloudcross.ssp.loader.AdvertiserLoader;
 import com.cloudcross.ssp.model.Account;
 import com.cloudcross.ssp.model.Advertiser;
 import com.cloudcross.ssp.model.Industry;
@@ -32,6 +34,7 @@ import com.cloudcross.ssp.service.IAdvertiserService;
 import com.cloudcross.ssp.service.IIndustryService;
 import com.cloudcross.ssp.service.ILogService;
 import com.cloudcross.ssp.service.IMessageService;
+import com.cloudcross.ssp.base.dao.GenericIBatisDao;
 import com.cloudcross.ssp.base.utils.freemarker.FreemarkerTemplateProcessor;
 import com.cloudcross.ssp.base.web.SimpleController;
 import com.cloudcross.ssp.base.web.result.AjaxResult;
@@ -57,6 +60,8 @@ public class AdvertiserController extends SimpleController {
 	private IMessageService messageService;
 	@Autowired
 	private FreemarkerTemplateProcessor templateProcessor;
+	@Autowired
+	private GenericIBatisDao myBatisDao;
 	/**
 	 * @return 返回到广告主管理第一页。
 	 */
@@ -202,6 +207,8 @@ public class AdvertiserController extends SimpleController {
 				t.setOperatorId(new Long(0));
 			}
 			if (advertiserService.add(t)) {
+				//广告主创建成功,重新广告主信息
+				loadAdvertiser();
 				//添加广告主后的资质审核消息
 				Message message = new Message();
 				Boolean flag = ("".equals(t.getCpiPath())&&"".equals(t.getIdPath())&&"".equals(t.getLicencePath())&&"".equals(t.getOrgPath()));
@@ -228,6 +235,7 @@ public class AdvertiserController extends SimpleController {
 				
 				
 			}
+			
 		} else {
 			Advertiser formerAdvertiser = advertiserService.findById(t.getId());
 			Industry formerIndustry = industryService.findByIndustryId(formerAdvertiser.getIndustryId());
@@ -532,5 +540,13 @@ public class AdvertiserController extends SimpleController {
 		}
 		return 	false;
 	}
+	
+	/**
+	 * 加载广告主信息
+	 */
+	public void loadAdvertiser(){
+		//项目启动时,放在内存的广告主信息处理完毕后,集合会被清空,再次加载广告主信息前不需要再次清空
+		new ApplicationListener().initAdvertiser(myBatisDao);
+	}
 
 }