| | |
| | | * 微信小程序登录处理类 |
| | | */ |
| | | @RestController |
| | | @RequestMapping(path = "/app") |
| | | public class WxLoginController extends BaseController { |
| | | private final static Logger logger = LoggerFactory.getLogger(WxLoginController.class); |
| | | |
| | |
| | | /** |
| | | * 微信登录接口 |
| | | * |
| | | * @param wxLoginInfo |
| | | * @param postInfo |
| | | * @param request |
| | | */ |
| | | @RequestMapping(path = "/loginWx", method = RequestMethod.POST) |
| | | public ResponseEntity<String> loginWx(@RequestBody WxLoginInfo wxLoginInfo, HttpServletRequest request) { |
| | | public ResponseEntity<String> loginWx(@RequestBody String postInfo, HttpServletRequest request) { |
| | | ResponseEntity<String> responseEntity = null; |
| | | String code = wxLoginInfo.getCode(); |
| | | UserInfo userInfo = wxLoginInfo.getUserInfo(); |
| | | JSONObject postObj = JSONObject.parseObject(postInfo); |
| | | String code = JSONObject.parseObject(postInfo).getString("code"); |
| | | JSONObject userInfo = postObj.getJSONObject("userInfo"); |
| | | if (code == null || userInfo == null) { |
| | | logger.error("code is null"); |
| | | responseEntity = new ResponseEntity<>("code is null", HttpStatus.BAD_REQUEST); |
| | | return responseEntity; |
| | | } |
| | | String sessionKey = null; |
| | | String openId = null; |
| | | /*String sessionKey = null; |
| | | String openId = null;*/ |
| | | // try { |
| | | // /*WxMaJscode2SessionResult result = this.wxMaService.getUserService().getSessionInfo(code); |
| | | // sessionKey = result.getSessionKey(); |
| | |
| | | // e.printStackTrace(); |
| | | // } |
| | | |
| | | IPageData pd = PageData.newInstance().builder("","", JSONObject.toJSONString(wxLoginInfo),"","","",""); |
| | | IPageData pd = PageData.newInstance().builder("", "", postInfo, |
| | | "", "", "", "", |
| | | request.getHeader("APP_ID")); |
| | | |
| | | return wxLoginSMOImpl.doLogin(pd); |
| | | return wxLoginSMOImpl.doLogin(pd); |
| | | |
| | | //login first |
| | | /*User user = userService.queryByOpenid(openId); |