|
|
@ -11,7 +11,6 @@ import com.hnac.gglm.bigmodel.maintenance.vo.AnswerCommentRequest; |
|
|
|
import com.hnac.gglm.bigmodel.maintenance.vo.AnswerPraiseRequest; |
|
|
|
import com.hnac.gglm.bigmodel.maintenance.vo.AnswerPraiseRequest; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springblade.core.secure.utils.AuthUtil; |
|
|
|
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
import org.springblade.core.tool.utils.ObjectUtil; |
|
|
|
import org.springblade.core.tool.utils.ObjectUtil; |
|
|
|
import org.springblade.system.user.entity.User; |
|
|
|
import org.springblade.system.user.entity.User; |
|
|
@ -32,7 +31,7 @@ public class QuestionAnswerCommentServiceImpl extends ServiceImpl<QuestionAnswer |
|
|
|
private final IUserClient userClient; |
|
|
|
private final IUserClient userClient; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public QuestionAnswerCommentEntity getComment(Long userId, String questionId) { |
|
|
|
public QuestionAnswerCommentEntity getComment(String userId, String questionId) { |
|
|
|
LambdaQueryWrapper<QuestionAnswerCommentEntity> queryWrapper = Wrappers.<QuestionAnswerCommentEntity>lambdaQuery() |
|
|
|
LambdaQueryWrapper<QuestionAnswerCommentEntity> queryWrapper = Wrappers.<QuestionAnswerCommentEntity>lambdaQuery() |
|
|
|
.eq(QuestionAnswerCommentEntity::getQuestionId, questionId) |
|
|
|
.eq(QuestionAnswerCommentEntity::getQuestionId, questionId) |
|
|
|
.eq(QuestionAnswerCommentEntity::getUserId, userId).last("limit 1"); |
|
|
|
.eq(QuestionAnswerCommentEntity::getUserId, userId).last("limit 1"); |
|
|
@ -41,7 +40,7 @@ public class QuestionAnswerCommentServiceImpl extends ServiceImpl<QuestionAnswer |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Boolean comment(AnswerCommentRequest req) { |
|
|
|
public Boolean comment(AnswerCommentRequest req) { |
|
|
|
QuestionAnswerCommentEntity entity = getComment(AuthUtil.getUserId(), |
|
|
|
QuestionAnswerCommentEntity entity = getComment(req.getUserId(), |
|
|
|
req.getQuestionId()); |
|
|
|
req.getQuestionId()); |
|
|
|
if (ObjectUtil.isEmpty(entity)) { |
|
|
|
if (ObjectUtil.isEmpty(entity)) { |
|
|
|
entity = req.toEntity(); |
|
|
|
entity = req.toEntity(); |
|
|
@ -53,7 +52,7 @@ public class QuestionAnswerCommentServiceImpl extends ServiceImpl<QuestionAnswer |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Boolean praise(AnswerPraiseRequest req) { |
|
|
|
public Boolean praise(AnswerPraiseRequest req) { |
|
|
|
QuestionAnswerCommentEntity entity = getComment(AuthUtil.getUserId(), |
|
|
|
QuestionAnswerCommentEntity entity = getComment(req.getUserId(), |
|
|
|
req.getQuestionId()); |
|
|
|
req.getQuestionId()); |
|
|
|
if (ObjectUtil.isNotEmpty(entity)) { |
|
|
|
if (ObjectUtil.isNotEmpty(entity)) { |
|
|
|
entity.setPraise(req.getPraise()); |
|
|
|
entity.setPraise(req.getPraise()); |
|
|
@ -70,11 +69,15 @@ public class QuestionAnswerCommentServiceImpl extends ServiceImpl<QuestionAnswer |
|
|
|
.eq(QuestionAnswerCommentEntity::getQuestionId, questionId) |
|
|
|
.eq(QuestionAnswerCommentEntity::getQuestionId, questionId) |
|
|
|
.orderByAsc(QuestionAnswerCommentEntity::getCreateTime)); |
|
|
|
.orderByAsc(QuestionAnswerCommentEntity::getCreateTime)); |
|
|
|
list.forEach(item -> { |
|
|
|
list.forEach(item -> { |
|
|
|
R<User> user = userClient.userInfoById(item.getUserId()); |
|
|
|
try { |
|
|
|
|
|
|
|
R<User> user = userClient.userInfoById(Long.parseLong(item.getUserId())); |
|
|
|
if (user.isSuccess() && user.getData() != null) { |
|
|
|
if (user.isSuccess() && user.getData() != null) { |
|
|
|
item.setUserName(user.getData().getName()); |
|
|
|
item.setUserName(user.getData().getName()); |
|
|
|
item.setUserAccount(user.getData().getAccount()); |
|
|
|
item.setUserAccount(user.getData().getAccount()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
log.error("获取用户信息失败", e); |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
return list; |
|
|
|
return list; |
|
|
|
} |
|
|
|
} |
|
|
@ -88,7 +91,7 @@ public class QuestionAnswerCommentServiceImpl extends ServiceImpl<QuestionAnswer |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Boolean resetPraise(AnswerPraiseRequest req) { |
|
|
|
public Boolean resetPraise(AnswerPraiseRequest req) { |
|
|
|
QuestionAnswerCommentEntity entity = getComment(AuthUtil.getUserId(), |
|
|
|
QuestionAnswerCommentEntity entity = getComment(req.getUserId(), |
|
|
|
req.getQuestionId()); |
|
|
|
req.getQuestionId()); |
|
|
|
if (ObjectUtil.isNotEmpty(entity)) { |
|
|
|
if (ObjectUtil.isNotEmpty(entity)) { |
|
|
|
entity.setPraise(0); |
|
|
|
entity.setPraise(0); |
|
|
|