|  | @@ -1,12 +1,19 @@
 | 
	
		
			
				|  |  |  package com.tzld.longarticle.recommend.server.remote;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +import com.alibaba.fastjson.JSONArray;
 | 
	
		
			
				|  |  | +import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  |  import com.tzld.longarticle.recommend.server.common.HttpPoolFactory;
 | 
	
		
			
				|  |  |  import com.tzld.longarticle.recommend.server.model.Content;
 | 
	
		
			
				|  |  | +import com.tzld.longarticle.recommend.server.service.recall.RecallParam;
 | 
	
		
			
				|  |  |  import lombok.extern.slf4j.Slf4j;
 | 
	
		
			
				|  |  | +import org.apache.http.StatusLine;
 | 
	
		
			
				|  |  | +import org.apache.http.client.methods.CloseableHttpResponse;
 | 
	
		
			
				|  |  | +import org.apache.http.client.methods.HttpPost;
 | 
	
		
			
				|  |  | +import org.apache.http.entity.StringEntity;
 | 
	
		
			
				|  |  |  import org.apache.http.impl.client.CloseableHttpClient;
 | 
	
		
			
				|  |  |  import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -import java.util.Collections;
 | 
	
		
			
				|  |  | +import java.util.ArrayList;
 | 
	
		
			
				|  |  |  import java.util.List;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
	
		
			
				|  | @@ -16,14 +23,40 @@ import java.util.List;
 | 
	
		
			
				|  |  |  @Slf4j
 | 
	
		
			
				|  |  |  public class AIGCRemoteService {
 | 
	
		
			
				|  |  |      private final CloseableHttpClient client = HttpPoolFactory.defaultPool();
 | 
	
		
			
				|  |  | -    private String aigcGetAllContentUrl;
 | 
	
		
			
				|  |  | +    private static final String aigcGetAllContentUrl = "http://aigc-api.cybertogether.net/aigc/publish/content/gzhWaitingPublishContent";
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      // TODO 如果过滤失败,那么认为所有视频都被过滤掉
 | 
	
		
			
				|  |  | -    public List<Content> getAllContent() {
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        // 调用AIGC
 | 
	
		
			
				|  |  | -        return Collections.emptyList();
 | 
	
		
			
				|  |  | +    public List<Content> getAllContent(RecallParam param) {
 | 
	
		
			
				|  |  | +        long start = System.currentTimeMillis();
 | 
	
		
			
				|  |  | +        List<Content> result = new ArrayList<>();
 | 
	
		
			
				|  |  | +        JSONObject bodyParam = new JSONObject();
 | 
	
		
			
				|  |  | +        JSONObject bodyParamParams = new JSONObject();
 | 
	
		
			
				|  |  | +        bodyParamParams.put("accountId", param.getAccountId());
 | 
	
		
			
				|  |  | +        bodyParamParams.put("planId", param.getPlanId());
 | 
	
		
			
				|  |  | +        bodyParam.put("params", bodyParamParams);
 | 
	
		
			
				|  |  | +        try {
 | 
	
		
			
				|  |  | +            HttpPost httpPost = new HttpPost(aigcGetAllContentUrl);
 | 
	
		
			
				|  |  | +            StringEntity stringEntity = new StringEntity(bodyParam.toJSONString());
 | 
	
		
			
				|  |  | +            stringEntity.setContentType("application/json");
 | 
	
		
			
				|  |  | +            stringEntity.setContentEncoding("UTF-8");
 | 
	
		
			
				|  |  | +            httpPost.setEntity(stringEntity);
 | 
	
		
			
				|  |  | +            CloseableHttpResponse response22 = client.execute(httpPost);
 | 
	
		
			
				|  |  | +            StatusLine statusLine = response22.getStatusLine();
 | 
	
		
			
				|  |  | +            if (statusLine.getStatusCode() == 200) {
 | 
	
		
			
				|  |  | +                String responseBody = response22.getEntity().getContent().toString();
 | 
	
		
			
				|  |  | +                log.info("getAllContent AIGC返回的数据:{}", responseBody);
 | 
	
		
			
				|  |  | +                JSONObject jsonObject = JSONObject.parseObject(responseBody);
 | 
	
		
			
				|  |  | +                if (jsonObject.getInteger("code") == 0) {
 | 
	
		
			
				|  |  | +                    JSONArray data = jsonObject.getJSONArray("data");
 | 
	
		
			
				|  |  | +                    result.addAll(JSONArray.parseArray(data.toJSONString(), Content.class));
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        } catch (Exception e) {
 | 
	
		
			
				|  |  | +            log.error("getAllContent error", e);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        log.info("getAllContent耗时:{}", System.currentTimeMillis() - start);
 | 
	
		
			
				|  |  | +        return result;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  }
 |