Commit 0252f076 authored by 刘基明's avatar 刘基明

话题权限

parent 4d3514d1
......@@ -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);
......
......@@ -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);
// 是否关注
......
......@@ -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());
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment