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