fix(community): getDetail 返回 isFollowed 字段,修复关注状态不持久(test-0415 反馈5-1)

- 此前仅回传 isLiked / isCollected,缺少 isFollowed
- 用户每次进入帖子页都显示「+ 关注」,重复点击导致 follow/unfollow 反复无感知
- 同时补全未登录场景的 isLiked/isCollected/isFollowed 默认 false

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
msh-agent
2026-05-03 02:30:50 +08:00
parent 82735a52b9
commit 5c0beeceb9

View File

@@ -372,6 +372,16 @@ public class ToolCommunityServiceImpl implements ToolCommunityService {
.eq(V2CommunityInteraction::getPostId, post.getPostId())
.eq(V2CommunityInteraction::getInteractionType, "collect");
map.put("isCollected", v2CommunityInteractionDao.selectCount(collectLqw) > 0);
// test-0415 反馈5-1关注状态需回传避免再次进入页面后按钮回到「+ 关注」
LambdaQueryWrapper<V2CommunityFollow> followLqw = new LambdaQueryWrapper<>();
followLqw.eq(V2CommunityFollow::getFollowerId, userId.longValue())
.eq(V2CommunityFollow::getFolloweeId, post.getUserId());
map.put("isFollowed", v2CommunityFollowDao.selectCount(followLqw) > 0);
} else {
map.put("isLiked", false);
map.put("isCollected", false);
map.put("isFollowed", false);
}
return map;