From 76f3d12cc7f119693b1e033e2adb6ea080bab1d4 Mon Sep 17 00:00:00 2001 From: gaosong Date: Mon, 8 Aug 2022 23:32:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=87=E6=A1=A3=E5=AF=B9?= =?UTF-8?q?=E6=AF=94-=E4=BF=AE=E6=94=B9=E6=AF=94=E5=AF=B9=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E4=B8=AD=E8=8B=B1=E6=96=87=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SarFileCompareResCommentController.java | 296 +++++++++--------- .../ISarFileCompareResCommentService.java | 2 + .../SarFileCompareResCommentServiceImpl.java | 39 ++- 3 files changed, 190 insertions(+), 147 deletions(-) diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/compare/controller/SarFileCompareResCommentController.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/compare/controller/SarFileCompareResCommentController.java index 560768a2b..31b1c3f8e 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/compare/controller/SarFileCompareResCommentController.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/compare/controller/SarFileCompareResCommentController.java @@ -1,184 +1,194 @@ package com.jero.modules.compare.controller; -import java.util.Arrays; -import java.util.List; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +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.common.api.vo.Result; +import com.jero.common.aspect.annotation.AutoLog; +import com.jero.common.system.base.controller.JeroController; import com.jero.common.system.query.QueryGenerator; import com.jero.modules.compare.entity.SarFileCompareResComVO; import com.jero.modules.compare.entity.SarFileCompareResComment; import com.jero.modules.compare.service.ISarFileCompareResCommentService; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; -import com.jero.common.system.base.controller.JeroController; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.ModelAndView; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import com.jero.common.aspect.annotation.AutoLog; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Arrays; +import java.util.List; - /** +/** * @Description: 文档对比信息结果评论表 * @Author: jero-boot - * @Date: 2022-08-05 + * @Date: 2022-08-05 * @Version: V1.0 */ -@Api(tags="文档对比信息结果评论表") +@Api(tags = "文档对比信息结果评论表") @RestController @RequestMapping("/compare/sarFileCompareResComment") @Slf4j public class SarFileCompareResCommentController extends JeroController { - @Autowired - private ISarFileCompareResCommentService sarFileCompareResCommentService; - - /** - * 分页列表查询 - * - * @param sarFileCompareResComment - * @param pageNo - * @param pageSize - * @param req - * @return - */ - @AutoLog(value = "文档对比信息结果评论表-分页列表查询") - @ApiOperation(value="文档对比信息结果评论表-分页列表查询", notes="文档对比信息结果评论表-分页列表查询") - @GetMapping(value = "/page") - public Result queryPageList(SarFileCompareResComment sarFileCompareResComment, - @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, - @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, - HttpServletRequest req) { - QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(sarFileCompareResComment, req.getParameterMap()); - Page page = new Page(pageNo, pageSize); - IPage pageList = sarFileCompareResCommentService.page(page, queryWrapper); - return Result.OK(pageList); - } + @Autowired + private ISarFileCompareResCommentService sarFileCompareResCommentService; /** - * 列表查询 - * - * @return - */ - @AutoLog(value = "文档对比信息结果评论表-列表查询") - @ApiOperation(value="文档对比信息结果评论表-列表查询", notes="文档对比信息结果评论表-列表查询") - @GetMapping(value = "/list") - public Result> queryList() { + * 分页列表查询 + * + * @param sarFileCompareResComment + * @param pageNo + * @param pageSize + * @param req + * @return + */ + @AutoLog(value = "文档对比信息结果评论表-分页列表查询") + @ApiOperation(value = "文档对比信息结果评论表-分页列表查询", notes = "文档对比信息结果评论表-分页列表查询") + @GetMapping(value = "/page") + public Result queryPageList(SarFileCompareResComment sarFileCompareResComment, + @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, + @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, + HttpServletRequest req) { + QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(sarFileCompareResComment, req.getParameterMap()); + Page page = new Page(pageNo, pageSize); + IPage pageList = sarFileCompareResCommentService.page(page, queryWrapper); + return Result.OK(pageList); + } + + /** + * 列表查询 + * + * @return + */ + @AutoLog(value = "文档对比信息结果评论表-列表查询") + @ApiOperation(value = "文档对比信息结果评论表-列表查询", notes = "文档对比信息结果评论表-列表查询") + @GetMapping(value = "/list") + public Result> queryList() { List list = sarFileCompareResCommentService.queryList(); return Result.OK(list); - } - - /** - * 添加 - * - * @param sarFileCompareResComment - * @return - */ - @AutoLog(value = "文档对比信息结果评论表-添加") - @ApiOperation(value="文档对比信息结果评论表-添加", notes="文档对比信息结果评论表-添加") - @PostMapping(value = "/add") - public Result add(@Validated @RequestBody SarFileCompareResComment sarFileCompareResComment) { - sarFileCompareResCommentService.add(sarFileCompareResComment); - return Result.OK("添加成功!"); - } - - /** - * 编辑 - * - * @param sarFileCompareResComment - * @return - */ - @AutoLog(value = "文档对比信息结果评论表-编辑") - @ApiOperation(value="文档对比信息结果评论表-编辑", notes="文档对比信息结果评论表-编辑") - @PutMapping(value = "/edit") - public Result edit(@Validated @RequestBody SarFileCompareResComment sarFileCompareResComment) { - sarFileCompareResCommentService.editById(sarFileCompareResComment); - return Result.OK("编辑成功!"); - } - - /** - * 通过id删除 - * - * @param id - * @return - */ - @AutoLog(value = "文档对比信息结果评论表-通过id删除") - @ApiOperation(value="文档对比信息结果评论表-通过id删除", notes="文档对比信息结果评论表-通过id删除") - @DeleteMapping(value = "/delete") - public Result delete(@RequestParam(name="id",required=true) String id) { - sarFileCompareResCommentService.deleteById(id); - return Result.OK("删除成功!"); - } - - /** - * 批量删除 - * - * @param ids - * @return - */ - @AutoLog(value = "文档对比信息结果评论表-批量删除") - @ApiOperation(value="文档对比信息结果评论表-批量删除", notes="文档对比信息结果评论表-批量删除") - @DeleteMapping(value = "/deleteBatch") - public Result deleteBatch(@RequestParam(name="ids",required=true) String ids) { - this.sarFileCompareResCommentService.deleteByIds(Arrays.asList(ids.split(","))); - return Result.OK("批量删除成功!"); - } - - /** - * 通过id查询 - * - * @param id - * @return - */ - @AutoLog(value = "文档对比信息结果评论表-通过id查询") - @ApiOperation(value="文档对比信息结果评论表-通过id查询", notes="文档对比信息结果评论表-通过id查询") - @GetMapping(value = "/queryById") - public Result queryById(@RequestParam(name="id",required=true) String id) { - SarFileCompareResComment sarFileCompareResComment = sarFileCompareResCommentService.queryById(id); - if(sarFileCompareResComment==null) { - return Result.error("未找到对应数据"); - } - return Result.OK(sarFileCompareResComment); - } + } /** - * 导出excel - * - * @param request - * @param sarFileCompareResComment - */ + * 添加 + * + * @param sarFileCompareResComment + * @return + */ + @AutoLog(value = "文档对比信息结果评论表-添加") + @ApiOperation(value = "文档对比信息结果评论表-添加", notes = "文档对比信息结果评论表-添加") + @PostMapping(value = "/add") + public Result add(@Validated @RequestBody SarFileCompareResComment sarFileCompareResComment) { + sarFileCompareResCommentService.add(sarFileCompareResComment); + return Result.OK("添加成功!"); + } + + /** + * 编辑 + * + * @param sarFileCompareResComment + * @return + */ + @AutoLog(value = "文档对比信息结果评论表-编辑") + @ApiOperation(value = "文档对比信息结果评论表-编辑", notes = "文档对比信息结果评论表-编辑") + @PutMapping(value = "/edit") + public Result edit(@Validated @RequestBody SarFileCompareResComment sarFileCompareResComment) { + sarFileCompareResCommentService.editById(sarFileCompareResComment); + return Result.OK("编辑成功!"); + } + + /** + * 通过id删除 + * + * @param id + * @return + */ + @AutoLog(value = "文档对比信息结果评论表-通过id删除") + @ApiOperation(value = "文档对比信息结果评论表-通过id删除", notes = "文档对比信息结果评论表-通过id删除") + @DeleteMapping(value = "/delete") + public Result delete(@RequestParam(name = "id", required = true) String id) { + sarFileCompareResCommentService.deleteById(id); + return Result.OK("删除成功!"); + } + + /** + * 批量删除 + * + * @param ids + * @return + */ + @AutoLog(value = "文档对比信息结果评论表-批量删除") + @ApiOperation(value = "文档对比信息结果评论表-批量删除", notes = "文档对比信息结果评论表-批量删除") + @DeleteMapping(value = "/deleteBatch") + public Result deleteBatch(@RequestParam(name = "ids", required = true) String ids) { + this.sarFileCompareResCommentService.deleteByIds(Arrays.asList(ids.split(","))); + return Result.OK("批量删除成功!"); + } + + /** + * 通过id查询 + * + * @param id + * @return + */ + @AutoLog(value = "文档对比信息结果评论表-通过id查询") + @ApiOperation(value = "文档对比信息结果评论表-通过id查询", notes = "文档对比信息结果评论表-通过id查询") + @GetMapping(value = "/queryById") + public Result queryById(@RequestParam(name = "id", required = true) String id) { + SarFileCompareResComment sarFileCompareResComment = sarFileCompareResCommentService.queryById(id); + if (sarFileCompareResComment == null) { + return Result.error("未找到对应数据"); + } + return Result.OK(sarFileCompareResComment); + } + + /** + * 导出excel + * + * @param request + * @param sarFileCompareResComment + */ @RequestMapping(value = "/exportXls") public ModelAndView exportXls(HttpServletRequest request, SarFileCompareResComment sarFileCompareResComment) { return super.exportXls(request, sarFileCompareResComment, SarFileCompareResComment.class, "文档对比信息结果评论表"); } /** - * 通过excel导入数据 - * - * @param request - * @param response - * @return - */ + * 通过excel导入数据 + * + * @param request + * @param response + * @return + */ @RequestMapping(value = "/importExcel", method = RequestMethod.POST) public Result importExcel(HttpServletRequest request, HttpServletResponse response) { return super.importExcel(request, response, SarFileCompareResComment.class); } - /** - * 根据infoId查询列表 - * - * @return - */ - @AutoLog(value = "文档对比信息结果评论表-根据infoId查询列表") - @ApiOperation(value="文档对比信息结果评论表-根据infoId查询列表", notes="文档对比信息结果评论表-根据infoId查询列表") - @GetMapping(value = "/queryListByInfoId") - public Result> queryListByInfoId(@RequestParam(name="id",required=true) String id) { - List list = sarFileCompareResCommentService.queryListByInfoId(id); - return Result.OK(list); - } + /** + * 根据infoId查询列表 + * + * @return + */ + @AutoLog(value = "文档对比信息结果评论表-根据infoId查询列表") + @ApiOperation(value = "文档对比信息结果评论表-根据infoId查询列表", notes = "文档对比信息结果评论表-根据infoId查询列表") + @GetMapping(value = "/queryListByInfoId") + public Result> queryListByInfoId(@RequestParam(name = "id", required = true) String id) { + List list = sarFileCompareResCommentService.queryListByInfoId(id); + return Result.OK(list); + } + + @AutoLog(value = "文档对比信息结果评论表-搜索评论") + @ApiOperation(value = "文档对比信息结果评论表-搜索评论", notes = "文档对比信息结果评论表-搜索评论") + @GetMapping(value = "/searchResComment") + public Result> searchResComment(@RequestParam(name = "id", required = true) String id, + @RequestParam(name = "str", required = true) String str) { + List list = sarFileCompareResCommentService.searchResComment(id, str); + return Result.OK(list); + } } diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/compare/service/ISarFileCompareResCommentService.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/compare/service/ISarFileCompareResCommentService.java index 445eb8771..96067e89f 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/compare/service/ISarFileCompareResCommentService.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/compare/service/ISarFileCompareResCommentService.java @@ -61,4 +61,6 @@ public interface ISarFileCompareResCommentService extends IService queryList(); List queryListByInfoId(String id); + + List searchResComment(String id, String str); } diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/compare/service/impl/SarFileCompareResCommentServiceImpl.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/compare/service/impl/SarFileCompareResCommentServiceImpl.java index 1a46d8fa1..6458afafb 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/compare/service/impl/SarFileCompareResCommentServiceImpl.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/compare/service/impl/SarFileCompareResCommentServiceImpl.java @@ -2,6 +2,7 @@ package com.jero.modules.compare.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.google.common.collect.Lists; import com.jero.modules.compare.entity.SarFileCompareResComVO; import com.jero.modules.compare.entity.SarFileCompareResComment; import com.jero.modules.compare.mapper.SarFileCompareResCommentMapper; @@ -10,9 +11,7 @@ import com.jero.modules.system.util.StringUtils; import org.springframework.stereotype.Service; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; +import java.util.*; /** * @Description: 文档对比信息结果评论表 @@ -125,5 +124,37 @@ public class SarFileCompareResCommentServiceImpl extends ServiceImpl searchResComment(String id, String str) { + if (StringUtils.isBlank(str)) { + return queryListByInfoId(id); + } + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(SarFileCompareResComment::getInfoId, id); + queryWrapper.like(SarFileCompareResComment::getComment, str); + queryWrapper.orderBy(true, true, SarFileCompareResComment::getCreateTime); + List list = this.list(queryWrapper); + Map resCommentMap = new HashMap<>(); + List subList = new ArrayList<>(); + //先找到一级评论 + for (SarFileCompareResComment rc : list) { + if (StringUtils.isEmpty(rc.getParentId())) { + resCommentMap.put(rc.getId(), wrapperSarFileCompareResComVO(rc)); + } else { + subList.add(rc); + } + } + //把回复评论放进一级评论下,没有一级评论要查出来放上 + for (SarFileCompareResComment rc : subList) { + if (resCommentMap.keySet().contains(rc.getParentId())) { + resCommentMap.get(rc.getParentId()).addResComVo(wrapperSarFileCompareResComVO(rc)); + } else { + SarFileCompareResComment prc = this.queryById(rc.getParentId()); + SarFileCompareResComVO prcVo = wrapperSarFileCompareResComVO(prc); + prcVo.addResComVo(wrapperSarFileCompareResComVO(rc)); + resCommentMap.put(prcVo.getId(), prcVo); + } + } + return Lists.newArrayList(resCommentMap.values()); + } }