|
@@ -1,19 +1,22 @@
|
|
|
package com.tzld.piaoquan.recommend.server.web;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.google.protobuf.InvalidProtocolBufferException;
|
|
|
import com.tzld.piaoquan.recommend.server.client.ProtobufUtils;
|
|
|
+import com.tzld.piaoquan.recommend.server.common.base.RankItem;
|
|
|
import com.tzld.piaoquan.recommend.server.gen.recommend.RecommendRequest;
|
|
|
import com.tzld.piaoquan.recommend.server.gen.recommend.RecommendResponse;
|
|
|
+import com.tzld.piaoquan.recommend.server.implement.TopRecommendPipeline;
|
|
|
import com.tzld.piaoquan.recommend.server.service.RecommendService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.slf4j.MDC;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.context.annotation.Bean;
|
|
|
-import org.springframework.http.converter.protobuf.ProtobufHttpMessageConverter;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
/**
|
|
|
* @author dyp
|
|
|
*/
|
|
@@ -49,4 +52,19 @@ public class RecommendV2Controller {
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+ @RequestMapping("/test/feedByRec")
|
|
|
+ public String feedByRec(@RequestBody RecommendRequest httpRequest) {
|
|
|
+ MDC.put("appType", String.valueOf(httpRequest.getAppType()));
|
|
|
+
|
|
|
+ TopRecommendPipeline topRecommendPipeline = new TopRecommendPipeline();
|
|
|
+ List<RankItem> rankItems = topRecommendPipeline.feedByRec(httpRequest, 0, null);
|
|
|
+ String result = "";
|
|
|
+ try {
|
|
|
+ result = JSONObject.toJSONString(rankItems);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("feedByRec ProtobufUtils.toJson", e);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|