提交 cd49ba7e 作者: 925993793@qq.com

代码优化

上级 87bfd3fc
......@@ -30,7 +30,7 @@ public class LoginInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, @NotNull HttpServletResponse response, @NotNull Object handler) {
String userInfo = URLDecoder.decode(request.getHeader(LOGIN_USER_HEADER), StandardCharsets.UTF_8);
log.info("当前登录用户信息:{}", userInfo);
log.debug("当前登录用户信息:{}", userInfo);
if (StringUtils.isBlank(userInfo)) {
returnJson(response, JSON.toJSONString(Result.FAIL(401, "用户未登录")));
return false;
......
......@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zzsn.event.constant.Result;
import com.zzsn.event.entity.Subject;
import com.zzsn.event.es.EsService;
import com.zzsn.event.service.SubjectService;
import com.zzsn.event.service.SubjectSimpleService;
import com.zzsn.event.vo.InfoDataSearchCondition;
......@@ -36,8 +35,6 @@ public class SubjectSimpleController {
private SubjectService subjectService;
@Autowired
private IXxlJobInfoService xxlJobInfoService;
@Autowired
private EsService esService;
/**
* 创建专题
......@@ -67,6 +64,10 @@ public class SubjectSimpleController {
*/
@PostMapping("/editSubject")
public Result<?> editSubject(@RequestBody SubjectSimpleVO subjectSimpleVO) {
List<SearchWordVO> keywords = subjectSimpleVO.getKeywords();
if (CollectionUtils.isEmpty(keywords)) {
return Result.FAIL("请先添加关键词");
}
subjectSimpleService.editSubject(subjectSimpleVO);
return Result.OK();
}
......
package com.zzsn.event.service.impl;
import cn.hutool.core.lang.tree.Tree;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
......@@ -36,7 +35,6 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
/**
......
......@@ -17,6 +17,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.concurrent.CompletableFuture;
......@@ -69,6 +70,7 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
private final static String PROJECT_ID = "1476527644425682945";
@Override
@Transactional
public Subject createSubject(SubjectSimpleVO subjectSimpleVO) {
SubjectPage subjectPage = new SubjectPage();
BeanUtils.copyProperties(subjectSimpleVO, subjectPage);
......@@ -99,6 +101,7 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
}
@Override
@Transactional
public void editSubject(SubjectSimpleVO subjectSimpleVO) {
SubjectPage subjectPage = new SubjectPage();
BeanUtils.copyProperties(subjectSimpleVO, subjectPage);
......@@ -150,7 +153,7 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
}
}
List<SearchWordVO> wordList = new ArrayList<>(map.values());
sortByAnotherList(wordList,sortList);
sortByAnotherList(wordList, sortList);
return wordList;
}
......@@ -167,7 +170,7 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
@Override
public void removeSubject(String subjectId) {
subjectService.removeById(subjectId);
CompletableFuture.runAsync(()->{
CompletableFuture.runAsync(() -> {
//删除与类别的映射
subjectTypeMapService.deleteBySubjectId(subjectId);
//删除与信息源的关联关系
......@@ -202,7 +205,7 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
public void selected(InfoDataSearchCondition searchCondition) {
String[] fetchFields = new String[]{"id", "checkStatus"};
searchCondition.setFetchFields(fetchFields);
Map<String,List<SpecialInformation>> updateMap = new HashMap<>();
Map<String, List<SpecialInformation>> updateMap = new HashMap<>();
List<SpecialInformation> informationList = esService.informationList(searchCondition);
for (SpecialInformation information : informationList) {
String index = information.getDbIndex();
......@@ -215,14 +218,14 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
updateMap.put(index, list);
}
}
updateMap.forEach((k,v)->esOpUtil.docUpdateBulk(k,v));
updateMap.forEach((k, v) -> esOpUtil.docUpdateBulk(k, v));
}
@Override
public void removeSelected(InfoDataSearchCondition searchCondition) {
String[] fetchFields = new String[]{"id", "checkStatus"};
searchCondition.setFetchFields(fetchFields);
Map<String,List<SpecialInformation>> updateMap = new HashMap<>();
Map<String, List<SpecialInformation>> updateMap = new HashMap<>();
List<SpecialInformation> informationList = esService.informationList(searchCondition);
for (SpecialInformation information : informationList) {
String index = information.getDbIndex();
......@@ -235,14 +238,14 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
updateMap.put(index, list);
}
}
updateMap.forEach((k,v)->esOpUtil.docUpdateBulk(k,v));
updateMap.forEach((k, v) -> esOpUtil.docUpdateBulk(k, v));
}
@Override
public void batchRemove(InfoDataSearchCondition searchCondition) {
String[] fetchFields = new String[]{"id", "deleteFlag"};
searchCondition.setFetchFields(fetchFields);
Map<String,List<SpecialInformation>> updateMap = new HashMap<>();
Map<String, List<SpecialInformation>> updateMap = new HashMap<>();
List<SpecialInformation> informationList = esService.informationList(searchCondition);
for (SpecialInformation information : informationList) {
String index = information.getDbIndex();
......@@ -255,7 +258,7 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
updateMap.put(index, list);
}
}
updateMap.forEach((k,v)->esOpUtil.docUpdateBulk(k,v));
updateMap.forEach((k, v) -> esOpUtil.docUpdateBulk(k, v));
}
//目标集合按照另一个集合的顺序排序
......@@ -416,7 +419,10 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
//绑定为过滤词的同时,绑定为采集词
List<SubjectKeywordsMap> collect = subjectKeywordsMapList.stream().filter(e -> "2".equals(e.getBindingType())).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(collect)) {
collect.forEach(e -> e.setBindingType("1"));
collect.forEach(e -> {
e.setBindingType("1");
e.setId(null);
});
subjectKeywordsMapService.saveBatch(subjectKeywordsMapList);
}
}
......
......@@ -101,6 +101,9 @@ public class InfoDataSearchCondition {
//每页返回条数
private Integer pageSize = 10;
//选择前num条数据
private Integer num;
//资讯id集合,导出/专题分析时使用-研究中心
private List<String> ids;
......@@ -113,8 +116,6 @@ public class InfoDataSearchCondition {
/*------专题分析类参数---start-------------------*/
//聚合分组类型-按日期集合分析时使用
private String groupType;
//选择的前num条数据-专题分析时使用
private Integer num;
//信息源id集合-统计分析资讯量最多的信息源时使用
private List<String> sourceIdList;
//聚合包含的字段值的集合
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论