|
@@ -595,8 +595,9 @@ public class CommunityCommentController extends BaseController {
|
|
|
int offset = (pageNum - 1) * pageSize;
|
|
|
|
|
|
List<CommentVo> commentInfoByUserId = new ArrayList<>();
|
|
|
+ List<CommentVo> pagedList = new ArrayList<>();
|
|
|
try {
|
|
|
- commentInfoByUserId = communityArticleCommentService.getCommentInfoByUserId(userId, offset, pageSize, searchType);
|
|
|
+ commentInfoByUserId = communityArticleCommentService.getCommentInfoByUserId2(userId,searchType);
|
|
|
for (CommentVo commentVo : commentInfoByUserId) {
|
|
|
String type = String.valueOf(commentVo.getType());
|
|
|
String id = String.valueOf(commentVo.getId());
|
|
@@ -604,12 +605,20 @@ public class CommunityCommentController extends BaseController {
|
|
|
communityCommentController.updateMsgRead(type,id);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ int toIndex = Math.min(offset + pageSize, commentInfoByUserId.size());
|
|
|
+ // 检查是否越界,防止异常
|
|
|
+ if (offset >= commentInfoByUserId.size() || offset < 0) {
|
|
|
+ return success(new ArrayList<>()); // 返回空列表,避免异常
|
|
|
+ }
|
|
|
+ pagedList = commentInfoByUserId.subList(offset, toIndex);
|
|
|
+
|
|
|
}catch (Exception e) {
|
|
|
//e.printStackTrace();
|
|
|
System.out.println(e.getMessage());
|
|
|
throw new ProjectException();
|
|
|
}
|
|
|
- return success(commentInfoByUserId);
|
|
|
+ return success(pagedList);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -627,8 +636,9 @@ public class CommunityCommentController extends BaseController {
|
|
|
int offset = (pageNum - 1) * pageSize;
|
|
|
|
|
|
List<RecommendAndCollectVo> recommendAndCollectVos = new ArrayList<>();
|
|
|
+ List<RecommendAndCollectVo> pagedList = new ArrayList<>();
|
|
|
try {
|
|
|
- recommendAndCollectVos= communityArticleCollectMapper.selectRecommendAndCollectByUserId(userId, offset, pageSize, searchType);
|
|
|
+ recommendAndCollectVos= communityArticleCollectMapper.selectRecommendAndCollectByUserId2(userId, searchType);
|
|
|
|
|
|
for (RecommendAndCollectVo recommendAndCollectVo : recommendAndCollectVos) {
|
|
|
String type = String.valueOf(recommendAndCollectVo.getType());
|
|
@@ -637,12 +647,19 @@ public class CommunityCommentController extends BaseController {
|
|
|
communityCommentController.updateMsgRead(type,id);
|
|
|
}
|
|
|
}
|
|
|
+ int toIndex = Math.min(offset + pageSize, recommendAndCollectVos.size());
|
|
|
+ // 检查是否越界,防止异常
|
|
|
+ if (offset >= recommendAndCollectVos.size() || offset < 0) {
|
|
|
+ return success(new ArrayList<>()); // 返回空列表,避免异常
|
|
|
+ }
|
|
|
+ pagedList = recommendAndCollectVos.subList(offset, toIndex);
|
|
|
+
|
|
|
}catch (Exception e) {
|
|
|
//e.printStackTrace();
|
|
|
System.out.println(e.getMessage());
|
|
|
throw new ProjectException();
|
|
|
}
|
|
|
- return success(recommendAndCollectVos);
|
|
|
+ return success(pagedList);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -662,15 +679,16 @@ public class CommunityCommentController extends BaseController {
|
|
|
try {
|
|
|
//调用这个接口 刷新已读状态
|
|
|
likeVos = communityUserLikeMapper.selectLikeByUserId(userId, offset, pageSize, searchType);
|
|
|
- for (LikeVo likeVo : likeVos) {
|
|
|
- if (!likeVo.isRead()) {
|
|
|
- userLikeService.update(new UpdateWrapper<CommunityUserLike>()
|
|
|
- .set("is_read", true)
|
|
|
- .set("update_time", DateUtils.parseDate(DateUtils.getTime()))
|
|
|
- .set("update_by", SecurityUtils.getUserId())
|
|
|
- .eq("id", likeVo.getId()));
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+ userLikeService.update(new UpdateWrapper<CommunityUserLike>()
|
|
|
+ .set("is_read", true)
|
|
|
+ .set("update_time", DateUtils.parseDate(DateUtils.getTime()))
|
|
|
+ .set("update_by", SecurityUtils.getUserId())
|
|
|
+ .eq("like_user_id",userId)
|
|
|
+ .eq("is_read", false));
|
|
|
+
|
|
|
+
|
|
|
}catch (Exception e) {
|
|
|
//e.printStackTrace();
|
|
|
System.out.println(e.getMessage());
|