1.1.1 usercontroller中添加updateAvatar,校验是否为url
@PatchMapping("updateAvatar")public Result updateAvatar(@RequestParam @URL String avatarUrl) {userService.updateAvatar(avatarUrl);return Result.success();}
1.1.2 userservice
//更新头像void updateAvatar(String avatarUrl);
1.1.3 userserviceimpl
@Overridepublic void updateAvatar(String avatarUrl) {Map<String,Object> map = ThreadLocalUtil.get();Integer id = (Integer) map.get("id");userMapper.updateAvatar(avatarUrl,id);}
1.1.4 mapper添加
@Update("update user set user_pic=#{avatarUrl},update_time=now() where id=#{id}")void updateAvatar(String avatarUrl,Integer id);
1.1.5 postman调试