|
@@ -48,6 +48,7 @@ import static com.tzld.piaoquan.growth.common.common.constant.OtherServerURL.POS
|
|
|
import static com.tzld.piaoquan.growth.common.common.constant.OtherServerURL.POST_VIDEO_DETAIL_URL;
|
|
|
import static com.tzld.piaoquan.growth.common.common.constant.TimeConstant.MILLISECOND_DAY;
|
|
|
import static com.tzld.piaoquan.growth.common.common.constant.WeComConstant.POST_WE_COM_MEDIA_UPLOAD;
|
|
|
+import static com.tzld.piaoquan.growth.common.common.constant.WeComConstant.POST_WE_COM_MEDIA_UPLOAD_ATTACHMENT;
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
@@ -507,7 +508,7 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public CommonResponse<Long> createAttachment(Integer type, MultipartFile file, String url, String picUrl, String page, String title, String desc, String appId) {
|
|
|
+ public CommonResponse<Long> createAttachment(Integer type, MultipartFile file, String url, String picUrl, String page, String title, String desc, String appId, Integer extType) {
|
|
|
if (type == null) {
|
|
|
return CommonResponse.create(500, "附件类型不能为空");
|
|
|
}
|
|
@@ -521,7 +522,7 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
|
|
|
if (file == null || file.isEmpty()) {
|
|
|
return CommonResponse.create(500, "封面文件不能为空");
|
|
|
}
|
|
|
- String mediaId = uploadFile(file, "image");
|
|
|
+ String mediaId = uploadFile(file, "image", extType);
|
|
|
if (StringUtils.isEmpty(mediaId)) {
|
|
|
return CommonResponse.create(500, "封面上传失败");
|
|
|
}
|
|
@@ -566,7 +567,7 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
|
|
|
if (file == null || file.isEmpty()) {
|
|
|
return CommonResponse.create(500, "图片不能为空");
|
|
|
}
|
|
|
- String mediaId = uploadFile(file, "image");
|
|
|
+ String mediaId = uploadFile(file, "image", extType);
|
|
|
if (StringUtils.isEmpty(mediaId)) {
|
|
|
return CommonResponse.create(500, "图片上传失败");
|
|
|
}
|
|
@@ -581,7 +582,7 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
|
|
|
if (file == null || file.isEmpty()) {
|
|
|
return CommonResponse.create(500, "视频不能为空");
|
|
|
}
|
|
|
- String mediaId = uploadFile(file, "video");
|
|
|
+ String mediaId = uploadFile(file, "video", extType);
|
|
|
if (StringUtils.isEmpty(mediaId)) {
|
|
|
return CommonResponse.create(500, "视频上传失败");
|
|
|
}
|
|
@@ -594,7 +595,7 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
|
|
|
return CommonResponse.create(500, "没有对应类型");
|
|
|
}
|
|
|
|
|
|
- private String uploadFile(MultipartFile multipartFile, String fileType) {
|
|
|
+ private String uploadFile(MultipartFile multipartFile, String fileType, Integer extType) {
|
|
|
String mediaId = null;
|
|
|
try {
|
|
|
String extension = FileUtils.getExtension(multipartFile);
|
|
@@ -612,7 +613,12 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
|
|
|
File file = new File(filePath);
|
|
|
//暂时不区分主体
|
|
|
String weComAccessToken = weComAccessTokenService.getWeComAccessToken(1L);
|
|
|
- String url = String.format(POST_WE_COM_MEDIA_UPLOAD + "?access_token=%s&type=%s", weComAccessToken, fileType);
|
|
|
+ String url;
|
|
|
+ if (extType != null && extType == 1) {
|
|
|
+ url = String.format(POST_WE_COM_MEDIA_UPLOAD_ATTACHMENT + "?access_token=%s&media_type=%s&attachment_type=1", weComAccessToken, fileType);
|
|
|
+ } else {
|
|
|
+ url = String.format(POST_WE_COM_MEDIA_UPLOAD + "?access_token=%s&type=%s", weComAccessToken, fileType);
|
|
|
+ }
|
|
|
String res = httpPoolClient.post(url, file);
|
|
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(res);
|