|
@@ -1,26 +1,29 @@
|
|
|
package com.tzld.piaoquan.api.controller;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.tzld.piaoquan.growth.common.model.vo.SendRequestParam;
|
|
|
import com.tzld.piaoquan.api.service.WeComAutoReply;
|
|
|
import com.tzld.piaoquan.growth.common.common.constant.WeComServerConstant;
|
|
|
+import com.tzld.piaoquan.growth.common.component.HttpPoolClient;
|
|
|
import com.tzld.piaoquan.growth.common.service.WeComUserService;
|
|
|
import com.tzld.piaoquan.growth.common.utils.wecom.WXBizMsgCrypt;
|
|
|
import com.tzld.piaoquan.growth.common.utils.wecom.WxUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import lombok.val;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.apache.ibatis.annotations.Param;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.servlet.ServletInputStream;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
-import java.io.BufferedReader;
|
|
|
-import java.io.InputStreamReader;
|
|
|
-import java.io.PrintWriter;
|
|
|
+import java.io.*;
|
|
|
+import java.nio.file.Files;
|
|
|
+import java.nio.file.Paths;
|
|
|
import java.util.Map;
|
|
|
+import java.util.UUID;
|
|
|
|
|
|
import static com.tzld.piaoquan.growth.common.common.enums.CorpEnum.HNWQ;
|
|
|
import static com.tzld.piaoquan.growth.common.common.enums.CorpEnum.YLQ;
|
|
@@ -37,6 +40,9 @@ public class TencentWeComController {
|
|
|
@Autowired
|
|
|
private WeComAutoReply weComAutoReply;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private HttpPoolClient httpPoolClient;
|
|
|
+
|
|
|
@GetMapping("/verify")
|
|
|
public void verifyGet(HttpServletRequest request, HttpServletResponse response) {
|
|
|
try {
|
|
@@ -219,4 +225,29 @@ public class TencentWeComController {
|
|
|
String success = "success";
|
|
|
return success;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("/send/post")
|
|
|
+ public String sendPost(@RequestBody SendRequestParam sendRequestParam) throws IOException {
|
|
|
+ log.info("sendPost sendRequestParam={}", sendRequestParam);
|
|
|
+ return httpPoolClient.post(sendRequestParam.getUrl(), sendRequestParam.getParam());
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/send/post/file")
|
|
|
+ public String sendPostFile(@RequestParam String url, @RequestParam("media") MultipartFile multipartFile) throws IOException {
|
|
|
+ String filePath = UUID.randomUUID() + ".jpg";
|
|
|
+ File file = new File(filePath);
|
|
|
+ // 将MultipartFile的内容传输到File中
|
|
|
+ multipartFile.transferTo(file);
|
|
|
+ log.info("sendPostFile url={}", url);
|
|
|
+ String post = httpPoolClient.post(url, file);
|
|
|
+ Files.delete(Paths.get(filePath));
|
|
|
+ return post;
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/send/get")
|
|
|
+ public String sendGet(@RequestParam String url) throws IOException {
|
|
|
+ log.info("sendGet url={}", url);
|
|
|
+ return httpPoolClient.get(url);
|
|
|
+ }
|
|
|
}
|