From 1e0b86c22f276aedf465903777ce0ff4b7ea5c9a Mon Sep 17 00:00:00 2001 From: cheney <1251790704@qq.com> Date: Tue, 19 Dec 2023 18:54:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=B0=8F=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=94=A8=E6=88=B7=E5=A4=B4=E5=83=8F=E6=88=96?= =?UTF-8?q?=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../users/controller/UserLoginController.java | 13 +++++++++---- .../users/service/IHrUserAccountService.java | 2 ++ .../service/impl/HrUserAccountServiceImpl.java | 17 +++++++++++++++++ 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/users/src/main/java/com/huoran/users/controller/UserLoginController.java b/users/src/main/java/com/huoran/users/controller/UserLoginController.java index b2af983..54fb42e 100644 --- a/users/src/main/java/com/huoran/users/controller/UserLoginController.java +++ b/users/src/main/java/com/huoran/users/controller/UserLoginController.java @@ -237,11 +237,16 @@ public class UserLoginController { return userInfoService.loginByOpenid(openid); } - @ApiOperation(value = "微信小程序更新用户头像") + @ApiOperation(value = "微信小程序更新用户头像或名称") @PostMapping("/updateAvatars") - public R updateAvatars(@RequestParam String url,HttpServletRequest request){ - String id = TokenUtils.getIdByJwtToken(request); - return userInfoService.updateAvatars(url,id); + public R updateAvatars( + @ApiParam(name = "url", value = "头像地址") + @RequestParam String url, + @ApiParam(name = "openId", value = "微信id", required = true) + @RequestParam String openId, + @ApiParam(name = "userName", value = "用户名称") + @RequestParam String userName){ + return userAccountService.updateAvatars(openId,url,userName); } /** diff --git a/users/src/main/java/com/huoran/users/service/IHrUserAccountService.java b/users/src/main/java/com/huoran/users/service/IHrUserAccountService.java index 3aba07a..931e416 100644 --- a/users/src/main/java/com/huoran/users/service/IHrUserAccountService.java +++ b/users/src/main/java/com/huoran/users/service/IHrUserAccountService.java @@ -86,4 +86,6 @@ public interface IHrUserAccountService extends IService { R studentAccountApplication(RegisterReq registerReq); UserInfoDetailsRes viewUserDetails(String openId); + + R updateAvatars(String openId, String url, String userName); } diff --git a/users/src/main/java/com/huoran/users/service/impl/HrUserAccountServiceImpl.java b/users/src/main/java/com/huoran/users/service/impl/HrUserAccountServiceImpl.java index 700a756..4427d97 100644 --- a/users/src/main/java/com/huoran/users/service/impl/HrUserAccountServiceImpl.java +++ b/users/src/main/java/com/huoran/users/service/impl/HrUserAccountServiceImpl.java @@ -433,6 +433,23 @@ public class HrUserAccountServiceImpl extends ServiceImpl userAccountList = hrUserAccountMapper.selectList(new QueryWrapper() + .eq("app_open_id", openId)); + //查询用户信息 + HrUserInfo hrUserInfo = hrUserInfoMapper.selectByUserId(userAccountList.get(0).getUserId()); + if (hrUserInfo.getUserAvatars()!=null){ + hrUserInfo.setUserAvatars(url); + } + if (userName!=null){ + hrUserInfo.setUserName(userName); + } + int update = hrUserInfoMapper.updateById(hrUserInfo); + return update>0 ? R.ok():R.error(); + } + @Override public R oneClickEnableVerification(Integer accountId) {