修改文档对比-修改比对信息中英文显示

This commit is contained in:
gaosong
2022-08-08 23:32:48 +08:00
parent a85314bfcb
commit 76f3d12cc7
3 changed files with 190 additions and 147 deletions
@@ -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<SarFileCompareResComment, ISarFileCompareResCommentService> {
@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<SarFileCompareResComment> queryWrapper = QueryGenerator.initQueryWrapper(sarFileCompareResComment, req.getParameterMap());
Page<SarFileCompareResComment> page = new Page<SarFileCompareResComment>(pageNo, pageSize);
IPage<SarFileCompareResComment> pageList = sarFileCompareResCommentService.page(page, queryWrapper);
return Result.OK(pageList);
}
@Autowired
private ISarFileCompareResCommentService sarFileCompareResCommentService;
/**
* 列表查询
*
* @return
*/
@AutoLog(value = "文档对比信息结果评论表-列表查询")
@ApiOperation(value="文档对比信息结果评论表-列表查询", notes="文档对比信息结果评论表-列表查询")
@GetMapping(value = "/list")
public Result<List<SarFileCompareResComment>> 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<SarFileCompareResComment> queryWrapper = QueryGenerator.initQueryWrapper(sarFileCompareResComment, req.getParameterMap());
Page<SarFileCompareResComment> page = new Page<SarFileCompareResComment>(pageNo, pageSize);
IPage<SarFileCompareResComment> pageList = sarFileCompareResCommentService.page(page, queryWrapper);
return Result.OK(pageList);
}
/**
* 列表查询
*
* @return
*/
@AutoLog(value = "文档对比信息结果评论表-列表查询")
@ApiOperation(value = "文档对比信息结果评论表-列表查询", notes = "文档对比信息结果评论表-列表查询")
@GetMapping(value = "/list")
public Result<List<SarFileCompareResComment>> queryList() {
List<SarFileCompareResComment> 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<List<SarFileCompareResComVO>> queryListByInfoId(@RequestParam(name="id",required=true) String id) {
List<SarFileCompareResComVO> list = sarFileCompareResCommentService.queryListByInfoId(id);
return Result.OK(list);
}
/**
* 根据infoId查询列表
*
* @return
*/
@AutoLog(value = "文档对比信息结果评论表-根据infoId查询列表")
@ApiOperation(value = "文档对比信息结果评论表-根据infoId查询列表", notes = "文档对比信息结果评论表-根据infoId查询列表")
@GetMapping(value = "/queryListByInfoId")
public Result<List<SarFileCompareResComVO>> queryListByInfoId(@RequestParam(name = "id", required = true) String id) {
List<SarFileCompareResComVO> list = sarFileCompareResCommentService.queryListByInfoId(id);
return Result.OK(list);
}
@AutoLog(value = "文档对比信息结果评论表-搜索评论")
@ApiOperation(value = "文档对比信息结果评论表-搜索评论", notes = "文档对比信息结果评论表-搜索评论")
@GetMapping(value = "/searchResComment")
public Result<List<SarFileCompareResComVO>> searchResComment(@RequestParam(name = "id", required = true) String id,
@RequestParam(name = "str", required = true) String str) {
List<SarFileCompareResComVO> list = sarFileCompareResCommentService.searchResComment(id, str);
return Result.OK(list);
}
}
@@ -61,4 +61,6 @@ public interface ISarFileCompareResCommentService extends IService<SarFileCompar
List<SarFileCompareResComment> queryList();
List<SarFileCompareResComVO> queryListByInfoId(String id);
List<SarFileCompareResComVO> searchResComment(String id, String str);
}
@@ -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<SarFileComp
return resComVO;
}
@Override
public List<SarFileCompareResComVO> searchResComment(String id, String str) {
if (StringUtils.isBlank(str)) {
return queryListByInfoId(id);
}
LambdaQueryWrapper<SarFileCompareResComment> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SarFileCompareResComment::getInfoId, id);
queryWrapper.like(SarFileCompareResComment::getComment, str);
queryWrapper.orderBy(true, true, SarFileCompareResComment::getCreateTime);
List<SarFileCompareResComment> list = this.list(queryWrapper);
Map<String, SarFileCompareResComVO> resCommentMap = new HashMap<>();
List<SarFileCompareResComment> 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());
}
}