Browse Source

分享微信设置配置

gaodm 5 years ago
parent
commit
0fa23e97de
1 changed files with 22 additions and 0 deletions
  1. 22 0
      zzcx-service/src/main/java/com/diagbot/web/WexinController.java

+ 22 - 0
zzcx-service/src/main/java/com/diagbot/web/WexinController.java

@@ -4,11 +4,18 @@ import com.diagbot.dto.RespDTO;
 import com.diagbot.facade.WeixinFacade;
 import com.diagbot.vo.WeixinVO;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
 import java.util.Map;
 
 /**
@@ -20,6 +27,7 @@ import java.util.Map;
 @Api(value = "微信", tags = { "微信API" })
 @SuppressWarnings("unchecked")
 @RequestMapping("/weixin")
+@Slf4j
 public class WexinController {
 
     @Autowired
@@ -31,4 +39,18 @@ public class WexinController {
         return RespDTO.onSuc(map);
     }
 
+    @RequestMapping(value = "/test", method = RequestMethod.GET, produces = { "application/json;charset=utf-8" })
+    @ApiOperation(value = "测试微信公众号的接口配置信息", notes = "接口配置信息", httpMethod = "GET")
+    public String getWxUserInfo(HttpServletRequest request,
+                                @ApiParam(value = "微信求的 echostr") @RequestParam(required = true) String echostr
+    ) {
+        try {
+            //只需要把微信请求的 echostr, 返回给微信就可以了
+            log.info("测试来过===================" + echostr);
+            return echostr;
+        } catch (Exception e) {
+            log.info("测试微信公众号的接口配置信息发生异常:", e);
+            return null;
+        }
+    }
 }