diff --git a/im-platform/src/main/java/com/lx/implatform/controller/FriendController.java b/im-platform/src/main/java/com/lx/implatform/controller/FriendController.java index eb25d50..2bbd2f2 100644 --- a/im-platform/src/main/java/com/lx/implatform/controller/FriendController.java +++ b/im-platform/src/main/java/com/lx/implatform/controller/FriendController.java @@ -31,7 +31,10 @@ public class FriendController { public Result< List> findFriends(){ List friends = friendService.findFriendByUserId(SessionContext.getSession().getId()); List vos = friends.stream().map(f->{ - FriendVO vo = BeanUtils.copyProperties(f, FriendVO.class); + FriendVO vo = new FriendVO(); + vo.setId(f.getFriendId()); + vo.setHeadImage(f.getFriendHeadImage()); + vo.setNickName(f.getFriendNickName()); return vo; }).collect(Collectors.toList()); return ResultUtils.success(vos); diff --git a/im-platform/src/main/java/com/lx/implatform/service/impl/FriendServiceImpl.java b/im-platform/src/main/java/com/lx/implatform/service/impl/FriendServiceImpl.java index 73b2906..626d5e6 100644 --- a/im-platform/src/main/java/com/lx/implatform/service/impl/FriendServiceImpl.java +++ b/im-platform/src/main/java/com/lx/implatform/service/impl/FriendServiceImpl.java @@ -80,15 +80,15 @@ public class FriendServiceImpl extends ServiceImpl impleme QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.lambda() .eq(Friend::getUserId,userId) - .eq(Friend::getFriendId,vo.getFriendId()); + .eq(Friend::getFriendId,vo.getId()); Friend f = this.getOne(queryWrapper); if(f == null){ throw new GlobalException(ResultCode.PROGRAM_ERROR,"对方不是您的好友"); } - f.setFriendHeadImage(vo.getFriendHeadImage()); - f.setFriendNickName(vo.getFriendNickName()); + f.setFriendHeadImage(vo.getHeadImage()); + f.setFriendNickName(vo.getNickName()); this.updateById(f); } diff --git a/im-platform/src/main/java/com/lx/implatform/vo/FriendVO.java b/im-platform/src/main/java/com/lx/implatform/vo/FriendVO.java index d4c739b..6b8a230 100644 --- a/im-platform/src/main/java/com/lx/implatform/vo/FriendVO.java +++ b/im-platform/src/main/java/com/lx/implatform/vo/FriendVO.java @@ -13,13 +13,13 @@ public class FriendVO { @NotNull(message = "好友id不可为空") @ApiModelProperty(value = "好友id") - private Long friendId; + private Long id; @NotNull(message = "好友昵称不可为空") @ApiModelProperty(value = "好友昵称") - private String friendNickName; + private String nickName; @ApiModelProperty(value = "好友头像") - private String friendHeadImage; + private String headImage; } diff --git a/im-ui/src/components/friend/AddFriend.vue b/im-ui/src/components/friend/AddFriend.vue index 21dd0ff..01db5aa 100644 --- a/im-ui/src/components/friend/AddFriend.vue +++ b/im-ui/src/components/friend/AddFriend.vue @@ -4,17 +4,17 @@ -
+
- +
-
{{userInfo.nickName}}
-
{{ userInfo.online?"[在线]":"[离线]"}}
+
{{user.nickName}}
+
{{ user.online?"[在线]":"[离线]"}}
- 添加 - 已添加 + 添加 + 已添加
@@ -54,27 +54,27 @@ this.users = data; }) }, - handleAddFriend(userInfo){ + handleAddFriend(user){ this.$http({ url: "/api/friend/add", method: "post", params: { - friendId: userInfo.id + friendId: user.id } }).then((data) => { this.$message.success("添加成功,对方已成为您的好友"); - let friendInfo = { - friendId:userInfo.id, - friendNickName: userInfo.nickName, - friendHeadImage: userInfo.headImage, - online: userInfo.online + let friend = { + id:user.id, + nickName: user.nickName, + headImage: user.headImage, + online: user.online } - this.$store.commit("addFriend",friendInfo); + this.$store.commit("addFriend",friend); }) }, isFriend(userId){ let friends = this.$store.state.friendStore.friends; - let friend = friends.find((f)=> f.friendId==userId); + let friend = friends.find((f)=> f.id==userId); return friend != undefined; } }, diff --git a/im-ui/src/components/friend/FriendItem.vue b/im-ui/src/components/friend/FriendItem.vue index 4717b19..bb3c686 100644 --- a/im-ui/src/components/friend/FriendItem.vue +++ b/im-ui/src/components/friend/FriendItem.vue @@ -1,13 +1,13 @@ +