提交 91d87531 作者: 布红亮

查询新增全部和其他查询

上级 a939f4c4
......@@ -3,7 +3,6 @@ package com.zzsn.thinktank.service.impl;
import cn.hutool.core.map.MapUtil;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter;
import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
......@@ -11,6 +10,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Maps;
import com.zzsn.thinktank.constants.CommonConstants;
import com.zzsn.thinktank.entity.*;
import com.zzsn.thinktank.mapper.ThinktankBasicInfoMapper;
......@@ -27,7 +27,6 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.builder.SearchSourceBuilder;
......@@ -40,7 +39,6 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
......@@ -357,9 +355,23 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
@Override
public Result<?> getList(ThinktankBasicInfoListVo thinktankBasicInfoListVo) {
if(thinktankBasicInfoListVo!=null && StringUtils.isNotBlank(thinktankBasicInfoListVo.getTypeId())
// 缓存的type类型
String cacheTypeStr = thinktankBasicInfoListVo.getTypeId();
if (StringUtils.equals(thinktankBasicInfoListVo.getQueryType(), "all")) {
cacheTypeStr = "all";
thinktankBasicInfoListVo.setTypeId(null);
thinktankBasicInfoListVo.setExcludeTypeIds(null);
} else if (StringUtils.equals(thinktankBasicInfoListVo.getQueryType(), "other")) {
// 其它-排除热门的
cacheTypeStr = thinktankBasicInfoListVo.getExcludeTypeIds().toString();
thinktankBasicInfoListVo.setTypeId(null);
} else {
thinktankBasicInfoListVo.setExcludeTypeIds(null);
}
if(StringUtils.isNotBlank(cacheTypeStr)
&& StringUtils.isBlank(thinktankBasicInfoListVo.getTagId())){
IPage cacheObject = (IPage)simRedisUtil.getCacheObject(KEY + "_" + thinktankBasicInfoListVo.getTypeId()
IPage cacheObject = (IPage)simRedisUtil.getCacheObject(KEY + "_" + cacheTypeStr
+ "_" + thinktankBasicInfoListVo.getColumn() + "_" + thinktankBasicInfoListVo.getOrder());
if(cacheObject!=null){
return Result.OK(cacheObject);
......@@ -452,9 +464,18 @@ public class ThinktankBasicInfoServiceImpl extends ServiceImpl<ThinktankBasicInf
thinktankTagService.addTagTop(s);
}
}
if(thinktankBasicInfoListVo!=null && StringUtils.isNotBlank(thinktankBasicInfoListVo.getTypeId())
&& StringUtils.isBlank(thinktankBasicInfoListVo.getTagId())){
simRedisUtil.setCacheObject(KEY + "_" + thinktankBasicInfoListVo.getTypeId()
if(StringUtils.isNotBlank(cacheTypeStr) && StringUtils.isBlank(thinktankBasicInfoListVo.getTagId())){
if (Arrays.asList("all", "other").contains(cacheTypeStr)) {
// all 和other数据量过大,只存id
List<Map<String, Object>> ids = (List<Map<String, Object>>) page.getRecords().stream()
.map(v -> {
Map<String, Object> map = Maps.newHashMap();
map.put("id", ((ThinktankBasicInfoVo) v).getId());
return map;
}).collect(Collectors.toList());
page.setRecords(ids);
}
simRedisUtil.setCacheObject(KEY + "_" + cacheTypeStr
+ "_" + thinktankBasicInfoListVo.getColumn() + "_" + thinktankBasicInfoListVo.getOrder(), page,10L, TimeUnit.DAYS);
}
return Result.OK(page);
......
......@@ -38,6 +38,10 @@ public class ThinktankBasicInfoListVo {
//类别 根据左侧树id
private String typeId;
//all other
private String queryType;
//查询排除类别
private List<String> excludeTypeIds;
//标签
private String tagId;
......
......@@ -27,6 +27,12 @@
AND a.tag_id like '%${item}%'
</foreach>
</if>
<if test="excludeTypeIds != null and excludeTypeIds.size > 0">
AND a.belong_country_id not in
<foreach item="item" index="index" collection="excludeTypeIds" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="keyword != null and keyword != ''">
AND
......@@ -50,6 +56,14 @@
<if test="typeId != null and typeId != ''">
AND a.belong_country_id = #{typeId}
</if>
<if test="excludeTypeIds != null and excludeTypeIds.size > 0">
AND a.belong_country_id not in
<foreach item="item" index="index" collection="excludeTypeIds" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="thinktankName != null and thinktankName != ''">
AND a.chinese_whole like '%${thinktankName}%'
</if>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论