|  | @@ -1,10 +1,14 @@
 | 
											
												
													
														|  |  package com.tzld.longarticle.recommend.server.service;
 |  |  package com.tzld.longarticle.recommend.server.service;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +import com.ctrip.framework.apollo.model.ConfigChangeEvent;
 | 
											
												
													
														|  | 
 |  | +import com.ctrip.framework.apollo.spring.annotation.ApolloConfigChangeListener;
 | 
											
												
													
														|  |  import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
 |  |  import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
 | 
											
												
													
														|  |  import com.google.common.collect.BiMap;
 |  |  import com.google.common.collect.BiMap;
 | 
											
												
													
														|  | 
 |  | +import com.google.common.collect.HashBiMap;
 | 
											
												
													
														|  |  import lombok.extern.slf4j.Slf4j;
 |  |  import lombok.extern.slf4j.Slf4j;
 | 
											
												
													
														|  |  import org.springframework.stereotype.Component;
 |  |  import org.springframework.stereotype.Component;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +import javax.annotation.PostConstruct;
 | 
											
												
													
														|  |  import java.util.Map;
 |  |  import java.util.Map;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  /**
 |  |  /**
 | 
											
										
											
												
													
														|  | @@ -17,9 +21,21 @@ public class AccountContentPoolConfigService {
 | 
											
												
													
														|  |      @ApolloJsonValue("${accountContentPoolConfig:{}}")
 |  |      @ApolloJsonValue("${accountContentPoolConfig:{}}")
 | 
											
												
													
														|  |      private Map<String, String[]> accountContentPoolMap;
 |  |      private Map<String, String[]> accountContentPoolMap;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -    @ApolloJsonValue("${contentPoolLevelConfig:{}}")
 |  | 
 | 
											
												
													
														|  |      private BiMap<String, Integer> contentPoolLevelMap;
 |  |      private BiMap<String, Integer> contentPoolLevelMap;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +    @ApolloJsonValue("${contentPoolLevelConfig:}")
 | 
											
												
													
														|  | 
 |  | +    private Map<String, Integer> contentPoolLevelConfig;
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    @PostConstruct
 | 
											
												
													
														|  | 
 |  | +    public void init() {
 | 
											
												
													
														|  | 
 |  | +        contentPoolLevelMap = HashBiMap.create(contentPoolLevelConfig);
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    @ApolloConfigChangeListener(interestedKeys = {"contentPoolLevelConfig"})
 | 
											
												
													
														|  | 
 |  | +    public void configChange(ConfigChangeEvent changeEvent) {
 | 
											
												
													
														|  | 
 |  | +        init();
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      public String[] getContentPools(String accountName) {
 |  |      public String[] getContentPools(String accountName) {
 | 
											
												
													
														|  |          if (accountContentPoolMap.containsKey(accountName)) {
 |  |          if (accountContentPoolMap.containsKey(accountName)) {
 | 
											
										
											
												
													
														|  | @@ -29,6 +45,7 @@ public class AccountContentPoolConfigService {
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      public String getContentPoolByLevel(int level) {
 |  |      public String getContentPoolByLevel(int level) {
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |          return contentPoolLevelMap.inverse().getOrDefault(level, "");
 |  |          return contentPoolLevelMap.inverse().getOrDefault(level, "");
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 |