123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- package com.diagbot.web;
- 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.Enumeration;
- import java.util.LinkedHashMap;
- import java.util.Map;
- /**
- * @Description:
- * @Author:zhoutg
- * @time: 2020/2/6 10:48
- */
- @RestController
- @Api(value = "微信", tags = { "微信API" })
- @SuppressWarnings("unchecked")
- @RequestMapping("/weixin")
- @Slf4j
- public class WexinController {
- @Autowired
- WeixinFacade weixinFacade;
- @RequestMapping("/getConfig")
- public RespDTO<Map> getConfig(@RequestBody WeixinVO weixinVO) {
- Map<String, String> map = weixinFacade.getConfig(weixinVO);
- 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") String echostr
- ) {
- try {
- Map<String, String> map = new LinkedHashMap<>();
- //只需要把微信请求的 echostr, 返回给微信就可以了
- log.info("测试来过===================" + echostr);
- Enumeration pNames = request.getParameterNames();
- while (pNames.hasMoreElements()) {
- String name = (String) pNames.nextElement();
- String value = request.getParameter(name);
- map.put(name, value);
- }
- log.info(map.toString());
- return echostr;
- } catch (Exception e) {
- log.info("测试微信公众号的接口配置信息发生异常:", e);
- return null;
- }
- }
- }
|