问题知识库-详情查看评论接口开发。

This commit is contained in:
wangzhijiang
2022-09-07 14:54:29 +08:00
parent 655c0c3b86
commit 22ccdae002
4 changed files with 113 additions and 2 deletions
@@ -11,6 +11,7 @@ import com.jero.modules.problemKnowledgeBase.service.IProblemKnowledgeBaseCommen
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jero.modules.problemKnowledgeBase.vo.ProblemKnowledgeBaseCommentVO;
import lombok.extern.slf4j.Slf4j;
import com.jero.common.system.base.controller.JeroController;
import org.springframework.beans.factory.annotation.Autowired;
@@ -67,8 +68,8 @@ public class ProblemKnowledgeBaseCommentEOController extends JeroController<Prob
@AutoLog(value = "问题知识库评论表-列表查询")
@ApiOperation(value="问题知识库评论表-列表查询", notes="问题知识库评论表-列表查询")
@GetMapping(value = "/list")
public Result<List<ProblemKnowledgeBaseCommentEO>> queryList(ProblemKnowledgeBaseCommentEO problemKnowledgeBaseCommentEO,HttpServletRequest req) {
List<ProblemKnowledgeBaseCommentEO> list = problemKnowledgeBaseCommentEOService.queryList(problemKnowledgeBaseCommentEO,req);
public Result<List<ProblemKnowledgeBaseCommentVO>> queryList(ProblemKnowledgeBaseCommentEO problemKnowledgeBaseCommentEO, HttpServletRequest req) {
List<ProblemKnowledgeBaseCommentVO> list = this.problemKnowledgeBaseCommentEOService.getInfoList(problemKnowledgeBaseCommentEO,req);
return Result.OK(list);
}
@@ -2,6 +2,7 @@ package com.jero.modules.problemKnowledgeBase.service;
import com.jero.modules.problemKnowledgeBase.entity.ProblemKnowledgeBaseCommentEO;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jero.modules.problemKnowledgeBase.vo.ProblemKnowledgeBaseCommentVO;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
@@ -60,4 +61,6 @@ public interface IProblemKnowledgeBaseCommentEOService extends IService<ProblemK
* @return
*/
List<ProblemKnowledgeBaseCommentEO> queryList(ProblemKnowledgeBaseCommentEO problemKnowledgeBaseCommentEO, HttpServletRequest req);
List<ProblemKnowledgeBaseCommentVO> getInfoList(ProblemKnowledgeBaseCommentEO problemKnowledgeBaseCommentEO, HttpServletRequest req);
}
@@ -5,9 +5,20 @@ import com.jero.common.system.query.QueryGenerator;
import com.jero.modules.problemKnowledgeBase.entity.ProblemKnowledgeBaseCommentEO;
import com.jero.modules.problemKnowledgeBase.mapper.ProblemKnowledgeBaseCommentEOMapper;
import com.jero.modules.problemKnowledgeBase.service.IProblemKnowledgeBaseCommentEOService;
import com.jero.modules.problemKnowledgeBase.vo.ProblemKnowledgeBaseCommentVO;
import com.jero.modules.project.entity.ProblemKnowledgeBaseReplyEO;
import com.jero.modules.project.service.IProblemKnowledgeBaseReplyEOService;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Date;
import java.util.stream.Collectors;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
@@ -24,6 +35,8 @@ import javax.servlet.http.HttpServletRequest;
@Transactional(value = "transactionManager", readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
public class ProblemKnowledgeBaseCommentEOServiceImpl extends ServiceImpl<ProblemKnowledgeBaseCommentEOMapper, ProblemKnowledgeBaseCommentEO> implements IProblemKnowledgeBaseCommentEOService {
@Autowired
private IProblemKnowledgeBaseReplyEOService problemKnowledgeBaseReplyEOService;
/**
* 保存
*
@@ -96,4 +109,36 @@ public class ProblemKnowledgeBaseCommentEOServiceImpl extends ServiceImpl<Proble
List<ProblemKnowledgeBaseCommentEO> result = this.list(queryWrapper);
return result;
}
@Override
public List<ProblemKnowledgeBaseCommentVO> getInfoList(ProblemKnowledgeBaseCommentEO problemKnowledgeBaseCommentEO, HttpServletRequest req) {
List<ProblemKnowledgeBaseCommentVO> result = new ArrayList<>();
List<ProblemKnowledgeBaseCommentEO> problemKnowledgeBaseCommentEOList = this.queryList(problemKnowledgeBaseCommentEO, req);
if(CollectionUtils.isNotEmpty(problemKnowledgeBaseCommentEOList)){
List<String> commentIdList = problemKnowledgeBaseCommentEOList.stream().map(ProblemKnowledgeBaseCommentEO::getId).distinct().collect(Collectors.toList());
QueryWrapper<ProblemKnowledgeBaseReplyEO> replyQueryWrapper = new QueryWrapper<>();
replyQueryWrapper.lambda().in(ProblemKnowledgeBaseReplyEO::getCommentId,commentIdList);
List<ProblemKnowledgeBaseReplyEO> problemKnowledgeBaseReplyEOList = this.problemKnowledgeBaseReplyEOService.list(replyQueryWrapper);
problemKnowledgeBaseCommentEOList.forEach(commentEO -> {
List<ProblemKnowledgeBaseCommentVO> commentVOList = new ArrayList<>();
problemKnowledgeBaseReplyEOList.forEach(replyEO -> {
if(StringUtils.equals(commentEO.getId(),replyEO.getCommentId())){
ProblemKnowledgeBaseCommentVO commentVO = new ProblemKnowledgeBaseCommentVO();
BeanUtils.copyProperties(replyEO, commentVO);
commentVO.setCommentContent(replyEO.getReplyContent());
commentVOList.add(commentVO);
}
});
ProblemKnowledgeBaseCommentVO commentVO = new ProblemKnowledgeBaseCommentVO();
BeanUtils.copyProperties(commentEO, commentVO);
commentVO.setProblemKnowledgeBaseCommentVOList(commentVOList);
result.add(commentVO);
});
}
return result;
}
}
@@ -0,0 +1,62 @@
package com.jero.modules.problemKnowledgeBase.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.List;
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="problem_knowledge_base_comment对象", description="问题知识库评论表")
public class ProblemKnowledgeBaseCommentVO implements Serializable {
private static final long serialVersionUID = 1L;
/**主键*/
@ApiModelProperty(value = "主键")
private java.lang.String id;
/**创建人*/
@ApiModelProperty(value = "创建人")
private java.lang.String createBy;
/**创建日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建日期")
private java.util.Date createTime;
/**更新人*/
@ApiModelProperty(value = "更新人")
private java.lang.String updateBy;
/**更新日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "更新日期")
private java.util.Date updateTime;
/**所属部门*/
@ApiModelProperty(value = "所属部门")
private java.lang.String sysOrgCode;
/**问题知识库id*/
@ApiModelProperty(value = "问题知识库id")
private java.lang.String problemKnowledgeBaseId;
/**评论内容*/
@ApiModelProperty(value = "评论内容")
private java.lang.String commentContent;
/**评论用户id*/
@ApiModelProperty(value = "评论用户id")
private java.lang.String commentUserId;
private List<ProblemKnowledgeBaseCommentVO> problemKnowledgeBaseCommentVOList;
}