|
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.tzld.piaoquan.wecom.common.base.CommonResponse;
|
|
import com.tzld.piaoquan.wecom.common.base.CommonResponse;
|
|
import com.tzld.piaoquan.wecom.common.enums.MessageAttachmentTypeEnum;
|
|
import com.tzld.piaoquan.wecom.common.enums.MessageAttachmentTypeEnum;
|
|
|
|
+import com.tzld.piaoquan.wecom.component.HttpPoolClient;
|
|
import com.tzld.piaoquan.wecom.dao.mapper.MessageAttachmentMapper;
|
|
import com.tzld.piaoquan.wecom.dao.mapper.MessageAttachmentMapper;
|
|
import com.tzld.piaoquan.wecom.model.bo.AdPutFlowParam;
|
|
import com.tzld.piaoquan.wecom.model.bo.AdPutFlowParam;
|
|
import com.tzld.piaoquan.wecom.model.bo.VideoDetail;
|
|
import com.tzld.piaoquan.wecom.model.bo.VideoDetail;
|
|
@@ -16,7 +17,6 @@ import com.tzld.piaoquan.wecom.service.AccessTokenService;
|
|
import com.tzld.piaoquan.wecom.service.MessageAttachmentService;
|
|
import com.tzld.piaoquan.wecom.service.MessageAttachmentService;
|
|
import com.tzld.piaoquan.wecom.utils.DateUtil;
|
|
import com.tzld.piaoquan.wecom.utils.DateUtil;
|
|
import com.tzld.piaoquan.wecom.utils.HttpClientUtil;
|
|
import com.tzld.piaoquan.wecom.utils.HttpClientUtil;
|
|
-import com.tzld.piaoquan.wecom.utils.HttpPoolClient;
|
|
|
|
import com.tzld.piaoquan.wecom.utils.LarkRobotUtil;
|
|
import com.tzld.piaoquan.wecom.utils.LarkRobotUtil;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -48,8 +48,8 @@ import static com.tzld.piaoquan.wecom.common.constant.WeComConstant.POST_WE_COM_
|
|
@Service
|
|
@Service
|
|
public class MessageAttachmentServiceImpl implements MessageAttachmentService {
|
|
public class MessageAttachmentServiceImpl implements MessageAttachmentService {
|
|
|
|
|
|
- private static final HttpPoolClient httpPoolClientDefault = HttpClientUtil.create(30000, 30000, 2000, 5000, 5, 30000);
|
|
|
|
-
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private HttpPoolClient httpPoolClient;
|
|
@Autowired
|
|
@Autowired
|
|
private AccessTokenService accessTokenService;
|
|
private AccessTokenService accessTokenService;
|
|
|
|
|
|
@@ -119,7 +119,7 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
|
|
Map<Long, VideoDetail> map = new HashMap<>();
|
|
Map<Long, VideoDetail> map = new HashMap<>();
|
|
JSONObject params = new JSONObject();
|
|
JSONObject params = new JSONObject();
|
|
params.put("videoIdList", videoIdList);
|
|
params.put("videoIdList", videoIdList);
|
|
- String post = httpPoolClientDefault.post(POST_VIDEO_DETAIL_URL, params.toJSONString());
|
|
|
|
|
|
+ String post = httpPoolClient.post(POST_VIDEO_DETAIL_URL, params.toJSONString());
|
|
JSONObject res = JSONObject.parseObject(post);
|
|
JSONObject res = JSONObject.parseObject(post);
|
|
JSONArray data = res.getJSONArray("data");
|
|
JSONArray data = res.getJSONArray("data");
|
|
for (int i = 0; i < data.size(); i++) {
|
|
for (int i = 0; i < data.size(); i++) {
|
|
@@ -164,7 +164,7 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
|
|
File file = new java.io.File(filePath);
|
|
File file = new java.io.File(filePath);
|
|
String weComAccessToken = accessTokenService.getWeComAccessToken();
|
|
String weComAccessToken = accessTokenService.getWeComAccessToken();
|
|
String url = String.format(POST_WE_COM_MEDIA_UPLOAD + "?access_token=%s&type=%s", weComAccessToken, "image");
|
|
String url = String.format(POST_WE_COM_MEDIA_UPLOAD + "?access_token=%s&type=%s", weComAccessToken, "image");
|
|
- String res = httpPoolClientDefault.post(url, file);
|
|
|
|
|
|
+ String res = httpPoolClient.post(url, file);
|
|
JSONObject jsonObject = JSONObject.parseObject(res);
|
|
JSONObject jsonObject = JSONObject.parseObject(res);
|
|
if (jsonObject != null && jsonObject.getInteger("errcode") == 0) {
|
|
if (jsonObject != null && jsonObject.getInteger("errcode") == 0) {
|
|
mediaId = jsonObject.getString("media_id");
|
|
mediaId = jsonObject.getString("media_id");
|
|
@@ -213,7 +213,7 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
|
|
.replace("${uuid}", "" + UUID.randomUUID());
|
|
.replace("${uuid}", "" + UUID.randomUUID());
|
|
requestParam.put("jumpPage", jumpPage);
|
|
requestParam.put("jumpPage", jumpPage);
|
|
param.setRequestParam(requestParam);
|
|
param.setRequestParam(requestParam);
|
|
- String res = httpPoolClientDefault.post(POST_ADD_TENCENT, JSONObject.toJSONString(param));
|
|
|
|
|
|
+ String res = httpPoolClient.post(POST_ADD_TENCENT, JSONObject.toJSONString(param));
|
|
JSONObject jsonObject = JSONObject.parseObject(res);
|
|
JSONObject jsonObject = JSONObject.parseObject(res);
|
|
JSONObject data = jsonObject.getJSONObject("data");
|
|
JSONObject data = jsonObject.getJSONObject("data");
|
|
return data.getString("url");
|
|
return data.getString("url");
|
|
@@ -224,7 +224,7 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
|
|
for (int n = 1; n <= totalPage; n++) {
|
|
for (int n = 1; n <= totalPage; n++) {
|
|
String url = getUrl(videoId, n);
|
|
String url = getUrl(videoId, n);
|
|
try {
|
|
try {
|
|
- String res = httpPoolClientDefault.get(url);
|
|
|
|
|
|
+ String res = httpPoolClient.get(url);
|
|
JSONObject jsonObject = JSONObject.parseObject(res);
|
|
JSONObject jsonObject = JSONObject.parseObject(res);
|
|
JSONObject data = jsonObject.getJSONObject("data");
|
|
JSONObject data = jsonObject.getJSONObject("data");
|
|
if (data == null) {
|
|
if (data == null) {
|