Selaa lähdekoodia

调整推荐位逻辑

tianboguang 3 vuotta sitten
vanhempi
commit
043e4afbb4

+ 4 - 7
platform-api/src/main/java/com/platform/api/ApiBrandController.java

@@ -1,7 +1,6 @@
 package com.platform.api;
 
 import com.alibaba.fastjson.JSONObject;
-import com.github.pagehelper.PageInfo;
 import com.platform.annotation.IgnoreAuth;
 import com.platform.entity.*;
 import com.platform.interceptor.AuthorizationInterceptor;
@@ -119,13 +118,11 @@ public class ApiBrandController extends ApiBaseAction {
             case 11:
             case 12:
             case 13:
-                params.put("type",type);
-                Query query = new Query(params);
-                List<BrandVo> list = recommendService.queryList(query).parallelStream().map(entity->{
+                List<BrandVo> list = zhiHouseService.queryRecomendsByType(type).parallelStream().map(entity->{
                     BrandVo vo = new BrandVo();
-                    vo.setName(entity.getTitle());
-                    vo.setId(entity.getConnectId().intValue());
-                    vo.setAppListPicUrl(entity.getImage());
+                    vo.setName(entity.getString("title"));
+                    vo.setId(entity.getInteger("connectId"));
+                    vo.setAppListPicUrl(entity.getString("image"));
                     return vo;
                 }).collect(Collectors.toList());
                 return toResponsSuccess(new ApiPageUtils(list, 3, 3, 1));

+ 16 - 0
platform-common/src/main/java/com/platform/service/impl/ZhiHouseService.java

@@ -17,6 +17,7 @@ import org.springframework.util.CollectionUtils;
 import org.springframework.util.ObjectUtils;
 import org.springframework.web.client.RestTemplate;
 
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -299,4 +300,19 @@ public class ZhiHouseService {
         List<String> list = (List<String>) responseEntity.getBody().getMessage();
         return list;
     }
+
+    public Collection<JSONObject> queryRecomendsByType(Integer type){
+        Map<String, Object> mp = new HashMap<>();
+        mp.put("type", type);
+        String url = zhiHouseHost + "recommend/selectByType";
+        ResponseEntity<ReturnDTO>  responseEntity = restTemplate.postForEntity(url, mp,ReturnDTO.class);
+        if(responseEntity.getStatusCode()!= HttpStatus.OK){
+            throw new CommonBaseException(ResultCodeEnum.D100);
+        }
+        if (responseEntity.getBody().getCode() != 200) {
+            throw new CommonBaseException(ResultCodeEnum.D100,responseEntity.getBody().getError());
+        }
+        List<JSONObject> message = JSONArray.parseArray(JSONArray.toJSONString(responseEntity.getBody().getMessage()),JSONObject.class);
+        return message;
+    }
 }