diff --git a/commom/src/main/java/com/lx/common/contant/Constant.java b/commom/src/main/java/com/lx/common/contant/Constant.java new file mode 100644 index 0000000..301a8f6 --- /dev/null +++ b/commom/src/main/java/com/lx/common/contant/Constant.java @@ -0,0 +1,13 @@ +package com.lx.common.contant; + + + +public class Constant { + + // 最大图片上传大小 + public static final long MAX_IMAGE_SIZE = 5*1024*1024; + // 最大上传文件大小 + public static final long MAX_FILE_SIZE = 10*1024*1024; + // 群聊最大人数 + public static final long MAX_GROUP_MEMBER = 500; +} diff --git a/commom/src/main/java/com/lx/common/contant/Contant.java b/commom/src/main/java/com/lx/common/contant/Contant.java deleted file mode 100644 index f24130e..0000000 --- a/commom/src/main/java/com/lx/common/contant/Contant.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.lx.common.contant; - - - -public class Contant { - - public static final long MAX_IMAGE_SIZE = 5*1024*1024; - - public static final long MAX_FILE_SIZE = 10*1024*1024; - - -} diff --git a/im-platform/src/main/java/com/lx/implatform/controller/GroupController.java b/im-platform/src/main/java/com/lx/implatform/controller/GroupController.java index 7b6ae4a..83f159b 100644 --- a/im-platform/src/main/java/com/lx/implatform/controller/GroupController.java +++ b/im-platform/src/main/java/com/lx/implatform/controller/GroupController.java @@ -5,6 +5,7 @@ import com.lx.common.result.Result; import com.lx.common.result.ResultUtils; import com.lx.implatform.service.IGroupService; import com.lx.implatform.vo.GroupInviteVO; +import com.lx.implatform.vo.GroupMemberVO; import com.lx.implatform.vo.GroupVO; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; @@ -54,5 +55,13 @@ public class GroupController { groupService.invite(vo); return ResultUtils.success(); } + + @ApiOperation(value = "查询群聊成员",notes="查询群聊成员") + @GetMapping("/members/{groupId}") + public Result> findGroupMembers(@NotNull(message = "群聊id不能为空") @PathVariable Long groupId){ + return ResultUtils.success(groupService.findGroupMembers(groupId)); + } + + } diff --git a/im-platform/src/main/java/com/lx/implatform/service/IGroupService.java b/im-platform/src/main/java/com/lx/implatform/service/IGroupService.java index ef38d6d..fd1edf0 100644 --- a/im-platform/src/main/java/com/lx/implatform/service/IGroupService.java +++ b/im-platform/src/main/java/com/lx/implatform/service/IGroupService.java @@ -3,6 +3,7 @@ package com.lx.implatform.service; import com.lx.implatform.entity.Group; import com.baomidou.mybatisplus.extension.service.IService; import com.lx.implatform.vo.GroupInviteVO; +import com.lx.implatform.vo.GroupMemberVO; import com.lx.implatform.vo.GroupVO; import java.util.List; @@ -27,4 +28,6 @@ public interface IGroupService extends IService { List findGroups(); void invite(GroupInviteVO vo); + + List findGroupMembers(Long groupId); } diff --git a/im-platform/src/main/java/com/lx/implatform/service/impl/GroupServiceImpl.java b/im-platform/src/main/java/com/lx/implatform/service/impl/GroupServiceImpl.java index ced8e53..75388ff 100644 --- a/im-platform/src/main/java/com/lx/implatform/service/impl/GroupServiceImpl.java +++ b/im-platform/src/main/java/com/lx/implatform/service/impl/GroupServiceImpl.java @@ -1,6 +1,7 @@ package com.lx.implatform.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.lx.common.contant.Constant; import com.lx.common.enums.ResultCode; import com.lx.common.util.BeanUtils; import com.lx.implatform.entity.Friend; @@ -17,11 +18,13 @@ import com.lx.implatform.service.IUserService; import com.lx.implatform.session.SessionContext; import com.lx.implatform.session.UserSession; import com.lx.implatform.vo.GroupInviteVO; +import com.lx.implatform.vo.GroupMemberVO; import com.lx.implatform.vo.GroupVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.Collections; import java.util.List; import java.util.stream.Collectors; @@ -124,6 +127,9 @@ public class GroupServiceImpl extends ServiceImpl implements QueryWrapper memberWrapper = new QueryWrapper(); memberWrapper.lambda().eq(GroupMember::getUserId, session.getId()); List groupMembers = groupMemberService.list(memberWrapper); + if(groupMembers.isEmpty()){ + return Collections.EMPTY_LIST; + } // 拉取群信息 List ids = groupMembers.stream().map((gm -> gm.getGroupId())).collect(Collectors.toList()); QueryWrapper groupWrapper = new QueryWrapper(); @@ -146,11 +152,18 @@ public class GroupServiceImpl extends ServiceImpl implements @Override public void invite(GroupInviteVO vo) { UserSession session = SessionContext.getSession(); + // 群聊人数校验 + QueryWrapper memberWrapper = new QueryWrapper(); + memberWrapper.lambda().eq(GroupMember::getGroupId, vo.getGroupId()); + List members = groupMemberService.list(memberWrapper); + if(vo.getFriendIds().size() + members.size() > Constant.MAX_GROUP_MEMBER){ + throw new GlobalException(ResultCode.PROGRAM_ERROR, "群聊人数不能大于"+Constant.MAX_GROUP_MEMBER+"人"); + } // 已经在群里面用户,不可重复加入 - QueryWrapper wrapper = new QueryWrapper(); - wrapper.lambda().eq(GroupMember::getId, vo.getGroupId()) - .in(GroupMember::getUserId, vo.getFriendIds()); - if(groupMemberService.count(wrapper)>0){ + Boolean flag = vo.getFriendIds().stream().anyMatch(id->{ + return members.stream().anyMatch(m->m.getUserId()==id); + }); + if(flag){ throw new GlobalException(ResultCode.PROGRAM_ERROR, "部分用户已经在群中,邀请失败"); } // 找出好友信息 @@ -174,4 +187,23 @@ public class GroupServiceImpl extends ServiceImpl implements groupMemberService.saveBatch(groupMembers); } } + + /** + * 查询群成员 + * + * @Param groupId 群聊id + * @return List + **/ + @Override + public List findGroupMembers(Long groupId) { + QueryWrapper memberWrapper = new QueryWrapper(); + memberWrapper.lambda().eq(GroupMember::getGroupId, groupId); + List members = groupMemberService.list(memberWrapper); + + List vos = members.stream().map(m->{ + GroupMemberVO vo = BeanUtils.copyProperties(m,GroupMemberVO.class); + return vo; + }).collect(Collectors.toList()); + return vos; + } } diff --git a/im-platform/src/main/java/com/lx/implatform/service/thirdparty/FileService.java b/im-platform/src/main/java/com/lx/implatform/service/thirdparty/FileService.java index 73cf455..7555a91 100644 --- a/im-platform/src/main/java/com/lx/implatform/service/thirdparty/FileService.java +++ b/im-platform/src/main/java/com/lx/implatform/service/thirdparty/FileService.java @@ -1,6 +1,6 @@ package com.lx.implatform.service.thirdparty; -import com.lx.common.contant.Contant; +import com.lx.common.contant.Constant; import com.lx.common.enums.FileTypeEnum; import com.lx.common.enums.ResultCode; import com.lx.implatform.exception.GlobalException; @@ -51,7 +51,7 @@ public class FileService { public String uploadFile(MultipartFile file){ // 大小校验 - if(file.getSize() > Contant.MAX_FILE_SIZE){ + if(file.getSize() > Constant.MAX_FILE_SIZE){ throw new GlobalException(ResultCode.PROGRAM_ERROR,"文件大小不能超过10M"); } // 上传 @@ -65,7 +65,7 @@ public class FileService { public UploadImageVO uploadImage(MultipartFile file){ try { // 大小校验 - if(file.getSize() > Contant.MAX_IMAGE_SIZE){ + if(file.getSize() > Constant.MAX_IMAGE_SIZE){ throw new GlobalException(ResultCode.PROGRAM_ERROR,"图片大小不能超过5M"); } // 图片格式校验 diff --git a/im-platform/src/main/java/com/lx/implatform/vo/GroupMemberVO.java b/im-platform/src/main/java/com/lx/implatform/vo/GroupMemberVO.java new file mode 100644 index 0000000..da3cd3a --- /dev/null +++ b/im-platform/src/main/java/com/lx/implatform/vo/GroupMemberVO.java @@ -0,0 +1,24 @@ +package com.lx.implatform.vo; + + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +@ApiModel("群成员信息VO") +public class GroupMemberVO { + + @ApiModelProperty("用户id") + private Long userId; + + @ApiModelProperty("群内显示名称") + private String aliasName; + + @ApiModelProperty("头像") + private String headImage; + + @ApiModelProperty("备注") + private String remark; + +} diff --git a/im-platform/src/main/resources/db/db.sql b/im-platform/src/main/resources/db/db.sql index e6f2be7..52b874c 100644 --- a/im-platform/src/main/resources/db/db.sql +++ b/im-platform/src/main/resources/db/db.sql @@ -7,7 +7,7 @@ create table `im_user`( `head_image_thumb` varchar(255) default '' comment '用户头像缩略图', `password` varchar(255) not null comment '密码(明文)', `sex` tinyint(1) default 0 comment '性别 0:男 1::女', - `signature` varchar(1024) not null comment '个性签名', + `signature` varchar(1024) default '' comment '个性签名', `last_login_time` datetime DEFAULT null comment '最后登录时间', `created_time` datetime DEFAULT CURRENT_TIMESTAMP comment '创建时间', unique key `idx_user_name`(user_name), diff --git a/im-ui/src/assets/style/global.css b/im-ui/src/assets/style/global.css index 5e3cd46..fc63060 100644 --- a/im-ui/src/assets/style/global.css +++ b/im-ui/src/assets/style/global.css @@ -17,7 +17,9 @@ section { height: 100%; } - +.el-dialog__body{ + padding: 10px 15px !important; +} ::-webkit-scrollbar { width: 6px; diff --git a/im-ui/src/components/chat/ChatItem.vue b/im-ui/src/components/chat/ChatItem.vue index 7a70c8b..49f62e5 100644 --- a/im-ui/src/components/chat/ChatItem.vue +++ b/im-ui/src/components/chat/ChatItem.vue @@ -13,7 +13,6 @@
-
@@ -64,14 +63,14 @@ padding-left: 15px; align-items: center; padding-right: 5px; - background-color: #eeeeee; + background-color: #fafafa; &:hover { - background-color: #dddddd; + background-color: #eeeeee; } &.active { - background-color: #cccccc; + background-color: #dddddd; } @@ -159,7 +158,4 @@ } } - .active { - background-color: #eeeeee; - } diff --git a/im-ui/src/components/common/HeadImage.vue b/im-ui/src/components/common/HeadImage.vue index f8a8350..1e15465 100644 --- a/im-ui/src/components/common/HeadImage.vue +++ b/im-ui/src/components/common/HeadImage.vue @@ -1,8 +1,6 @@ \ No newline at end of file diff --git a/im-ui/src/components/friend/AddFriend.vue b/im-ui/src/components/friend/AddFriend.vue index 01db5aa..366ad27 100644 --- a/im-ui/src/components/friend/AddFriend.vue +++ b/im-ui/src/components/friend/AddFriend.vue @@ -4,7 +4,7 @@ -
+
diff --git a/im-ui/src/components/friend/FriendItem.vue b/im-ui/src/components/friend/FriendItem.vue index bb3c686..9c82bb1 100644 --- a/im-ui/src/components/friend/FriendItem.vue +++ b/im-ui/src/components/friend/FriendItem.vue @@ -1,5 +1,5 @@ @@ -24,6 +25,12 @@ data() { return {} }, + methods:{ + handleDel(){ + console.log("11111111111111111111") + this.$emit('del',this.friend,this.index) + } + }, props: { friend: { type: Object @@ -33,6 +40,10 @@ }, index: { type: Number + }, + showDelete:{ + type: Boolean, + default: true } }, computed: { @@ -44,7 +55,7 @@ diff --git a/im-ui/src/components/group/AddGroupMember.vue b/im-ui/src/components/group/AddGroupMember.vue new file mode 100644 index 0000000..484e7d3 --- /dev/null +++ b/im-ui/src/components/group/AddGroupMember.vue @@ -0,0 +1,182 @@ + + + + + diff --git a/im-ui/src/components/group/GroupItem.vue b/im-ui/src/components/group/GroupItem.vue new file mode 100644 index 0000000..b962e9b --- /dev/null +++ b/im-ui/src/components/group/GroupItem.vue @@ -0,0 +1,71 @@ + + + + + diff --git a/im-ui/src/components/group/GroupMember.vue b/im-ui/src/components/group/GroupMember.vue new file mode 100644 index 0000000..8649639 --- /dev/null +++ b/im-ui/src/components/group/GroupMember.vue @@ -0,0 +1,47 @@ + + + + + diff --git a/im-ui/src/components/setting/Setting.vue b/im-ui/src/components/setting/Setting.vue index a6e84a3..067e6e8 100644 --- a/im-ui/src/components/setting/Setting.vue +++ b/im-ui/src/components/setting/Setting.vue @@ -105,7 +105,7 @@ diff --git a/im-ui/src/view/Group.vue b/im-ui/src/view/Group.vue index ee24d85..6d552ac 100644 --- a/im-ui/src/view/Group.vue +++ b/im-ui/src/view/Group.vue @@ -1,7 +1,7 @@ @@ -29,15 +78,24 @@