Browse Source

Merge remote-tracking branch 'origin/prod-5.1.3' into prod-5.1.3

zhongwei
haungxing 2 months ago
parent
commit
26894e8645
  1. 5
      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. 21
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/QuestionAnswerCommentServiceImpl.java
  4. 6
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/vo/AnswerCommentRequest.java
  5. 4
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/vo/AnswerPraiseRequest.java

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

@ -1,14 +1,11 @@
package com.hnac.gglm.bigmodel.maintenance.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
import org.springblade.core.tenant.mp.TenantEntity;
import org.springframework.data.annotation.Transient;
import java.io.Serializable;
@ -32,7 +29,7 @@ public class QuestionAnswerCommentEntity extends TenantEntity implements Seriali
@ApiModelProperty("用户id")
@TableField("user_id")
private Long userId;
private String userId;
@ApiModelProperty("用户账号")
@TableField(exist = false)

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
*/
public interface QuestionAnswerCommentService extends IService<QuestionAnswerCommentEntity> {
QuestionAnswerCommentEntity getComment(Long userId, String questionId);
QuestionAnswerCommentEntity getComment(String userId, String questionId);
Boolean comment(AnswerCommentRequest req);

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

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

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

@ -4,7 +4,6 @@ import com.hnac.gglm.bigmodel.maintenance.entity.QuestionAnswerCommentEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springblade.core.secure.utils.AuthUtil;
/**
* @Author: ypj
@ -22,12 +21,15 @@ public class AnswerCommentRequest {
@ApiModelProperty(value = "评论内容")
private String content;
@ApiModelProperty(value = "用户id")
private String userId;
public QuestionAnswerCommentEntity toEntity() {
QuestionAnswerCommentEntity entity = new QuestionAnswerCommentEntity();
entity.setChatId(chartId);
entity.setQuestionId(questionId);
entity.setContent(content);
entity.setUserId(AuthUtil.getUserId());
entity.setUserId(userId);
return entity;
}
}

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

@ -22,11 +22,15 @@ public class AnswerPraiseRequest {
@ApiModelProperty(value = "点赞,0取消点赞,1点赞")
private Integer praise;
@ApiModelProperty(value = "用户id")
private String userId;
public QuestionAnswerCommentEntity toEntity() {
QuestionAnswerCommentEntity entity = new QuestionAnswerCommentEntity();
entity.setChatId(chartId);
entity.setQuestionId(questionId);
entity.setPraise(praise);
entity.setUserId(userId);
return entity;
}
}

Loading…
Cancel
Save