Authored by hugufei

添加yoho-core-rest-client-simple的依赖

... ... @@ -12,6 +12,10 @@
<dependencies>
<dependency>
<groupId>com.yoho.core</groupId>
<artifactId>yoho-core-rest-client-simple</artifactId>
</dependency>
<dependency>
<groupId>com.yoho.search</groupId>
<artifactId>search-es</artifactId>
</dependency>
... ...
package com.yoho.search.recall.scene.beans.persional;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yoho.core.rest.client.ServiceCaller;
import com.yoho.search.core.personalized.models.SortPriceArea;
import com.yoho.search.core.personalized.models.UserPersonalFactorReq;
import com.yoho.search.core.personalized.models.UserPersonalFactorRsp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
... ... @@ -16,12 +21,10 @@ class UserPersionalFactorComponent {
private static final Logger RECALL_NEW_LOGGER = LoggerFactory.getLogger("RECALL");
// @Autowired
// private ServiceCaller serviceCaller;
@Autowired
private ServiceCaller serviceCaller;
//serviceCaller.asyncCall("message.publishIosUser", iosTokenBO, Integer.class);
private static final String SERVICE_NAME = "bigdata.userPersionalFactorRsp";
private static final String SERVICE_NAME = "bigdata.searchPersonalFactors";
private static final int timeOut = 100;
/**
... ... @@ -51,21 +54,20 @@ class UserPersionalFactorComponent {
}
private UserPersonalFactorRsp queryUserPersionalFactorRsp(int uid, String udid){
// try {
// UserPersonalFactorReq userPersionalFactorReq = new UserPersonalFactorReq(uid,udid);
// JSONObject result = serviceCaller.call(SERVICE_NAME,userPersionalFactorReq,JSONObject.class,timeOut);
// RECALL_NEW_LOGGER.info("UserPersionalFactorComponent.result is[{}]",result.toJSONString());
// JSONObject userPersonalFactorRspJSon = result.getJSONObject("data");
// UserPersonalFactorRsp rsp = JSON.toJavaObject(userPersonalFactorRspJSon,UserPersonalFactorRsp.class);
// if(rsp==null ||rsp.getBrandIds()==null || rsp.getSortPriceAreas()==null){
// RECALL_NEW_LOGGER.error("query bigdata fail, result is [{}]",result.toJSONString());
// return null;
// }
// return rsp;
// }catch (Exception e){
// logger.error(e.getMessage(),e);
// return null;
// }
try {
UserPersonalFactorReq userPersionalFactorReq = new UserPersonalFactorReq(uid,udid);
JSONObject result = serviceCaller.call(SERVICE_NAME,userPersionalFactorReq,JSONObject.class,timeOut);
RECALL_NEW_LOGGER.info("UserPersionalFactorComponent.result is[{}]",result.toJSONString());
JSONObject userPersonalFactorRspJSon = result.getJSONObject("data");
UserPersonalFactorRsp rsp = JSON.toJavaObject(userPersonalFactorRspJSon,UserPersonalFactorRsp.class);
if(rsp==null ||rsp.getBrandIds()==null || rsp.getSortPriceAreas()==null){
RECALL_NEW_LOGGER.error("query bigdata fail, result is [{}]",result.toJSONString());
return null;
}
return rsp;
}catch (Exception e){
logger.error(e.getMessage(),e);
return null;
}
}
}
... ...