diff --git a/community-service/src/main/java/com/tanpu/community/manager/CommentManager.java b/community-service/src/main/java/com/tanpu/community/manager/CommentManager.java index 7dd840b183b78857752be9b2395bf992cab1319c..7bc9913fbffc14cd6a037264f3a9f78acfaf4053 100644 --- a/community-service/src/main/java/com/tanpu/community/manager/CommentManager.java +++ b/community-service/src/main/java/com/tanpu/community/manager/CommentManager.java @@ -129,7 +129,7 @@ public class CommentManager { } // 查询管ç†å‘˜ ThemeEntity themeEntity = themeService.queryByThemeId(themeId); - String managerId = topicService.getManagerId(themeEntity.getTopicId()); + Set<String> managerId = topicService.getManagerId(themeEntity.getTopicId()); for (CommentQo commentQo : commentQos) { // å°è£…ç”¨æˆ·ä¿¡æ¯ @@ -140,7 +140,7 @@ public class CommentManager { Integer countByTypeAndId = collectionService.getCountByTypeAndId(commentId, CollectionTypeEnum.LIKE_COMMENT); commentQo.setLikeCount(countByTypeAndId); // 是å¦ç®¡ç†å‘˜ - if (commentQo.getAuthorId().equals(managerId)) { + if (managerId.contains(commentQo.getAuthorId())) { commentQo.setManager(true); } else { commentQo.setManager(false); diff --git a/community-service/src/main/java/com/tanpu/community/manager/TopicManager.java b/community-service/src/main/java/com/tanpu/community/manager/TopicManager.java index ef45d1639ac382e0864cbe76252c166205a0a107..4243e60000a092275512cbac37d15cfcba412d81 100644 --- a/community-service/src/main/java/com/tanpu/community/manager/TopicManager.java +++ b/community-service/src/main/java/com/tanpu/community/manager/TopicManager.java @@ -143,7 +143,7 @@ public class TopicManager { BeanUtils.copyProperties(topicDetail, result); // 查询管ç†å‘˜ - result.setManagers(topicService.queryManagers(result.getTopicId())); + result.setManagers(topicService.queryManagerNames(result.getTopicId())); // 查询关è”äº§å“ topicService.queryAttachments(result); // 是å¦å…³æ³¨ diff --git a/community-service/src/main/java/com/tanpu/community/service/TopicService.java b/community-service/src/main/java/com/tanpu/community/service/TopicService.java index c58542012375a686a7ab3dabc422a576cab6ab8b..cbf1ff50a9e4b94c550aae6d19ffec049c6fcb07 100644 --- a/community-service/src/main/java/com/tanpu/community/service/TopicService.java +++ b/community-service/src/main/java/com/tanpu/community/service/TopicService.java @@ -141,9 +141,15 @@ public class TopicService { } public void batchCheckPermission(List<TopicRankQo> content, String userId) { - if (StringUtils.isBlank(userId)) { - return; - } + Set<String> userPermitTopics = getUserPermitTopics(userId); + content.forEach(o -> { + if (userPermitTopics.contains(o.getTopicId())) { + o.setHasPermission(true); + } else { + o.setHasPermission(false); + } + }); + } @@ -176,8 +182,20 @@ public class TopicService { // return "该è¯é¢˜ä»…é™" + permission + "å¯å‚与哦~"; } - public String queryManagers(String topicId) { - return "å°çŽ‹ã€å°æŽã€å°åˆ˜"; + public String queryManagerNames(String topicId) { + + List<TopicManagerEntity> topicManagerEntities = topicManagerMapper.selectList(new LambdaQueryWrapper<TopicManagerEntity>().eq(TopicManagerEntity::getTopicId, topicId)); + + List<String> managerIds = topicManagerEntities.stream().map(TopicManagerEntity::getUserId).collect(Collectors.toList()); + + List<UserInfoResp> userList = feignService.getUserList(managerIds); + + if (CollectionUtils.isEmpty(userList)) { + return ""; + } + List<String> userNames = userList.stream().map(UserInfoResp::getNickName).collect(Collectors.toList()); + + return StringUtils.join(userNames, "ã€"); } public void queryAttachments(TopicPageDetailQo topic) { @@ -243,30 +261,18 @@ public class TopicService { public void checkManager(String topicId, List<ThemeQo> themes) { - String managerId = getManagerId(topicId); + Set<String> managerId = getManagerId(topicId); for (ThemeQo theme : themes) { - theme.setManager(theme.getAuthorId().equals(managerId)); + theme.setManager(managerId.contains(theme.getAuthorId())); } } - public String getManagerId(String topicId) { + public Set<String> getManagerId(String topicId) { if (StringUtils.isBlank(topicId)) { - return ""; + return new HashSet<>(); } - List<TopicManagerEntity> topicManagerEntities = topicManagerMapper.selectList(new LambdaQueryWrapper<TopicManagerEntity>().eq(TopicManagerEntity::getTopicId, topicId)); - - List<String> managerIds = topicManagerEntities.stream().map(TopicManagerEntity::getUserId).collect(Collectors.toList()); - - List<UserInfoResp> userList = feignService.getUserList(managerIds); - - if (CollectionUtils.isEmpty(userList)) { - return ""; - } - List<String> userNames = userList.stream().map(UserInfoResp::getNickName).collect(Collectors.toList()); - - return StringUtils.join(userNames, "ã€"); - + return topicManagerEntities.stream().map(TopicManagerEntity::getUserId).collect(Collectors.toSet()); } /**