|
|
@@ -0,0 +1,43 @@
|
|
|
+package com.tzld.piaoquan.longarticle.service.remote.impl;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.tzld.piaoquan.longarticle.model.dto.RecallVideoScoreParam;
|
|
|
+import com.tzld.piaoquan.longarticle.model.dto.RecallVideoScoreVO;
|
|
|
+import com.tzld.piaoquan.longarticle.service.remote.VideoVectorService;
|
|
|
+import com.tzld.piaoquan.longarticle.utils.HttpClientUtil;
|
|
|
+import com.tzld.piaoquan.longarticle.utils.HttpPoolClientUtil;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+public class VideoVectorServiceImpl implements VideoVectorService {
|
|
|
+
|
|
|
+ private static final HttpPoolClientUtil HTTP_CLIENT = HttpClientUtil.create(3000, 6000, 20, 100, 3, 3000);
|
|
|
+
|
|
|
+ @Value("${video.vector.api.host:http://api-internal.piaoquantv.com/videoVector}")
|
|
|
+ private String videoVectorApiHost;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public RecallVideoScoreVO recallWithScore(RecallVideoScoreParam param) {
|
|
|
+ String apiUrl = videoVectorApiHost + "/recallWithScore";
|
|
|
+ try {
|
|
|
+ log.info("recallWithScore request={}", JSON.toJSONString(param));
|
|
|
+ String res = HTTP_CLIENT.post(apiUrl, JSON.toJSONString(param));
|
|
|
+ JSONObject jsonObject = JSON.parseObject(res);
|
|
|
+ log.info("recallWithScore res code={}, msg={}", jsonObject.getInteger("code"), jsonObject.getString("msg"));
|
|
|
+
|
|
|
+ if (jsonObject.getInteger("code") != null && jsonObject.getInteger("code") == 0) {
|
|
|
+ JSONObject dataJson = jsonObject.getJSONObject("data");
|
|
|
+ if (dataJson != null) {
|
|
|
+ return dataJson.toJavaObject(RecallVideoScoreVO.class);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("recallWithScore error, param={}", JSON.toJSONString(param), e);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+}
|