From 7cc4dd5746ed73a2614a7c9ad6f2f83d5dbc01f9 Mon Sep 17 00:00:00 2001 From: Sum1Dream <418471657@qq.com> Date: Tue, 23 Aug 2022 14:07:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8C=BA=E5=9F=9F=E5=85=AC?= =?UTF-8?q?=E5=8F=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/cweb/controller/WechatController.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) 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); + } + } }