|
|
|
@ -27,16 +27,16 @@ import java.util.List;
|
|
|
|
|
@DS("hznlm") |
|
|
|
|
public class QuestionAnswerCommentServiceImpl extends ServiceImpl<QuestionAnswerCommentMapper, QuestionAnswerCommentEntity> implements QuestionAnswerCommentService { |
|
|
|
|
@Override |
|
|
|
|
public QuestionAnswerCommentEntity getComment(String userAccount, String questionId) { |
|
|
|
|
public QuestionAnswerCommentEntity getComment(Long userId, String questionId) { |
|
|
|
|
LambdaQueryWrapper<QuestionAnswerCommentEntity> queryWrapper = Wrappers.<QuestionAnswerCommentEntity>lambdaQuery() |
|
|
|
|
.eq(QuestionAnswerCommentEntity::getQuestionId, questionId) |
|
|
|
|
.eq(QuestionAnswerCommentEntity::getUserId, userAccount).last("limit 1"); |
|
|
|
|
.eq(QuestionAnswerCommentEntity::getUserId, userId).last("limit 1"); |
|
|
|
|
return this.getOne(queryWrapper); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Boolean comment(AnswerCommentRequest req) { |
|
|
|
|
QuestionAnswerCommentEntity entity = getComment(AuthUtil.getUserAccount(), |
|
|
|
|
QuestionAnswerCommentEntity entity = getComment(AuthUtil.getUserId(), |
|
|
|
|
req.getQuestionId()); |
|
|
|
|
if (ObjectUtil.isEmpty(entity)) { |
|
|
|
|
entity = req.toEntity(); |
|
|
|
@ -46,7 +46,7 @@ public class QuestionAnswerCommentServiceImpl extends ServiceImpl<QuestionAnswer
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Boolean praise(AnswerPraiseRequest req) { |
|
|
|
|
QuestionAnswerCommentEntity entity = getComment(AuthUtil.getUserAccount(), |
|
|
|
|
QuestionAnswerCommentEntity entity = getComment(AuthUtil.getUserId(), |
|
|
|
|
req.getQuestionId()); |
|
|
|
|
if (ObjectUtil.isNotEmpty(entity)) { |
|
|
|
|
entity.setPraise(req.getPraise()); |
|
|
|
@ -57,6 +57,7 @@ public class QuestionAnswerCommentServiceImpl extends ServiceImpl<QuestionAnswer
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<QuestionAnswerCommentEntity> listByQuestionId(String questionId) { |
|
|
|
|
|
|
|
|
|
return this.list(Wrappers.<QuestionAnswerCommentEntity>lambdaQuery() |
|
|
|
|
.eq(QuestionAnswerCommentEntity::getQuestionId, questionId) |
|
|
|
|
.orderByAsc(QuestionAnswerCommentEntity::getCreateTime)); |
|
|
|
@ -71,7 +72,7 @@ public class QuestionAnswerCommentServiceImpl extends ServiceImpl<QuestionAnswer
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Boolean resetPraise(AnswerPraiseRequest req) { |
|
|
|
|
QuestionAnswerCommentEntity entity = getComment(AuthUtil.getUserAccount(), |
|
|
|
|
QuestionAnswerCommentEntity entity = getComment(AuthUtil.getUserId(), |
|
|
|
|
req.getQuestionId()); |
|
|
|
|
if (ObjectUtil.isNotEmpty(entity)) { |
|
|
|
|
entity.setPraise(0); |
|
|
|
|