Browse Source

新闻微服务改用二级域名

wangdy 8 years ago
parent
commit
3537ec551a

+ 3 - 3
src/main/java/com/uas/platform/b2c/advertise/news/service/impl/NewsServiceImpl.java

@@ -30,7 +30,7 @@ public class NewsServiceImpl implements NewsService {
 	@Override
 	public JSONObject getNewsListByPage(int page, int pageSize) {
 		if (page <= 0) page = 1;
-		String url = conf.getRequestUrl(20210, "/news/created/v2?pagenumber=" + page +"&pagesize=" + pageSize + "&taxonomySlug=B2C");
+		String url = conf.getRequestUrlForNews( "/news/created/v2?pagenumber=" + page +"&pagesize=" + pageSize + "&taxonomySlug=B2C");
 		String result = restTemplate.getForEntity(url, String.class).getBody();
 		return JacksonUtils.fromJson(result, JSONObject.class);
 	}
@@ -38,7 +38,7 @@ public class NewsServiceImpl implements NewsService {
 	@Override
 	public JSONObject getNewsListOrderByViewCount(int page, int pageSize) {
 		if (page <= 0) page = 1;
-		String url = conf.getRequestUrl(20210, "/news/viewcount/v2?pagenumber=" + page +"&pagesize=" + pageSize + "&taxonomySlug=B2C");
+		String url = conf.getRequestUrlForNews("/news/viewcount/v2?pagenumber=" + page +"&pagesize=" + pageSize + "&taxonomySlug=B2C");
 		String result = restTemplate.getForEntity(url, String.class).getBody();
 		return JacksonUtils.fromJson(result, JSONObject.class);
 	}
@@ -46,7 +46,7 @@ public class NewsServiceImpl implements NewsService {
 	@Override
 	public JSONObject getNewsById(Long id) {
 		if (id == null) return null;
-		String url = conf.getRequestUrl(20210, "/news/" +  id);
+		String url = conf.getRequestUrlForNews( "/news/" +  id);
 		String result = restTemplate.getForEntity(url, String.class).getBody();
 		return JacksonUtils.fromJson(result, JSONObject.class);
 	}

+ 18 - 0
src/main/java/com/uas/platform/b2c/core/config/MicroServicesConf.java

@@ -16,6 +16,12 @@ public class MicroServicesConf {
 	@Value("#{sys.microServiceIp ?: '10.10.101.23'}")
 	private String microServiceIp;
 
+	/**
+	 * 特殊:news用的是官网数据库
+	 */
+	@Value("#{sys.newsMicroServiceIp ?: 'news.usoftchina.com'}")
+	private String newsMicroServiceIp;
+
 	public String getMicroServiceIp() {
 		return microServiceIp;
 	}
@@ -24,10 +30,22 @@ public class MicroServicesConf {
 		this.microServiceIp = microServiceIp;
 	}
 
+	public String getNewsMicroServiceIp() {
+		return newsMicroServiceIp;
+	}
+
+	public void setNewsMicroServiceIp(String newsMicroServiceIp) {
+		this.newsMicroServiceIp = newsMicroServiceIp;
+	}
+
 	public String getRequestUrl(int port, String requestUrl) {
 		return String.format("http://%s:%d%s", this.microServiceIp, port, requestUrl);
 	}
 
+	public String getRequestUrlForNews(String requestUrl) {
+		return String.format("http://%s%s", this.newsMicroServiceIp, requestUrl);
+	}
+
 	public String getRequestUrl(int port, String requestUrl, PageParams pageable) {
 		return String.format("http://%s:%d%s%s", this.microServiceIp, port, requestUrl, "&count=" + pageable.getCount() + "&page=" + pageable.getPage() + "&filter=" + pageable.getFilter());
 	}

+ 1 - 0
src/main/resources/dev/sys.properties

@@ -23,6 +23,7 @@ reportPrintUrl=http://print.ubtob.com/report/print?userName=B2C&profile=${profil
 reportUploadUrl=http://print.ubtob.com/report/fileUpload?userName=B2C
 # micro service IP(Swarm Manager IP)
 microServiceIp=10.10.101.23
+newsMicroServiceIp=news.usoftchina.com
 endpointUri=10.10.101.23
 recommendPort=20102
 

+ 1 - 0
src/main/resources/prod/sys.properties

@@ -24,6 +24,7 @@ reportPrintUrl=http://print.ubtob.com/report/print?userName=B2C&profile=${profil
 reportUploadUrl=http://print.ubtob.com/report/fileUpload?userName=B2C
 # micro service IP(Swarm Manager IP)
 microServiceIp=10.10.100.23
+newsMicroServiceIp=news.usoftchina.com
 endpointUri=10.10.100.23
 recommendPort=20100
 

+ 1 - 0
src/main/resources/test/sys.properties

@@ -23,6 +23,7 @@ reportPrintUrl=http://print.ubtob.com/report/print?userName=B2C&profile=${profil
 reportUploadUrl=http://print.ubtob.com/report/fileUpload?userName=B2C
 # micro service IP(Swarm Manager IP)
 microServiceIp=10.10.101.23
+newsMicroServiceIp=news.usoftchina.com
 endpointUri=10.10.101.23
 recommendPort=20102