|
@@ -14,7 +14,6 @@ import com.chelvc.cloud.vehicle.server.service.DynamicCommentService;
|
|
|
import com.chelvc.cloud.vehicle.server.service.DynamicContentService;
|
|
|
import com.chelvc.cloud.vehicle.server.service.DynamicEvaluateRecordService;
|
|
|
import com.chelvc.framework.common.exception.ResourceUnavailableException;
|
|
|
-import com.chelvc.framework.common.function.Executor;
|
|
|
import com.chelvc.framework.common.util.ObjectUtils;
|
|
|
import com.chelvc.framework.database.context.DatabaseContextHolder;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
@@ -26,6 +25,7 @@ import org.springframework.stereotype.Service;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
+import java.util.function.Supplier;
|
|
|
|
|
|
/**
|
|
|
* @PACKAGE_NAME: net.yeeu.collision.dynamic.service.impl
|
|
@@ -54,33 +54,35 @@ public class DynamicEvaluateRecordServiceImpl extends ServiceImpl<DynamicEvaluat
|
|
|
* 新增内容评价(点赞/踩)列
|
|
|
*/
|
|
|
@Override
|
|
|
- public Boolean updateRecord(AddDynamicEvaluateRecordParam param, Long userId) {
|
|
|
+ public Long updateRecord(AddDynamicEvaluateRecordParam param, Long userId) {
|
|
|
Integer actionType = param.getActionType().getValue();
|
|
|
Integer recordType = param.getRecordType().getValue();
|
|
|
Integer dynamicStatusType = param.getDynamicStatusType().getValue();
|
|
|
LambdaQueryWrapper<DynamicEvaluateRecord> lqw =
|
|
|
buildAddWrapper(param.getContentId(), userId);
|
|
|
- DatabaseContextHolder.transactional((Executor) () -> {
|
|
|
+ DatabaseContextHolder.transactional((Supplier<Long>) () -> {
|
|
|
+ Long num = 0L;
|
|
|
if (Objects.equals(ActionType.ADD.getValue(), actionType)) {
|
|
|
//判断该用户是否有点赞/踩记录,点击新增记录,取消删除记录
|
|
|
executeWrapper(lqw, param, true, userId);
|
|
|
if (Objects.equals(RecordType.COMMENT.getValue(), recordType)) {
|
|
|
- iDynamicCommentService.addNum(dynamicStatusType, param.getContentId());
|
|
|
+ num = iDynamicCommentService.addNum(dynamicStatusType, param.getContentId());
|
|
|
} else if (Objects.equals(RecordType.DYNAMIC.getValue(), recordType)) {
|
|
|
- iDynamicContentService.addNum(dynamicStatusType, param.getContentId());
|
|
|
+ num = iDynamicContentService.addNum(dynamicStatusType, param.getContentId());
|
|
|
}
|
|
|
} else if (Objects.equals(ActionType.CANCEL.getValue(), actionType)) {
|
|
|
lqw.eq(DynamicEvaluateRecord::getOperaterType, dynamicStatusType);
|
|
|
//判断该用户是否有点赞/踩记录,点击新增记录,取消删除记录
|
|
|
executeWrapper(lqw, param, false, userId);
|
|
|
if (Objects.equals(RecordType.COMMENT.getValue(), recordType)) {
|
|
|
- iDynamicCommentService.reduceNum(dynamicStatusType, param.getContentId());
|
|
|
+ num = iDynamicCommentService.reduceNum(dynamicStatusType, param.getContentId());
|
|
|
} else if (Objects.equals(RecordType.DYNAMIC.getValue(), recordType)) {
|
|
|
- iDynamicContentService.reduceNum(dynamicStatusType, param.getContentId());
|
|
|
+ num = iDynamicContentService.reduceNum(dynamicStatusType, param.getContentId());
|
|
|
}
|
|
|
}
|
|
|
+ return num;
|
|
|
});
|
|
|
- return true;
|
|
|
+ return 0L;
|
|
|
}
|
|
|
|
|
|
@Override
|