微信小程序更新用户头像或名称

main
cheney 12 months ago
parent 8c4a1ce670
commit 1e0b86c22f
  1. 13
      users/src/main/java/com/huoran/users/controller/UserLoginController.java
  2. 2
      users/src/main/java/com/huoran/users/service/IHrUserAccountService.java
  3. 17
      users/src/main/java/com/huoran/users/service/impl/HrUserAccountServiceImpl.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);
}
/**

@ -86,4 +86,6 @@ public interface IHrUserAccountService extends IService<HrUserAccount> {
R studentAccountApplication(RegisterReq registerReq);
UserInfoDetailsRes viewUserDetails(String openId);
R updateAvatars(String openId, String url, String userName);
}

@ -433,6 +433,23 @@ public class HrUserAccountServiceImpl extends ServiceImpl<HrUserAccountMapper, H
return res;
}
@Override
public R updateAvatars(String openId, String url, String userName) {
//查询账号详情List
List<HrUserAccount> userAccountList = hrUserAccountMapper.selectList(new QueryWrapper<HrUserAccount>()
.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) {

Loading…
Cancel
Save