refactor(resource): 调整评论排序逻辑和查询条件
parent
b4ae47cf28
commit
5b359ed6a3
|
@ -72,7 +72,7 @@ public class ModelCommentServiceImpl extends ServiceImpl<ModelCommentMapper, Mod
|
||||||
.isNull(ModelComment::getParentId);
|
.isNull(ModelComment::getParentId);
|
||||||
if (sortType == 0) {
|
if (sortType == 0) {
|
||||||
// 按点赞数降序,创建时间升序
|
// 按点赞数降序,创建时间升序
|
||||||
lqw.orderByAsc(ModelComment::getLikeNum)
|
lqw.orderByDesc(ModelComment::getLikeNum)
|
||||||
.orderByAsc(ModelComment::getCreateTime);
|
.orderByAsc(ModelComment::getCreateTime);
|
||||||
} else {
|
} else {
|
||||||
lqw.orderByDesc(ModelComment::getCreateTime);
|
lqw.orderByDesc(ModelComment::getCreateTime);
|
||||||
|
@ -121,6 +121,7 @@ public class ModelCommentServiceImpl extends ServiceImpl<ModelCommentMapper, Mod
|
||||||
// 获取所模型父评论
|
// 获取所模型父评论
|
||||||
List<ModelComment> modelCommentList = baseMapper.selectList(
|
List<ModelComment> modelCommentList = baseMapper.selectList(
|
||||||
new LambdaQueryWrapper<ModelComment>()
|
new LambdaQueryWrapper<ModelComment>()
|
||||||
|
.isNull(ModelComment::getParentId)
|
||||||
.eq(ModelComment::getModelId, modelId));
|
.eq(ModelComment::getModelId, modelId));
|
||||||
|
|
||||||
// 获取所有父评论的ID
|
// 获取所有父评论的ID
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.mcwl.common.core.domain.entity.SysUser;
|
import com.mcwl.common.core.domain.entity.SysUser;
|
||||||
import com.mcwl.common.utils.SecurityUtils;
|
import com.mcwl.common.utils.SecurityUtils;
|
||||||
|
import com.mcwl.resource.domain.ModelComment;
|
||||||
import com.mcwl.resource.domain.ModelImageComment;
|
import com.mcwl.resource.domain.ModelImageComment;
|
||||||
import com.mcwl.resource.domain.ModelImageCommentLike;
|
import com.mcwl.resource.domain.ModelImageCommentLike;
|
||||||
import com.mcwl.resource.domain.WorkFlowComment;
|
import com.mcwl.resource.domain.WorkFlowComment;
|
||||||
|
@ -64,7 +65,7 @@ public class ModelImageCommentServiceImpl extends ServiceImpl<ModelImageCommentM
|
||||||
.isNull(ModelImageComment::getParentId);
|
.isNull(ModelImageComment::getParentId);
|
||||||
if (sortType == 0) {
|
if (sortType == 0) {
|
||||||
// 按点赞数降序,创建时间升序
|
// 按点赞数降序,创建时间升序
|
||||||
lqw.orderByAsc(ModelImageComment::getLikeNum)
|
lqw.orderByDesc(ModelImageComment::getLikeNum)
|
||||||
.orderByAsc(ModelImageComment::getCreateTime);
|
.orderByAsc(ModelImageComment::getCreateTime);
|
||||||
} else {
|
} else {
|
||||||
lqw.orderByDesc(ModelImageComment::getCreateTime);
|
lqw.orderByDesc(ModelImageComment::getCreateTime);
|
||||||
|
@ -108,6 +109,7 @@ public class ModelImageCommentServiceImpl extends ServiceImpl<ModelImageCommentM
|
||||||
// 获取所有图片父评论
|
// 获取所有图片父评论
|
||||||
List<ModelImageComment> modelImageCommentList = baseMapper.selectList(
|
List<ModelImageComment> modelImageCommentList = baseMapper.selectList(
|
||||||
new LambdaQueryWrapper<ModelImageComment>()
|
new LambdaQueryWrapper<ModelImageComment>()
|
||||||
|
.isNull(ModelImageComment::getParentId)
|
||||||
.eq(ModelImageComment::getModelImageId, imageId));
|
.eq(ModelImageComment::getModelImageId, imageId));
|
||||||
|
|
||||||
// 获取所有父评论的ID
|
// 获取所有父评论的ID
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class WorkFlowCommentLikeServiceImpl extends ServiceImpl<WorkFlowCommentL
|
||||||
Long userId = SecurityUtils.getUserId();
|
Long userId = SecurityUtils.getUserId();
|
||||||
WorkFlowCommentLike workFlowCommentLike = baseMapper.getLikeComment(userId, commentId);
|
WorkFlowCommentLike workFlowCommentLike = baseMapper.getLikeComment(userId, commentId);
|
||||||
if (Objects.nonNull(workFlowCommentLike)) {
|
if (Objects.nonNull(workFlowCommentLike)) {
|
||||||
if (Objects.equals(workFlowComment.getDelFlag(), "0")) {
|
if (Objects.equals(workFlowCommentLike.getDelFlag(), "0")) {
|
||||||
workFlowCommentLike.setDelFlag("2");
|
workFlowCommentLike.setDelFlag("2");
|
||||||
int likeNum = workFlowComment.getLikeNum() - 1;
|
int likeNum = workFlowComment.getLikeNum() - 1;
|
||||||
likeNum = Math.max(likeNum, 0);
|
likeNum = Math.max(likeNum, 0);
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class WorkFlowCommentServiceImpl extends ServiceImpl<WorkFlowCommentMappe
|
||||||
.isNull(WorkFlowComment::getParentId);
|
.isNull(WorkFlowComment::getParentId);
|
||||||
if (sortType == 0) {
|
if (sortType == 0) {
|
||||||
// 按点赞数降序,创建时间升序
|
// 按点赞数降序,创建时间升序
|
||||||
lqw.orderByAsc(WorkFlowComment::getLikeNum)
|
lqw.orderByDesc(WorkFlowComment::getLikeNum)
|
||||||
.orderByAsc(WorkFlowComment::getCreateTime);
|
.orderByAsc(WorkFlowComment::getCreateTime);
|
||||||
} else {
|
} else {
|
||||||
lqw.orderByDesc(WorkFlowComment::getCreateTime);
|
lqw.orderByDesc(WorkFlowComment::getCreateTime);
|
||||||
|
@ -112,6 +112,7 @@ public class WorkFlowCommentServiceImpl extends ServiceImpl<WorkFlowCommentMappe
|
||||||
// 获取所工作流父评论
|
// 获取所工作流父评论
|
||||||
List<WorkFlowComment> modelCommentList = baseMapper.selectList(
|
List<WorkFlowComment> modelCommentList = baseMapper.selectList(
|
||||||
new LambdaQueryWrapper<WorkFlowComment>()
|
new LambdaQueryWrapper<WorkFlowComment>()
|
||||||
|
.isNull(WorkFlowComment::getParentId)
|
||||||
.eq(WorkFlowComment::getWorkFlowId, workFlowId));
|
.eq(WorkFlowComment::getWorkFlowId, workFlowId));
|
||||||
|
|
||||||
// 获取所有父评论的ID
|
// 获取所有父评论的ID
|
||||||
|
|
Loading…
Reference in New Issue