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) {