Browse Source

add:问题点赞和评论

zhongwei
luyie 2 months ago
parent
commit
82f7cfed4a
  1. 7
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/QuestionAnswerCommentEntity.java
  2. 2
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/QuestionAnswerCommentService.java
  3. 11
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/QuestionAnswerCommentServiceImpl.java
  4. 2
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/vo/AnswerCommentRequest.java

7
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/QuestionAnswerCommentEntity.java

@ -8,6 +8,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
import org.springblade.core.tenant.mp.TenantEntity; import org.springblade.core.tenant.mp.TenantEntity;
import org.springframework.data.annotation.Transient;
import java.io.Serializable; import java.io.Serializable;
@ -31,10 +32,12 @@ public class QuestionAnswerCommentEntity extends TenantEntity implements Seriali
@ApiModelProperty("用户id") @ApiModelProperty("用户id")
@TableField("user_id") @TableField("user_id")
private String userId; private Long userId;
@ApiModelProperty("用户账号")
private String userAccount;
@ApiModelProperty("用户名") @ApiModelProperty("用户名")
@TableLogic
private String userName; private String userName;
@ApiModelProperty("点赞") @ApiModelProperty("点赞")

2
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/QuestionAnswerCommentService.java

@ -12,7 +12,7 @@ import java.util.List;
* @Date: 2024/9/21 13:29 * @Date: 2024/9/21 13:29
*/ */
public interface QuestionAnswerCommentService extends IService<QuestionAnswerCommentEntity> { public interface QuestionAnswerCommentService extends IService<QuestionAnswerCommentEntity> {
QuestionAnswerCommentEntity getComment(String userAccount, String questionId); QuestionAnswerCommentEntity getComment(Long userId, String questionId);
Boolean comment(AnswerCommentRequest req); Boolean comment(AnswerCommentRequest req);

11
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/QuestionAnswerCommentServiceImpl.java

@ -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);

2
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/vo/AnswerCommentRequest.java

@ -27,7 +27,7 @@ public class AnswerCommentRequest {
entity.setChatId(chartId); entity.setChatId(chartId);
entity.setQuestionId(questionId); entity.setQuestionId(questionId);
entity.setContent(content); entity.setContent(content);
entity.setUserId(AuthUtil.getUserAccount()); entity.setUserId(AuthUtil.getUserId());
return entity; return entity;
} }
} }

Loading…
Cancel
Save