|
|
|
|
@ -9,6 +9,7 @@ import com.ruoyi.portal.search.convert.PortalSearchDocConverter;
|
|
|
|
|
import com.ruoyi.portal.search.es.entity.PortalSearchDoc;
|
|
|
|
|
import com.ruoyi.portal.search.es.mapper.PortalSearchMapper;
|
|
|
|
|
import com.ruoyi.portal.search.service.PortalSearchEsService;
|
|
|
|
|
import com.ruoyi.portal.search.support.PortalSearchRouteResolver;
|
|
|
|
|
import com.ruoyi.portal.service.IHwSearchRebuildService;
|
|
|
|
|
import org.dromara.easyes.core.biz.EsPageInfo;
|
|
|
|
|
import org.dromara.easyes.core.conditions.select.LambdaEsQueryWrapper;
|
|
|
|
|
@ -42,13 +43,17 @@ public class PortalSearchEsServiceImpl implements PortalSearchEsService
|
|
|
|
|
|
|
|
|
|
private final IHwSearchRebuildService hwSearchRebuildService;
|
|
|
|
|
|
|
|
|
|
private final PortalSearchRouteResolver routeResolver;
|
|
|
|
|
|
|
|
|
|
private final ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
|
|
|
|
|
public PortalSearchEsServiceImpl(PortalSearchMapper portalSearchMapper,
|
|
|
|
|
@Autowired(required = false) IHwSearchRebuildService hwSearchRebuildService)
|
|
|
|
|
@Autowired(required = false) IHwSearchRebuildService hwSearchRebuildService,
|
|
|
|
|
PortalSearchRouteResolver routeResolver)
|
|
|
|
|
{
|
|
|
|
|
this.portalSearchMapper = portalSearchMapper;
|
|
|
|
|
this.hwSearchRebuildService = hwSearchRebuildService;
|
|
|
|
|
this.routeResolver = routeResolver;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@ -137,7 +142,7 @@ public class PortalSearchEsServiceImpl implements PortalSearchEsService
|
|
|
|
|
result.setSnippet(buildSnippet(doc.getTitle(), doc.getContent(), keyword));
|
|
|
|
|
result.setScore(0);
|
|
|
|
|
result.setRoute(doc.getRoute());
|
|
|
|
|
result.setRouteQuery(parseRouteQuery(doc.getRouteQueryJson()));
|
|
|
|
|
result.setRouteQuery(buildRouteQuery(doc));
|
|
|
|
|
if (editMode)
|
|
|
|
|
{
|
|
|
|
|
result.setEditRoute(buildEditRoute(doc.getSourceType(), doc.getWebCode(), doc.getTypeId(), doc.getDeviceId(), doc.getMenuId(), doc.getDocumentId()));
|
|
|
|
|
@ -145,6 +150,25 @@ public class PortalSearchEsServiceImpl implements PortalSearchEsService
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Map<String, Object> buildRouteQuery(PortalSearchDoc doc)
|
|
|
|
|
{
|
|
|
|
|
Map<String, Object> routeQuery = parseRouteQuery(doc.getRouteQueryJson());
|
|
|
|
|
if (!PortalSearchDocConverter.SOURCE_CONFIG_TYPE.equals(doc.getSourceType()))
|
|
|
|
|
{
|
|
|
|
|
return routeQuery;
|
|
|
|
|
}
|
|
|
|
|
String routeWebCode = StringUtils.isNotBlank(doc.getWebCode()) ? doc.getWebCode() : routeResolver.resolveConfigTypeWebCode(doc.getTitle());
|
|
|
|
|
if (StringUtils.isBlank(routeWebCode))
|
|
|
|
|
{
|
|
|
|
|
return routeQuery;
|
|
|
|
|
}
|
|
|
|
|
// 这里在查询侧再次归一化一次,兼容历史 ES 文档尚未重建时仍然写着旧的 config_type_id。
|
|
|
|
|
Map<String, Object> normalizedQuery = new HashMap<>();
|
|
|
|
|
normalizedQuery.put("id", routeWebCode);
|
|
|
|
|
normalizedQuery.put("configTypeId", routeWebCode);
|
|
|
|
|
return normalizedQuery;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Map<String, Object> parseRouteQuery(String json)
|
|
|
|
|
{
|
|
|
|
|
if (StringUtils.isBlank(json))
|
|
|
|
|
|