diff --git a/hai-cweb/src/main/java/com/cweb/controller/WechatController.java b/hai-cweb/src/main/java/com/cweb/controller/WechatController.java index 5de9c0b8..2f2db978 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/WechatController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/WechatController.java @@ -332,4 +332,41 @@ public class WechatController { } } + @RequestMapping(value = "/getH5AccessByOpenId", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "【H5】通过openId查询") + public ResponseData getH5AccessByOpenId(@RequestParam(value = "openId", required = true) String openId, + HttpServletRequest request, HttpServletResponse response) { + try { + + HighUser user = highUserService.findByOpenId(openId); + + if (user == null) { + user = new HighUser(); + user.setName("用户" + IDGenerator.nextId(5)); + user.setRegTime(new Date()); + user.setGold(0); + user.setOpenId(openId); + user.setStatus(1); + // 用户信息完整状态 + // 0:完整 + // 1:需要填写用户信息 + // 2:需要填写手机号 + user.setInfoCompleteStatus(1); + highUserService.insertUser(user , null , null); + } + + // 定义个人所有数据 + HighUserModel highUserModel = new HighUserModel(); + HighUser detailData = highUserService.getDetailDataByUser(user.getId()); + detailData.setPassword(null); + highUserModel.setHighUser(detailData); + SessionObject so = new SessionObject(user.getOpenId(), 1, highUserModel); + userCenter.save(request, response, so); + return ResponseMsgUtil.success(so); + + } catch (Exception e) { + return ResponseMsgUtil.exception(e); + } + } }