Browse Source

Merge branch 'feature/1020-tencent-im' into saas

liujc 10 months ago
parent
commit
070bcb9d8e

+ 31 - 1
mec-application/src/main/java/com/ym/mec/student/controller/ImGroupController.java

@@ -4,6 +4,7 @@ import com.google.common.collect.Lists;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dto.ImUserFriendDto;
 import com.ym.mec.biz.dal.entity.ImGroup;
+import com.ym.mec.biz.dal.entity.ImGroupMemberPlus;
 import com.ym.mec.biz.dal.enums.im.ClientEnum;
 import com.ym.mec.biz.dal.page.ImGroupNoticeQueryInfo;
 import com.ym.mec.biz.service.*;
@@ -18,6 +19,7 @@ import io.swagger.annotations.ApiOperation;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -51,6 +53,9 @@ public class ImGroupController extends BaseController {
     @Autowired
     private ImGroupCoreService imGroupCoreService;
 
+    @Autowired
+    private ImGroupMemberPlusService imGroupMemberPlusService;
+
 	@ApiOperation("查询群列表")
 	@GetMapping(value = "/queryGroupList")
 	public Object queryGroupList(String search,String groupType) {
@@ -63,7 +68,19 @@ public class ImGroupController extends BaseController {
 		if (imGroupId.contains("S") || imGroupId.contains("I")){
 			imGroupId = imGroupId.substring(1);
 		}
-		ImGroup imGroup = imGroupService.get(imGroupId);
+        ImGroup imGroup = imGroupService.get(imGroupId);
+
+        if (imGroup == null) {
+            return failed(HttpStatus.NO_CONTENT, "群组不存在");
+        }
+        ImGroupMemberPlus admin = imGroupMemberPlusService.lambdaQuery()
+            .eq(ImGroupMemberPlus::getImGroupId, imGroup.getId())
+            .eq(ImGroupMemberPlus::getUserId, sysUserService.getUser().getId())
+            .last("limit 1").one();
+        if (admin == null) {
+            // 该用户不在该群,无权限查看,处理用户退出群后,查看历史消息校验
+            return failed(HttpStatus.NO_CONTENT, "群组不存在");
+        }
 		// 设置默认头像
 		if (Objects.nonNull(imGroup) && Objects.nonNull(imGroup.getGroupType()) && StringUtils.isBlank(imGroup.getImg())) {
 			imGroup.setImg(imGroup.getGroupType().getAvatar());
@@ -80,6 +97,19 @@ public class ImGroupController extends BaseController {
 		if (imGroupId.contains("S") || imGroupId.contains("I")){
 			imGroupId = imGroupId.substring(1);
 		}
+        ImGroup imGroup = imGroupService.get(imGroupId);
+
+        if (imGroup == null) {
+            return failed(HttpStatus.NO_CONTENT, "群组不存在");
+        }
+        ImGroupMemberPlus admin = imGroupMemberPlusService.lambdaQuery()
+            .eq(ImGroupMemberPlus::getImGroupId, imGroup.getId())
+            .eq(ImGroupMemberPlus::getUserId, sysUserService.getUser().getId())
+            .last("limit 1").one();
+        if (admin == null) {
+            // 该用户不在该群,无权限查看,处理用户退出群后,查看历史消息校验
+            return failed(HttpStatus.NO_CONTENT, "群组不存在");
+        }
 		return succeed(imGroupService.get(imGroupId));
 	}
 

+ 32 - 5
mec-application/src/main/java/com/ym/mec/teacher/controller/ImGroupController.java

@@ -4,12 +4,10 @@ import com.google.common.collect.Lists;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dto.ImUserFriendDto;
 import com.ym.mec.biz.dal.entity.ImGroup;
+import com.ym.mec.biz.dal.entity.ImGroupMemberPlus;
 import com.ym.mec.biz.dal.enums.im.ClientEnum;
 import com.ym.mec.biz.dal.page.ImGroupNoticeQueryInfo;
-import com.ym.mec.biz.service.ImGroupNoticeService;
-import com.ym.mec.biz.service.ImGroupService;
-import com.ym.mec.biz.service.ImUserFriendService;
-import com.ym.mec.biz.service.SysUserService;
+import com.ym.mec.biz.service.*;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.vo.ImUserWrapper;
@@ -20,6 +18,7 @@ import io.swagger.annotations.ApiOperation;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -47,6 +46,9 @@ public class ImGroupController extends BaseController {
 	@Autowired
 	private SysUserService userLoginService;
 
+    @Autowired
+    private ImGroupMemberPlusService imGroupMemberPlusService;
+
 	@ApiOperation("查询群列表")
 	@GetMapping(value = "/queryGroupList")
 	public Object queryGroupList(String search,String groupType) {
@@ -69,7 +71,19 @@ public class ImGroupController extends BaseController {
 		if (imGroupId.contains("S") || imGroupId.contains("I")){
 			imGroupId = imGroupId.substring(1);
 		}
-		ImGroup imGroup = imGroupService.get(imGroupId);
+        ImGroup imGroup = imGroupService.get(imGroupId);
+
+        if (imGroup == null) {
+            return failed(HttpStatus.NO_CONTENT, "群组不存在");
+        }
+        ImGroupMemberPlus admin = imGroupMemberPlusService.lambdaQuery()
+            .eq(ImGroupMemberPlus::getImGroupId, imGroup.getId())
+            .eq(ImGroupMemberPlus::getUserId, userLoginService.getUser().getId())
+            .last("limit 1").one();
+        if (admin == null) {
+            // 该用户不在该群,无权限查看,处理用户退出群后,查看历史消息校验
+            return failed(HttpStatus.NO_CONTENT, "群组不存在");
+        }
 		// 设置默认头像
 		if (Objects.nonNull(imGroup) && Objects.nonNull(imGroup.getGroupType()) && StringUtils.isBlank(imGroup.getImg())) {
 			imGroup.setImg(imGroup.getGroupType().getAvatar());
@@ -86,6 +100,19 @@ public class ImGroupController extends BaseController {
 		if (imGroupId.contains("S") || imGroupId.contains("I")){
 			imGroupId = imGroupId.substring(1);
 		}
+        ImGroup imGroup = imGroupService.get(imGroupId);
+
+        if (imGroup == null) {
+            return failed(HttpStatus.NO_CONTENT, "群组不存在");
+        }
+        ImGroupMemberPlus admin = imGroupMemberPlusService.lambdaQuery()
+            .eq(ImGroupMemberPlus::getImGroupId, imGroup.getId())
+            .eq(ImGroupMemberPlus::getUserId, userLoginService.getUser().getId())
+            .last("limit 1").one();
+        if (admin == null) {
+            // 该用户不在该群,无权限查看,处理用户退出群后,查看历史消息校验
+            return failed(HttpStatus.NO_CONTENT, "群组不存在");
+        }
 		return succeed(imGroupService.get(imGroupId));
 	}
 

+ 32 - 1
mec-application/src/main/java/com/ym/mec/web/controller/ImGroupController.java

@@ -7,6 +7,8 @@ import com.ym.mec.biz.dal.dto.ImGroupMemberDto;
 import com.ym.mec.biz.dal.dto.ImUserFriendDto;
 import com.ym.mec.biz.dal.dto.NameDto;
 import com.ym.mec.biz.dal.entity.ImGroup;
+import com.ym.mec.biz.dal.entity.ImGroupMember;
+import com.ym.mec.biz.dal.entity.ImGroupMemberPlus;
 import com.ym.mec.biz.dal.enums.im.ClientEnum;
 import com.ym.mec.biz.dal.page.ImGroupNoticeQueryInfo;
 import com.ym.mec.biz.dal.vo.ImGroupVo;
@@ -24,6 +26,7 @@ import io.swagger.annotations.ApiOperation;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.Arrays;
@@ -49,6 +52,9 @@ public class ImGroupController extends BaseController {
 	@Autowired
 	private ImGroupMemberService imGroupMemberService;
 
+    @Autowired
+    private ImGroupMemberPlusService imGroupMemberPlusService;
+
 	@Autowired
 	private ImGroupNoticeService imGroupNoticeService;
 
@@ -74,6 +80,18 @@ public class ImGroupController extends BaseController {
 			imGroupId = imGroupId.substring(1);
 		}
 		ImGroup imGroup = imGroupService.get(imGroupId);
+
+        if (imGroup == null) {
+            return failed(HttpStatus.NO_CONTENT, "群组不存在");
+        }
+        ImGroupMemberPlus admin = imGroupMemberPlusService.lambdaQuery()
+            .eq(ImGroupMemberPlus::getImGroupId, imGroup.getId())
+            .eq(ImGroupMemberPlus::getUserId, sysUserService.getUser().getId())
+            .last("limit 1").one();
+        if (admin == null) {
+            // 该用户不在该群,无权限查看,处理用户退出群后,查看历史消息校验
+            return failed(HttpStatus.NO_CONTENT, "群组不存在");
+        }
 		// 设置默认头像
 		if (Objects.nonNull(imGroup) && Objects.nonNull(imGroup.getGroupType()) && StringUtils.isBlank(imGroup.getImg())) {
 			imGroup.setImg(imGroup.getGroupType().getAvatar());
@@ -90,7 +108,20 @@ public class ImGroupController extends BaseController {
 		if (imGroupId.contains("S") || imGroupId.contains("I")){
 			imGroupId = imGroupId.substring(1);
 		}
-		return succeed(imGroupService.get(imGroupId));
+        ImGroup imGroup = imGroupService.get(imGroupId);
+
+        if (imGroup == null) {
+            return failed(HttpStatus.NO_CONTENT, "群组不存在");
+        }
+        ImGroupMemberPlus admin = imGroupMemberPlusService.lambdaQuery()
+            .eq(ImGroupMemberPlus::getImGroupId, imGroup.getId())
+            .eq(ImGroupMemberPlus::getUserId, sysUserService.getUser().getId())
+            .last("limit 1").one();
+        if (admin == null) {
+            // 该用户不在该群,无权限查看,处理用户退出群后,查看历史消息校验
+            return failed(HttpStatus.NO_CONTENT, "群组不存在");
+        }
+		return succeed(imGroup);
 	}
 
 	@ApiOperation("修改群信息")