提交 cd86a093 作者: 925993793@qq.com

增加专题库资讯详情接口

上级 30051a6e
package com.zzsn.event.controller.plat; package com.zzsn.event.controller.plat;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zzsn.event.constant.Constants; import com.zzsn.event.constant.Constants;
import com.zzsn.event.constant.Result; import com.zzsn.event.constant.Result;
import com.zzsn.event.entity.SubjectInfoSourceMap;
import com.zzsn.event.es.EsService; import com.zzsn.event.es.EsService;
import com.zzsn.event.service.IEventService; import com.zzsn.event.service.IEventService;
import com.zzsn.event.service.IInfoSourceService; import com.zzsn.event.service.IInfoSourceService;
import com.zzsn.event.service.ISubjectInfoSourceMapService;
import com.zzsn.event.service.ISubjectTypeService; import com.zzsn.event.service.ISubjectTypeService;
import com.zzsn.event.util.DateUtil; import com.zzsn.event.util.*;
import com.zzsn.event.util.ExcelExportUtil;
import com.zzsn.event.util.user.UserUtil; import com.zzsn.event.util.user.UserUtil;
import com.zzsn.event.util.user.UserVo; import com.zzsn.event.util.user.UserVo;
import com.zzsn.event.vo.*; import com.zzsn.event.vo.*;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -52,9 +49,9 @@ public class PlatEventManageController { ...@@ -52,9 +49,9 @@ public class PlatEventManageController {
@Autowired @Autowired
private IInfoSourceService infoSourceService; private IInfoSourceService infoSourceService;
@Autowired @Autowired
private ISubjectInfoSourceMapService subjectInfoSourceMapService;
@Autowired
private EsService esService; private EsService esService;
@Autowired
private EsOpUtil esOpUtil;
/** /**
* 事件页左侧树 * 事件页左侧树
...@@ -245,7 +242,7 @@ public class PlatEventManageController { ...@@ -245,7 +242,7 @@ public class PlatEventManageController {
*/ */
@GetMapping("/removeUnBindInfoSource") @GetMapping("/removeUnBindInfoSource")
public Result<?> removeUnBindInfoSource(@RequestParam String subjectId, @RequestParam String sourceId) { public Result<?> removeUnBindInfoSource(@RequestParam String subjectId, @RequestParam String sourceId) {
eventService.removeUnBindInfoSource(subjectId,sourceId); eventService.removeUnBindInfoSource(subjectId, sourceId);
return Result.OK(); return Result.OK();
} }
...@@ -411,6 +408,60 @@ public class PlatEventManageController { ...@@ -411,6 +408,60 @@ public class PlatEventManageController {
} }
/**
* 通过id查询(采集库)
*
* @param id 资讯id
* @param index 索引名称
* @author lkg
* @date 2024/5/8
*/
@GetMapping(value = "/collectionQueryById")
public Result<?> collectionQueryById(@RequestParam String id, @RequestParam String index) {
DisplayInfo info = (DisplayInfo) esOpUtil.getInfoById(index, id, DisplayInfo.class);
if (StringUtils.isNotEmpty(info.getContentWithTag())) {
String contentNoTag = Utility.TransferHTML2TextWithImg(info.getContentWithTag());
String contentNoTag2 = Utility.dealImg(contentNoTag);
info.setContent(contentNoTag2);
info.setContentWithTag(null);
}
info.setPublishDate(EsDateUtil.esFieldDateMapping(info.getPublishDate()));
return Result.OK(info);
}
/**
* 通过id查询(专题库)
*
* @param id 资讯id
* @param index 索引名称
* @author lkg
* @date 2024/5/8
*/
@GetMapping(value = "/queryById")
public Result<?> queryById(@RequestParam String id, @RequestParam String index) {
DisplayInfo displayInfo = (DisplayInfo) esOpUtil.getInfoById(index, id, DisplayInfo.class);
addReadNum(displayInfo,index);
if (StringUtils.isNotEmpty(displayInfo.getContentWithTag())) {
String contentNoTag = Utility.TransferHTML2TextWithImg(displayInfo.getContentWithTag());
String contentNoTag2 = Utility.dealImg(contentNoTag);
displayInfo.setContent(contentNoTag2);
}
displayInfo.setPublishDate(EsDateUtil.esFieldDateMapping(displayInfo.getPublishDate()));
return Result.OK(displayInfo);
}
private void addReadNum(DisplayInfo displayInfo,String index){
if (displayInfo != null) {
if (displayInfo.getReadNum() == 0) {
displayInfo.setReadNum(1L);
} else {
displayInfo.setReadNum(displayInfo.getReadNum() + 1);
}
esOpUtil.docUpdateById(index, displayInfo.getId(), JSON.toJSONString(displayInfo));
}
}
private void setResponseHeader(HttpServletResponse response, String name) { private void setResponseHeader(HttpServletResponse response, String name) {
try { try {
try { try {
......
...@@ -763,7 +763,7 @@ public class EsOpUtil<T> { ...@@ -763,7 +763,7 @@ public class EsOpUtil<T> {
/** /**
* 根据id查询各类资讯详情 * 根据id查询各类资讯详情
* */ * */
public T getInfoByid(String index, String id, Class<T> entry){ public T getInfoById(String index, String id, Class<T> entry){
try { try {
SearchRequest searchRequest = new SearchRequest(index); SearchRequest searchRequest = new SearchRequest(index);
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论