|
@@ -125,6 +125,10 @@ public class CommunityArticleController extends BaseController {
|
|
|
@Autowired
|
|
|
private CommunityArticleAtMapper communityArticleAtMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private CommunityArticleRecommendMapper recommendMapper;
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 生成唯一的缓存键(基于请求参数)
|
|
|
*/
|
|
@@ -1306,6 +1310,24 @@ public class CommunityArticleController extends BaseController {
|
|
|
}
|
|
|
try {
|
|
|
communityArticleVos = communityArticleService.selectUserLike(userId, pageNum, pageSize, searchType);
|
|
|
+
|
|
|
+ for (CommunityArticleVo communityArticleVo : communityArticleVos) {
|
|
|
+ //判断当前查询用户有没有喜欢该文章
|
|
|
+ CommunityLike like = communityLikeMapper.selectOne(
|
|
|
+ new QueryWrapper<CommunityLike>()
|
|
|
+ .eq("user_id", SecurityUtils.getUserId())
|
|
|
+ .eq("article_id", communityArticleVo.getId()));
|
|
|
+
|
|
|
+ communityArticleVo.setLike(!Objects.isNull(like));
|
|
|
+
|
|
|
+ //判断是否已推荐
|
|
|
+ CommunityArticleRecommend recommend = recommendMapper.selectOne(new QueryWrapper<CommunityArticleRecommend>()
|
|
|
+ .eq("user_id", SecurityUtils.getUserId())
|
|
|
+ .eq("article_id", communityArticleVo.getId()).and((wrapper) -> {
|
|
|
+ wrapper.ne("is_delete", true).or().isNull("is_delete");
|
|
|
+ }));
|
|
|
+ communityArticleVo.setRecommend(!Objects.isNull(recommend));
|
|
|
+ }
|
|
|
} catch (Exception e) {
|
|
|
System.out.println(e.getMessage());
|
|
|
throw new ProjectException();
|
|
@@ -1327,6 +1349,25 @@ public class CommunityArticleController extends BaseController {
|
|
|
userId = SecurityUtils.getUserId();
|
|
|
}
|
|
|
communityArticleVos = communityArticleService.selectUserCollect(userId, pageNum, pageSize, searchType);
|
|
|
+
|
|
|
+
|
|
|
+ for (CommunityArticleVo communityArticleVo : communityArticleVos) {
|
|
|
+ //判断当前查询用户有没有喜欢该文章
|
|
|
+ CommunityLike like = communityLikeMapper.selectOne(
|
|
|
+ new QueryWrapper<CommunityLike>()
|
|
|
+ .eq("user_id", SecurityUtils.getUserId())
|
|
|
+ .eq("article_id", communityArticleVo.getId()));
|
|
|
+
|
|
|
+ communityArticleVo.setLike(!Objects.isNull(like));
|
|
|
+
|
|
|
+ //判断是否已推荐
|
|
|
+ CommunityArticleRecommend recommend = recommendMapper.selectOne(new QueryWrapper<CommunityArticleRecommend>()
|
|
|
+ .eq("user_id", SecurityUtils.getUserId())
|
|
|
+ .eq("article_id", communityArticleVo.getId()).and((wrapper) -> {
|
|
|
+ wrapper.ne("is_delete", true).or().isNull("is_delete");
|
|
|
+ }));
|
|
|
+ communityArticleVo.setRecommend(!Objects.isNull(recommend));
|
|
|
+ }
|
|
|
} catch (Exception e) {
|
|
|
System.out.println(e.getMessage());
|
|
|
throw new ProjectException();
|