Browse Source

fix:问题评价写入问题日志表

zhongwei
luyie 2 months ago
parent
commit
16bdf48eab
  1. 27
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/constants/CommentType.java
  2. 12
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/QuestionAnswerCommentServiceImpl.java

27
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/constants/CommentType.java

@ -0,0 +1,27 @@
package com.hnac.gglm.bigmodel.maintenance.constants;
import lombok.Getter;
/**
* @Author: ypj
* @Date: 2024/10/10 10:21
*/
@Getter
public enum CommentType {
CRITICAL(0, "差评"),
PRAISE(1, "好评");
private final int code;
private final String msg;
CommentType(int code, String msg) {
this.code = code;
this.msg = msg;
}
public static CommentType getInstance(int code) {
for (CommentType item : CommentType.values()) {
if (item.getCode() == code) {
return item;
}
}
return null;
}
}

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

@ -4,8 +4,10 @@ import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.gglm.bigmodel.maintenance.entity.AgentLogEntity;
import com.hnac.gglm.bigmodel.maintenance.entity.QuestionAnswerCommentEntity;
import com.hnac.gglm.bigmodel.maintenance.mapper.QuestionAnswerCommentMapper;
import com.hnac.gglm.bigmodel.maintenance.service.AgentLogService;
import com.hnac.gglm.bigmodel.maintenance.service.QuestionAnswerCommentService;
import com.hnac.gglm.bigmodel.maintenance.vo.AnswerCommentRequest;
import com.hnac.gglm.bigmodel.maintenance.vo.AnswerPraiseRequest;
@ -29,6 +31,7 @@ import java.util.List;
@DS("hznlm")
public class QuestionAnswerCommentServiceImpl extends ServiceImpl<QuestionAnswerCommentMapper, QuestionAnswerCommentEntity> implements QuestionAnswerCommentService {
private final IUserClient userClient;
private final AgentLogService agentLogService;
@Override
public QuestionAnswerCommentEntity getComment(String userId, String questionId) {
@ -54,13 +57,18 @@ public class QuestionAnswerCommentServiceImpl extends ServiceImpl<QuestionAnswer
public Boolean praise(AnswerPraiseRequest req) {
QuestionAnswerCommentEntity entity = getComment(req.getUserId(),
req.getQuestionId());
Boolean result;
if (ObjectUtil.isNotEmpty(entity)) {
entity.setPraise(req.getPraise());
return this.updateById(entity);
result = this.updateById(entity);
} else {
entity = req.toEntity();
return this.save(entity);
result = this.save(entity);
}
if (ObjectUtil.isNotEmpty(req.getPraise()) && ObjectUtil.isNotEmpty(req.getQuestionId())) {
agentLogService.update(Wrappers.<AgentLogEntity>lambdaUpdate().set(AgentLogEntity::getUserConclusion, req.getPraise()).eq(AgentLogEntity::getQId, req.getQuestionId()));
}
return result;
}
@Override

Loading…
Cancel
Save