From 3e58cfdd8551c99c4accf6ca7936135622e7f462 Mon Sep 17 00:00:00 2001 From: "xie.bx" Date: Tue, 1 Nov 2022 10:43:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E7=90=86=E4=BB=A3=E7=A0=81=E9=A3=8E?= =?UTF-8?q?=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/FriendController.java | 5 +- .../service/impl/FriendServiceImpl.java | 6 +- .../java/com/lx/implatform/vo/FriendVO.java | 6 +- im-ui/src/components/friend/AddFriend.vue | 30 +++++----- im-ui/src/components/friend/FriendItem.vue | 42 +++++++------ im-ui/src/components/group/CreateGroup.vue | 8 --- im-ui/src/store/chatStore.js | 9 ++- im-ui/src/store/friendStore.js | 16 ++--- im-ui/src/store/groupStore.js | 13 ++-- im-ui/src/store/index.js | 5 +- im-ui/src/view/Chat.vue | 24 ++++---- im-ui/src/view/Friend.vue | 60 +++++++++---------- im-ui/src/view/Group.vue | 55 +++++++++++------ im-ui/src/view/Home.vue | 8 +-- 14 files changed, 154 insertions(+), 133 deletions(-) delete mode 100644 im-ui/src/components/group/CreateGroup.vue 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 @@ +