From 6cc97918a5a42e37a3c3867cc5b78a0b9fd43a24 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期五, 29 四月 2022 19:55:41 +0800 Subject: [PATCH] 功能完善 --- app/src/main/java/com/yeshi/makemoney/app/controller/client/api/UserController.java | 85 +++++++++++++++++++++++++++++++----------- 1 files changed, 63 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/com/yeshi/makemoney/app/controller/client/api/UserController.java b/app/src/main/java/com/yeshi/makemoney/app/controller/client/api/UserController.java index 6dcb850..3294f24 100644 --- a/app/src/main/java/com/yeshi/makemoney/app/controller/client/api/UserController.java +++ b/app/src/main/java/com/yeshi/makemoney/app/controller/client/api/UserController.java @@ -1,12 +1,14 @@ package com.yeshi.makemoney.app.controller.client.api; import com.yeshi.makemoney.app.dto.user.LoginInfoDTO; +import com.yeshi.makemoney.app.entity.APPPlatform; import com.yeshi.makemoney.app.entity.user.UserExtraInfo; import com.yeshi.makemoney.app.entity.user.UserInfo; import com.yeshi.makemoney.app.entity.user.UserLoginRecord; import com.yeshi.makemoney.app.entity.user.WXUserInfo; import com.yeshi.makemoney.app.entity.vip.UserVIPInfo; import com.yeshi.makemoney.app.exception.user.LoginException; +import com.yeshi.makemoney.app.exception.user.UserAccountException; import com.yeshi.makemoney.app.service.inter.goldcorn.GoldCornGetRecordService; import com.yeshi.makemoney.app.service.inter.money.UserMoneyService; import com.yeshi.makemoney.app.service.inter.team.TeamInviteRelationService; @@ -15,6 +17,7 @@ import com.yeshi.makemoney.app.service.inter.user.UserInfoService; import com.yeshi.makemoney.app.service.inter.user.WXUserInfoService; import com.yeshi.makemoney.app.service.inter.vip.VIPService; +import com.yeshi.makemoney.app.service.manager.PushManager; import com.yeshi.makemoney.app.service.manager.VerifyCodeManager; import com.yeshi.makemoney.app.utils.ApiCodeConstant; import com.yeshi.makemoney.app.utils.ImageUtil; @@ -70,8 +73,8 @@ @Resource private VerifyCodeManager verifyCodeManager; - // @Reference(version = "1.0", check = false) - private BDeviceTokenService bDeviceTokenService; + @Resource + private PushManager pushManager; @Resource private GoldCornGetRecordService goldCornGetRecordService; @@ -102,6 +105,25 @@ return JsonUtil.loadFalseResult("淇℃伅涓嶅畬鏁�"); } loginInfo.setSystem(acceptData.getSystem()); + return login(loginInfo, acceptData); + } + + + @ResponseBody + @RequestMapping("loginWX") + public String loginWX(AcceptData acceptData, String code, HttpServletRequest request) { + LoginInfoDTO loginInfo = new LoginInfoDTO(); + loginInfo.setIpInfo(IPUtil.getRemotIP(request) + ":" + request.getRemotePort()); + loginInfo.setLoginType(UserLoginRecord.TYPE_LOGIN_WX); + if (StringUtil.isNullOrEmpty(code)) { + return JsonUtil.loadFalseResult("淇℃伅涓嶅畬鏁�"); + } + loginInfo.setWxCode(code); + loginInfo.setSystem(acceptData.getSystem()); + return login(loginInfo, acceptData); + } + + private String login(LoginInfoDTO loginInfo, AcceptData acceptData) { try { UserInfo userInfo = userAccountService.login(loginInfo); ThreadUtil.run(new Runnable() { @@ -109,7 +131,7 @@ public void run() { try { //鐧诲綍鎴愬姛 - bDeviceTokenService.bindUid(acceptData.getSystem().name(), acceptData.getUtdId(), userInfo.getId() + ""); + pushManager.bindUid(acceptData.getSystem(), userInfo.getId(), acceptData.getPlatform() == APPPlatform.ios ? acceptData.getIdfa() : acceptData.getUtdId()); } catch (Exception e) { } @@ -120,7 +142,6 @@ } catch (LoginException e) { return JsonUtil.loadFalseResult(e.getMessage()); } - } private String outUserInfoForLogin(UserInfo userInfo) { @@ -135,13 +156,45 @@ return JsonUtil.loadTrueResult(JsonUtil.getSimpleGson().toJson(vo)); } + + @UserLogin(uid = "#uid") + @ResponseBody + @RequestMapping("bindWX") + public String bindWX(AcceptData acceptData, Long uid, String code) { + + try { + userAccountService.bindWX(uid, code); + } catch (UserAccountException e) { + e.printStackTrace(); + return JsonUtil.loadFalseResult(e.getMsg()); + } + + return JsonUtil.loadTrueResult(""); + } + + @UserLogin(uid = "#uid") + @ResponseBody + @RequestMapping("bindPhone") + public String bindPhone(AcceptData acceptData, Long uid, String phone, String vcode, String token) { + + try { + userAccountService.bindPhone(uid, phone, vcode, token); + } catch (UserAccountException e) { + e.printStackTrace(); + return JsonUtil.loadFalseResult(e.getMsg()); + } + + return JsonUtil.loadTrueResult(""); + } + + @UserLogin(uid = "#uid") @ResponseBody @RequestMapping("logout") public String logout(AcceptData acceptData, Long uid) { try { //瑙g粦UID - bDeviceTokenService.unBindUid(acceptData.getSystem().name(), acceptData.getUtdId()); + pushManager.unBind(acceptData.getSystem(), acceptData.getPlatform() == APPPlatform.ios ? acceptData.getIdfa() : acceptData.getUtdId()); } catch (Exception e) { e.printStackTrace(); } @@ -195,7 +248,8 @@ return JsonUtil.loadFalseResult(ApiCodeConstant.CODE_FAIL_USER_DELETE, "鐢ㄦ埛宸茶鍒犻櫎"); } - UserInfoVO vo = UserInfoVO.create(user, userExtraInfoService.get(uid), wxUserInfoService.selectByUid(uid)); + + UserInfoVO vo = UserInfoVO.create(user, userExtraInfoService.get(uid), user.getWxUser() == null ? null : wxUserInfoService.get(user.getWxUser().getId())); return JsonUtil.loadTrueResult(vo); } @@ -260,26 +314,13 @@ @ResponseBody @RequestMapping("uploadPushRegId") public String uploadPushRegId(AcceptData acceptData, Long uid, String regId) { - - BPushDeviceToken deviceToken = new BPushDeviceToken(); - deviceToken.setAppCode(acceptData.getSystem().name()); - deviceToken.setDeviceId(acceptData.getUtdId()); - deviceToken.setBuildModel(acceptData.getDeviceType()); - deviceToken.setBuildVersion(acceptData.getOsVersion()); - deviceToken.setToken(regId); - deviceToken.setType(PushPlatform.jpush); - if (uid != null) { - deviceToken.setUid(uid + ""); - } - deviceToken.setVersionCode(acceptData.getVersion()); - try { - bDeviceTokenService.save(deviceToken); + pushManager.saveToken(acceptData, uid, regId); return JsonUtil.loadTrueResult(""); } catch (BPushDeviceTokenException e) { - return JsonUtil.loadTrueResult(e.getMessage()); + return JsonUtil.loadTrueResult("涓氬姟鍑洪敊"); } catch (ParamsException e) { - return JsonUtil.loadTrueResult(e.getMessage()); + return JsonUtil.loadTrueResult("鍙傛暟閿欒"); } } -- Gitblit v1.8.0