Commit bc92650f authored by 赵啸非's avatar 赵啸非

修改热门词汇

parent d1728327
Pipeline #2411 canceled with stages
......@@ -4,6 +4,7 @@ import com.mortals.framework.model.PageInfo;
import com.mortals.xhx.module.hotword.model.HotwordEntity;
import com.mortals.xhx.module.hotword.model.HotwordQuery;
import com.mortals.xhx.module.hotword.service.HotwordService;
import com.mortals.xhx.module.matter.model.MatterEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
......@@ -16,6 +17,8 @@ import org.springframework.util.ObjectUtils;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
* BasesetService
......@@ -43,7 +46,13 @@ public class BasesetServiceImpl extends AbstractCRUDServiceImpl<BasesetDao, Base
@Override
protected void saveAfter(BasesetEntity entity, Context context) throws AppException {
if(!ObjectUtils.isEmpty(entity.getHotwordList())){
//更新新增热门词汇
//更新新增热门词汇,差集删除不在列表中的
List<HotwordEntity> allHotWords = hotwordService.find(new HotwordQuery().siteId(entity.getSiteId()));
//求差集 删除
List<HotwordEntity> delList = this.subList(allHotWords, entity.getHotwordList());
if(!ObjectUtils.isEmpty(delList)){
hotwordService.removeList(delList,context);
}
entity.getHotwordList().forEach(item -> {
HotwordEntity hotwordEntity = hotwordService.selectOne(new HotwordQuery().siteId(item.getSiteId()).hotwords(item.getHotwords()));
if (!ObjectUtils.isEmpty(hotwordEntity)) {
......@@ -63,4 +72,10 @@ public class BasesetServiceImpl extends AbstractCRUDServiceImpl<BasesetDao, Base
super.saveAfter(entity, context);
}
public List<HotwordEntity> subList(List<HotwordEntity> firstList, List<HotwordEntity> secondList) {
Set<String> secondSet = secondList.parallelStream().map(e -> e.getHotwords()).collect(Collectors.toSet());
return firstList.parallelStream().filter(item -> !secondSet.contains(item.getHotwords())).collect(Collectors.toList());
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment