فهرست منبع

迁云-修改上传文件的地址和搜索地址

yujia 8 سال پیش
والد
کامیت
5fc5963559

+ 5 - 5
src/main/java/com/uas/platform/b2c/common/base/constant/FileClientConstant.java

@@ -5,26 +5,26 @@ public class FileClientConstant {
     /**
      * 文件上传
      */
-    public final static String FILE_UPLOAD = "http://10.10.100.200:9999/file/upload";
+    public final static String FILE_UPLOAD = "/file/upload";
 
 
     /**
      * 文件下载
      */
-    public final static String FILE_DOWNLOAD = "http://10.10.100.200:9999/file/download";
+    public final static String FILE_DOWNLOAD = "/file/download";
 
     /**
      * 文件删除
      */
-    public final static String FILE_DELETE = "http://10.10.100.200:9999/file/delete";
+    public final static String FILE_DELETE = "/file/delete";
 
     /**
      * 文件信息
      */
-    public final static String FILE_INFO = "http://10.10.100.200:9999/file/info";
+    public final static String FILE_INFO = "/file/info";
 
     /**
      * 文件额外属性
      */
-    public final static String FILE_METADATA = "http://10.10.100.200:9999/file/metadata";
+    public final static String FILE_METADATA = "/file/metadata";
 }

+ 8 - 4
src/main/java/com/uas/platform/b2c/common/base/service/impl/FileClientImpl.java

@@ -5,6 +5,7 @@ import com.uas.dfs.domain.FileInfo;
 import com.uas.dfs.domain.MetaData;
 import com.uas.dfs.service.FileClient;
 import com.uas.platform.b2c.common.base.constant.FileClientConstant;
+import com.uas.platform.b2c.core.config.SysConf;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.io.ByteArrayResource;
 import org.springframework.http.*;
@@ -23,9 +24,12 @@ public class FileClientImpl implements FileClient {
 
     private final RestTemplate restTemplate;
 
+    private final SysConf sysConf;
+
     @Autowired
-    public FileClientImpl(RestTemplate restTemplate) {
+    public FileClientImpl(RestTemplate restTemplate, SysConf sysConf) {
         this.restTemplate = restTemplate;
+        this.sysConf = sysConf;
     }
 
     @Override
@@ -54,7 +58,7 @@ public class FileClientImpl implements FileClient {
         form.add("file", arrayResource);
 
         HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<MultiValueMap<String, Object>>(form, headers);
-        ResponseEntity<JSONObject> responseEntity = restTemplate.postForEntity(FileClientConstant.FILE_UPLOAD, requestEntity, JSONObject.class);
+        ResponseEntity<JSONObject> responseEntity = restTemplate.postForEntity(sysConf.getUploadFileUrl() + FileClientConstant.FILE_UPLOAD, requestEntity, JSONObject.class);
         return responseEntity.getBody().getString("path");
     }
 
@@ -63,7 +67,7 @@ public class FileClientImpl implements FileClient {
         Map<String, Object> params = new HashMap<String, Object>();
         params.put("path", s);
         HttpHeaders headers = new HttpHeaders();
-        ResponseEntity<byte[]> response = restTemplate.exchange(FileClientConstant.FILE_DOWNLOAD, HttpMethod.GET,
+        ResponseEntity<byte[]> response = restTemplate.exchange(sysConf.getUploadFileUrl() + FileClientConstant.FILE_DOWNLOAD, HttpMethod.GET,
                 new HttpEntity<byte[]>(headers), byte[].class, params);
         return response.getBody();
     }
@@ -72,7 +76,7 @@ public class FileClientImpl implements FileClient {
     public void delete(String s) {
         Map<String, Object> params = new HashMap<String, Object>();
         params.put("path", s);
-        restTemplate.delete(FileClientConstant.FILE_DELETE, params);
+        restTemplate.delete(sysConf.getUploadFileUrl() + FileClientConstant.FILE_DELETE, params);
     }
 
     @Override

+ 19 - 19
src/main/java/com/uas/platform/b2c/common/search/constant/SearchUrl.java

@@ -10,109 +10,109 @@ public class SearchUrl {
     /**
      * 获取类目id
      */
-    public static final String KIND_ID_URL = "http://10.10.100.191:8092/search/kindIds/{keyword}";
+    public static final String KIND_ID_URL = "/search/kindIds/{keyword}";
 
     /**
      * 获取类目的数据
      *
      */
-    public static final String KIND_INFO_URL = "http://10.10.100.191:8092/search/kinds/{keyword}?page={page}&size={size}";
+    public static final String KIND_INFO_URL = "/search/kinds/{keyword}?page={page}&size={size}";
 
     /**
      * 搜索品牌的id
      */
-    public static final String BRAND_ID_URL = "http://10.10.100.191:8092/search/brandIds/{keyword}?page={page}&size={size}";
+    public static final String BRAND_ID_URL = "/search/brandIds/{keyword}?page={page}&size={size}";
 
     /**
      * 搜索品牌的具体信息
      */
-    public static final String BRAND_INFO_URL = "http://10.10.100.191:8092/search/brands/{keyword}?page={page}&size={size}";
+    public static final String BRAND_INFO_URL = "/search/brands/{keyword}?page={page}&size={size}";
 
 
     /**
      * 搜索器件的id
      */
-    public static final String COMPONENT_ID_URL = "http://10.10.100.191:8092/search/componentIds?keyword={keyword}&params={params}";
+    public static final String COMPONENT_ID_URL = "/search/componentIds?keyword={keyword}&params={params}";
 
     /**
      * 根据品牌id后去类目的id
      */
-    public static final String KIND_ID_COMPONENT_URL = "http://10.10.100.191:8092/search/kindIdsByComponent?keyword={keyword}&brandId={brandId}";
+    public static final String KIND_ID_COMPONENT_URL = "/search/kindIdsByComponent?keyword={keyword}&brandId={brandId}";
 
     /**
      * 根据品牌id后去类目信息
      */
-    public static final String KIND_COMPONENT_URL = "http://10.10.100.191:8092/search/kindsByComponent?keyword={keyword}&brandId={brandId}";
+    public static final String KIND_COMPONENT_URL = "/search/kindsByComponent?keyword={keyword}&brandId={brandId}";
 
     /**
      * 根据类目的id,获取品牌id信息
      */
-    public static final String BREAND_ID_COMPONENT_URL = "http://10.10.100.191:8092/search/brandIdsByComponent?keyword={keyword}&kindId={kindId}";
+    public static final String BREAND_ID_COMPONENT_URL = "/search/brandIdsByComponent?keyword={keyword}&kindId={kindId}";
 
 
     /**
      * 根据类目的id,获取品牌信息
      */
-    public static final String BREAND_COMPONENT_URL = "http://10.10.100.191:8092/search/brandsByComponent?keyword={keyword}&kindId={kindId}";
+    public static final String BREAND_COMPONENT_URL = "/search/brandsByComponent?keyword={keyword}&kindId={kindId}";
 
 
     /**
      * 根据关键字联想
      */
-    public static final String SIMILAR_KEYWORD_URL = "http://10.10.100.191:8092/search/similarKeywords/{keyword}";
+    public static final String SIMILAR_KEYWORD_URL = "/search/similarKeywords/{keyword}";
 
 
     /**
      * 根据关键字联想器件
      */
-    public static final String SIMILAR_COMPONENT_URL = "http://10.10.100.191:8092/search/similarComponents/{keyword}";
+    public static final String SIMILAR_COMPONENT_URL = "/search/similarComponents/{keyword}";
 
 
     /**
      * 根据关键字联想品牌
      */
-    public static final String SIMILAR_BRAND_URL = "http://10.10.100.191:8092/search/similarBrands/{keyword}";
+    public static final String SIMILAR_BRAND_URL = "/search/similarBrands/{keyword}";
 
 
     /**
      * 根据关键字联想类目
      */
-    public static final String SIMILAR_KIND_URL = "http://10.10.100.191:8092/search/similarKinds/{keyword}";
+    public static final String SIMILAR_KIND_URL = "/search/similarKinds/{keyword}";
 
 
 
     /**
      * 获取某个信息的叶子节点
      */
-    public static final String SIMILAR_LEAF_KIND_URL = "http://10.10.100.191:8092/search/similarLeafKinds/{keyword}";
+    public static final String SIMILAR_LEAF_KIND_URL = "/search/similarLeafKinds/{keyword}";
 
 
     /**
      * 获取类目的层级
      */
-    public static final String SIMILAR__KIND_LEVEL_URL = "http://10.10.100.191:8092/search/similarKindsByLevel?kindName={kindName}&level={level}";
+    public static final String SIMILAR__KIND_LEVEL_URL = "/search/similarKindsByLevel?kindName={kindName}&level={level}";
 
 
     /**
      * 属性值搜索
      */
-    public static final String PROPERTYVALUES_URL = "http://10.10.100.191:8092/search/similarPropertyValues?kindId={kindId}&propertyId={propertyId}&keyword={keyword}&topNum={topNum}";
+    public static final String PROPERTYVALUES_URL = "/search/similarPropertyValues?kindId={kindId}&propertyId={propertyId}&keyword={keyword}&topNum={topNum}";
 
 
     /**
      * 搜索库存信息
      */
-    public static final String GOODIS_URL= "http://10.10.100.191:8092/search/goodsIds?keyword={keyword}&params={params}";
+    public static final String GOODIS_URL= "/search/goodsIds?keyword={keyword}&params={params}";
 
 
     /**
      * 搜索库存
      */
-    public static final String GOODS_COLLECT_URL= "http://10.10.100.191:8092/search/collectBySearchGoods?keyword={keyword}&collectedField={collectedField}&filters={filters}";
+    public static final String GOODS_COLLECT_URL= "/search/collectBySearchGoods?keyword={keyword}&collectedField={collectedField}&filters={filters}";
 
     /**
      * 搜索订单
      */
-    public static final String ORDER_SEARCH_URL = "http://10.10.100.191:8092/search/orderIds?tableName={tableName}&keyword={keyword}&page={page}&size={size}&status={status}&buyeruu={buyeruu}&buyerenuu={buyerenuu}&sellerenuu={sellerenuu}&mintime={mintime}&maxtime={maxtime}";
+    public static final String ORDER_SEARCH_URL = "/search/orderIds?tableName={tableName}&keyword={keyword}&page={page}&size={size}&status={status}&buyeruu={buyeruu}&buyerenuu={buyerenuu}&sellerenuu={sellerenuu}&mintime={mintime}&maxtime={maxtime}";
 
 }

+ 23 - 19
src/main/java/com/uas/platform/b2c/common/search/rpc/service/Impl/SearchServiceImpl.java

@@ -3,6 +3,7 @@ package com.uas.platform.b2c.common.search.rpc.service.Impl;
 
 import com.uas.platform.b2c.common.search.constant.SearchUrl;
 import com.uas.platform.b2c.common.search.rpc.service.SearchService;
+import com.uas.platform.b2c.core.config.SysConf;
 import com.uas.platform.b2c.core.utils.FastjsonUtils;
 import com.uas.platform.core.util.serializer.FlexJsonUtils;
 import com.uas.search.exception.SearchException;
@@ -29,15 +30,18 @@ public class SearchServiceImpl implements SearchService{
 
     private final RestTemplate restTemplate;
 
+    private final SysConf sysConf;
+
     @Autowired
-    public SearchServiceImpl(RestTemplate restTemplate) {
+    public SearchServiceImpl(RestTemplate restTemplate, SysConf sysConf) {
         this.restTemplate = restTemplate;
+        this.sysConf = sysConf;
     }
 
     @Override
     public SPage<Long> getKindIds(String keyword, Integer page, Integer size) throws SearchException {
         Map<String, Object> map = initSearchMap(keyword, page, size);
-        String str = restTemplate.getForObject(SearchUrl.KIND_ID_URL, String.class, map);
+        String str = restTemplate.getForObject(sysConf.getSearchUrl() + SearchUrl.KIND_ID_URL, String.class, map);
         if(StringUtils.isEmpty(str)) {
             return null;
         }else {
@@ -54,7 +58,7 @@ public class SearchServiceImpl implements SearchService{
     @Override
     public SPage<Map<String, Object>> getKinds(String keyword, Integer page, Integer size) throws SearchException {
         Map<String, Object> map = initSearchMap(keyword, page, size);
-        String str = restTemplate.getForObject(SearchUrl.KIND_INFO_URL, String.class, map);
+        String str = restTemplate.getForObject(sysConf.getSearchUrl() + SearchUrl.KIND_INFO_URL, String.class, map);
         if(StringUtils.isEmpty(str)) {
             return null;
         }else {
@@ -71,7 +75,7 @@ public class SearchServiceImpl implements SearchService{
     @Override
     public SPage<Long> getBrandIds(String keyword, Integer page, Integer size) throws SearchException {
         Map<String, Object> map = initSearchMap(keyword, page, size);
-        String str = restTemplate.getForObject(SearchUrl.BRAND_ID_URL, String.class, map);
+        String str = restTemplate.getForObject(sysConf.getSearchUrl() + SearchUrl.BRAND_ID_URL, String.class, map);
         if(StringUtils.isEmpty(str)) {
             return null;
         }else {
@@ -89,7 +93,7 @@ public class SearchServiceImpl implements SearchService{
     @Override
     public SPage<Map<String, List<Integer>>> getBrands(String keyword, Integer page, Integer size) throws SearchException {
         Map<String, Object> map = initSearchMap(keyword, page, size);
-        String str = restTemplate.getForObject(SearchUrl.BRAND_INFO_URL, String.class, map);
+        String str = restTemplate.getForObject(sysConf.getSearchUrl() + SearchUrl.BRAND_INFO_URL, String.class, map);
         if(StringUtils.isEmpty(str)) {
             return null;
         }else {
@@ -108,7 +112,7 @@ public class SearchServiceImpl implements SearchService{
         Map<String, Object> map = new HashedMap();
         map.put("keyword", keyword);
         map.put("params", FlexJsonUtils.toJsonDeep(var2));
-        String str = restTemplate.getForObject(SearchUrl.COMPONENT_ID_URL, String.class, map);
+        String str = restTemplate.getForObject(sysConf.getSearchUrl() + SearchUrl.COMPONENT_ID_URL, String.class, map);
         if(StringUtils.isEmpty(str)) {
             return null;
         }else {
@@ -127,7 +131,7 @@ public class SearchServiceImpl implements SearchService{
         Map<String, Object> map = new HashedMap();
         map.put("keyword", keyword);
         map.put("brandId", brandId);
-        String str = restTemplate.getForObject(SearchUrl.KIND_ID_COMPONENT_URL, String.class, map);
+        String str = restTemplate.getForObject(sysConf.getSearchUrl() + SearchUrl.KIND_ID_COMPONENT_URL, String.class, map);
         if(StringUtils.isEmpty(str)) {
             return null;
         }else {
@@ -146,7 +150,7 @@ public class SearchServiceImpl implements SearchService{
         Map<String, Object> map = new HashedMap();
         map.put("keyword", keyword);
         map.put("brandId", brandId);
-        String str = restTemplate.getForObject(SearchUrl.KIND_COMPONENT_URL, String.class, map);
+        String str = restTemplate.getForObject(sysConf.getSearchUrl() + SearchUrl.KIND_COMPONENT_URL, String.class, map);
         if(StringUtils.isEmpty(str)) {
             return null;
         }else {
@@ -165,7 +169,7 @@ public class SearchServiceImpl implements SearchService{
         Map<String, Object> map = new HashedMap();
         map.put("keyword", keyword);
         map.put("kindId", kindId);
-        String str = restTemplate.getForObject(SearchUrl.BREAND_ID_COMPONENT_URL, String.class, map);
+        String str = restTemplate.getForObject(sysConf.getSearchUrl() + SearchUrl.BREAND_ID_COMPONENT_URL, String.class, map);
         if(StringUtils.isEmpty(str)) {
             return null;
         }else {
@@ -184,7 +188,7 @@ public class SearchServiceImpl implements SearchService{
         Map<String, Object> map = new HashedMap();
         map.put("keyword", keyword);
         map.put("kindId", kindId);
-        String str = restTemplate.getForObject(SearchUrl.BREAND_COMPONENT_URL, String.class, map);
+        String str = restTemplate.getForObject(sysConf.getSearchUrl() + SearchUrl.BREAND_COMPONENT_URL, String.class, map);
         if(StringUtils.isEmpty(str)) {
             return null;
         }else {
@@ -202,7 +206,7 @@ public class SearchServiceImpl implements SearchService{
     public List<String> getSimilarKeywords(String keyword) throws SearchException {
         Map<String, Object> map = new HashedMap();
         map.put("keyword", keyword);
-        String str = restTemplate.getForObject(SearchUrl.SIMILAR_KEYWORD_URL, String.class, map);
+        String str = restTemplate.getForObject(sysConf.getSearchUrl() + SearchUrl.SIMILAR_KEYWORD_URL, String.class, map);
         if(StringUtils.isEmpty(str)) {
             return null;
         }else {
@@ -220,7 +224,7 @@ public class SearchServiceImpl implements SearchService{
     public List<Map<String, Object>> getSimilarComponents(String keyword) throws SearchException {
         Map<String, Object> map = new HashedMap();
         map.put("keyword", keyword);
-        String str = restTemplate.getForObject(SearchUrl.SIMILAR_COMPONENT_URL, String.class, map);
+        String str = restTemplate.getForObject(sysConf.getSearchUrl() + SearchUrl.SIMILAR_COMPONENT_URL, String.class, map);
         if(StringUtils.isEmpty(str)) {
             return null;
         }else {
@@ -238,7 +242,7 @@ public class SearchServiceImpl implements SearchService{
     public List<Map<String, Object>> getSimilarBrands(String keyword) throws SearchException {
         Map<String, Object> map = new HashedMap();
         map.put("keyword", keyword);
-        String str = restTemplate.getForObject(SearchUrl.SIMILAR_BRAND_URL, String.class, map);
+        String str = restTemplate.getForObject(sysConf.getSearchUrl() + SearchUrl.SIMILAR_BRAND_URL, String.class, map);
         if(StringUtils.isEmpty(str)) {
             return null;
         }else {
@@ -256,7 +260,7 @@ public class SearchServiceImpl implements SearchService{
     public List<Map<String, Object>> getSimilarKinds(String keyword) throws SearchException {
         Map<String, Object> map = new HashedMap();
         map.put("keyword", keyword);
-        String str = restTemplate.getForObject(SearchUrl.SIMILAR_KIND_URL, String.class, map);
+        String str = restTemplate.getForObject(sysConf.getSearchUrl() + SearchUrl.SIMILAR_KIND_URL, String.class, map);
         if(StringUtils.isEmpty(str)) {
             return null;
         }else {
@@ -274,7 +278,7 @@ public class SearchServiceImpl implements SearchService{
     public List<Map<String, Object>> getSimilarLeafKinds(String keyword) throws SearchException {
         Map<String, Object> map = new HashedMap();
         map.put("keyword", keyword);
-        String str = restTemplate.getForObject(SearchUrl.SIMILAR_LEAF_KIND_URL, String.class, map);
+        String str = restTemplate.getForObject(sysConf.getSearchUrl() + SearchUrl.SIMILAR_LEAF_KIND_URL, String.class, map);
         if(StringUtils.isEmpty(str)) {
             return null;
         }else {
@@ -293,7 +297,7 @@ public class SearchServiceImpl implements SearchService{
         Map<String, Object> map = new HashedMap();
         map.put("kindName", kindName);
         map.put("level", level);
-        String str = restTemplate.getForObject(SearchUrl.SIMILAR__KIND_LEVEL_URL, String.class, map);
+        String str = restTemplate.getForObject(sysConf.getSearchUrl() + SearchUrl.SIMILAR__KIND_LEVEL_URL, String.class, map);
         if(StringUtils.isEmpty(str)) {
             return null;
         }else {
@@ -314,7 +318,7 @@ public class SearchServiceImpl implements SearchService{
         map.put("propertyId", propertyId);
         map.put("keyword", keyword);
         map.put("topNum", topNum);
-        String str = restTemplate.getForObject(SearchUrl.PROPERTYVALUES_URL, String.class, map);
+        String str = restTemplate.getForObject(sysConf.getSearchUrl() + SearchUrl.PROPERTYVALUES_URL, String.class, map);
         if(StringUtils.isEmpty(str)) {
             return null;
         }else {
@@ -333,7 +337,7 @@ public class SearchServiceImpl implements SearchService{
         Map<String, Object> map = new HashedMap();
         map.put("keyword", keyword);
         map.put("params", FlexJsonUtils.toJsonDeep(var2));
-        String str = restTemplate.getForObject(SearchUrl.GOODIS_URL, String.class, map);
+        String str = restTemplate.getForObject(sysConf.getSearchUrl() + SearchUrl.GOODIS_URL, String.class, map);
         if(StringUtils.isEmpty(str)) {
             return null;
         }else {
@@ -353,7 +357,7 @@ public class SearchServiceImpl implements SearchService{
         map.put("keyword", keyword);
         map.put("collectedField", collectField);
         map.put("filters", FastjsonUtils.toJson(filters));
-        String str = restTemplate.getForObject(SearchUrl.GOODS_COLLECT_URL, String.class, map);
+        String str = restTemplate.getForObject(sysConf.getSearchUrl() + SearchUrl.GOODS_COLLECT_URL, String.class, map);
         if(StringUtils.isEmpty(str)) {
             return null;
         }else {

+ 30 - 0
src/main/java/com/uas/platform/b2c/core/config/SysConf.java

@@ -130,6 +130,18 @@ public class SysConf {
 	@Value("#{sys.reportUploadUrl}")
 	private String reportUploadUrl;
 
+	/**
+	 * 文件上传的地址
+	 */
+	@Value("#{sys.uploadFileUrl}")
+	private String uploadFileUrl;
+
+	/**
+	 * 搜索的地址
+	 */
+	@Value("#{sys.searchUrl}")
+	private String searchUrl;
+
 	public Boolean getRebuildIndexesOnRefresh() {
 		return rebuildIndexesOnRefresh;
 	}
@@ -275,4 +287,22 @@ public class SysConf {
 		this.adminName = adminName;
 		return this;
 	}
+
+	public String getUploadFileUrl() {
+		return uploadFileUrl;
+	}
+
+	public SysConf setUploadFileUrl(String uploadFileUrl) {
+		this.uploadFileUrl = uploadFileUrl;
+		return this;
+	}
+
+	public String getSearchUrl() {
+		return searchUrl;
+	}
+
+	public SysConf setSearchUrl(String searchUrl) {
+		this.searchUrl = searchUrl;
+		return this;
+	}
 }

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

@@ -27,6 +27,10 @@ newsMicroServiceIp=news.usoftchina.com
 newsRedisRefresh=3600
 endpointUri=10.10.101.23
 recommendPort=20102
+# upload file
+uploadFileUrl = http://10.10.100.200:9999
+# search file
+searchUrl = http://10.10.100.191:8092
 
 # Kafka
 kafka-bootstrap-servers=10.10.100.11:9292,10.10.100.12:9292,10.10.100.13:9292,10.10.100.14:9292,10.10.100.15:9292,10.10.100.16:9292

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

@@ -28,6 +28,9 @@ newsMicroServiceIp=news.usoftchina.com
 newsRedisRefresh=3600
 endpointUri=10.10.100.23
 recommendPort=20100
-
+# upload file
+uploadFileUrl = http://10.10.0.254:8080
+# search file
+searchUrl = http://10.10.0.76:8081
 # Kafka
 kafka-bootstrap-servers=10.10.100.11:9292,10.10.100.12:9292,10.10.100.13:9292,10.10.100.14:9292,10.10.100.15:9292,10.10.100.16:9292

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

@@ -27,6 +27,10 @@ newsMicroServiceIp=news.usoftchina.com
 newsRedisRefresh=3600
 endpointUri=10.10.101.23
 recommendPort=20102
+# upload file
+uploadFileUrl = http://10.10.100.200:9999
+# search file
+searchUrl = http://10.10.100.191:8092
 
 # Kafka
 kafka-bootstrap-servers=10.10.100.11:9292,10.10.100.12:9292,10.10.100.13:9292,10.10.100.14:9292,10.10.100.15:9292,10.10.100.16:9292