fix:修复点赞取消点赞产生脏数据Bug

This commit is contained in:
2023-05-09 17:19:38 +08:00
parent 67f3555c7a
commit e5545d76bb
@@ -10,6 +10,7 @@ import com.adc.da.report.vo.ReportDetailThumbUpVo;
import com.adc.da.report.vo.ReportLogPageVO;
import com.adc.da.util.utils.StringUtils;
import com.adc.da.util.utils.UUID;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
@@ -167,8 +168,12 @@ public class IReportLogBookServiceImpl extends ServiceImpl<ReportLogBookDao, Rep
return reportLogBook.getId();
}
private void thumbDown(String logId) {
removeById(logId);
private void thumbDown(String reportId) {
LambdaQueryWrapper<ReportLogBook> reportLogBookLambdaQueryWrapper = new LambdaQueryWrapper<>();
reportLogBookLambdaQueryWrapper.eq(ReportLogBook::getReportId, reportId);
reportLogBookLambdaQueryWrapper.eq(ReportLogBook::getType, 3);
reportLogBookLambdaQueryWrapper.eq(ReportLogBook::getUserId, UserUtils.getUserId());
remove(reportLogBookLambdaQueryWrapper);
}
@Override
@@ -179,7 +184,7 @@ public class IReportLogBookServiceImpl extends ServiceImpl<ReportLogBookDao, Rep
String logId = thumbUp(reportId);
reportDetailThumbUpVo.setLogId(logId);
} else {
thumbDown(entity.getId());
thumbDown(reportId);
}
//计算已有点赞数
Integer count = getThumbUpCount(reportId);