refactor(resource): 调整评论排序逻辑和查询条件

master
yang 2025-02-13 11:21:34 +08:00
parent b4ae47cf28
commit 5b359ed6a3
4 changed files with 8 additions and 4 deletions

View File

@ -72,7 +72,7 @@ public class ModelCommentServiceImpl extends ServiceImpl<ModelCommentMapper, Mod
.isNull(ModelComment::getParentId);
if (sortType == 0) {
// 按点赞数降序,创建时间升序
lqw.orderByAsc(ModelComment::getLikeNum)
lqw.orderByDesc(ModelComment::getLikeNum)
.orderByAsc(ModelComment::getCreateTime);
} else {
lqw.orderByDesc(ModelComment::getCreateTime);
@ -121,6 +121,7 @@ public class ModelCommentServiceImpl extends ServiceImpl<ModelCommentMapper, Mod
// 获取所模型父评论
List<ModelComment> modelCommentList = baseMapper.selectList(
new LambdaQueryWrapper<ModelComment>()
.isNull(ModelComment::getParentId)
.eq(ModelComment::getModelId, modelId));
// 获取所有父评论的ID

View File

@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mcwl.common.core.domain.entity.SysUser;
import com.mcwl.common.utils.SecurityUtils;
import com.mcwl.resource.domain.ModelComment;
import com.mcwl.resource.domain.ModelImageComment;
import com.mcwl.resource.domain.ModelImageCommentLike;
import com.mcwl.resource.domain.WorkFlowComment;
@ -64,7 +65,7 @@ public class ModelImageCommentServiceImpl extends ServiceImpl<ModelImageCommentM
.isNull(ModelImageComment::getParentId);
if (sortType == 0) {
// 按点赞数降序,创建时间升序
lqw.orderByAsc(ModelImageComment::getLikeNum)
lqw.orderByDesc(ModelImageComment::getLikeNum)
.orderByAsc(ModelImageComment::getCreateTime);
} else {
lqw.orderByDesc(ModelImageComment::getCreateTime);
@ -108,6 +109,7 @@ public class ModelImageCommentServiceImpl extends ServiceImpl<ModelImageCommentM
// 获取所有图片父评论
List<ModelImageComment> modelImageCommentList = baseMapper.selectList(
new LambdaQueryWrapper<ModelImageComment>()
.isNull(ModelImageComment::getParentId)
.eq(ModelImageComment::getModelImageId, imageId));
// 获取所有父评论的ID

View File

@ -39,7 +39,7 @@ public class WorkFlowCommentLikeServiceImpl extends ServiceImpl<WorkFlowCommentL
Long userId = SecurityUtils.getUserId();
WorkFlowCommentLike workFlowCommentLike = baseMapper.getLikeComment(userId, commentId);
if (Objects.nonNull(workFlowCommentLike)) {
if (Objects.equals(workFlowComment.getDelFlag(), "0")) {
if (Objects.equals(workFlowCommentLike.getDelFlag(), "0")) {
workFlowCommentLike.setDelFlag("2");
int likeNum = workFlowComment.getLikeNum() - 1;
likeNum = Math.max(likeNum, 0);

View File

@ -69,7 +69,7 @@ public class WorkFlowCommentServiceImpl extends ServiceImpl<WorkFlowCommentMappe
.isNull(WorkFlowComment::getParentId);
if (sortType == 0) {
// 按点赞数降序,创建时间升序
lqw.orderByAsc(WorkFlowComment::getLikeNum)
lqw.orderByDesc(WorkFlowComment::getLikeNum)
.orderByAsc(WorkFlowComment::getCreateTime);
} else {
lqw.orderByDesc(WorkFlowComment::getCreateTime);
@ -112,6 +112,7 @@ public class WorkFlowCommentServiceImpl extends ServiceImpl<WorkFlowCommentMappe
// 获取所工作流父评论
List<WorkFlowComment> modelCommentList = baseMapper.selectList(
new LambdaQueryWrapper<WorkFlowComment>()
.isNull(WorkFlowComment::getParentId)
.eq(WorkFlowComment::getWorkFlowId, workFlowId));
// 获取所有父评论的ID