CMS优化全文检索模块提示

This commit is contained in:
thinkgem
2023-04-11 11:29:22 +08:00
parent 5a11da74ca
commit 03a519fd23
7 changed files with 25 additions and 38 deletions

View File

@@ -32,7 +32,7 @@ public interface ArticleIndexService {
* 重建索引
* @author ThinkGem
*/
void rebuild(Article article);
String rebuild(Article article);
/**
* 文章高级搜索

View File

@@ -10,7 +10,6 @@ import com.jeesite.common.entity.Page;
import com.jeesite.common.lang.DateUtils;
import com.jeesite.common.lang.StringUtils;
import com.jeesite.common.service.CrudService;
import com.jeesite.common.service.ServiceException;
import com.jeesite.modules.cms.dao.ArticleDao;
import com.jeesite.modules.cms.dao.ArticleDataDao;
import com.jeesite.modules.cms.entity.Article;
@@ -228,17 +227,6 @@ public class ArticleService extends CrudService<ArticleDao, Article> {
}
}
/**
* 重建索引
* @author ThinkGem
*/
public void rebuildIndex(Article article) {
if (articleIndexService == null) {
throw new ServiceException(text("未安装全文检索模块"));
}
articleIndexService.rebuild(article);
}
/**
* 文章高级搜索
* @param page 分页对象
@@ -252,7 +240,8 @@ public class ArticleService extends CrudService<ArticleDao, Article> {
public Page<Map<String, Object>> searchPage(Page<Map<String, Object>> page, String qStr,
String qand, String qnot, String bd, String ed, Map<String, String> params) {
if (articleIndexService == null) {
throw new ServiceException(text("未安装全文检索模块"));
page.addOtherData("message", text("您好,系统未安装全文检索模块"));
return page;
}
return articleIndexService.searchPage(page, qStr, qand, qnot, bd, ed, params);
}

View File

@@ -4,7 +4,6 @@
*/
package com.jeesite.modules.cms.service;
import com.jeesite.common.service.ServiceException;
import com.jeesite.common.service.TreeService;
import com.jeesite.modules.cms.dao.CategoryDao;
import com.jeesite.modules.cms.entity.Article;
@@ -118,11 +117,11 @@ public class CategoryService extends TreeService<CategoryDao, Category> {
* 重建索引
* @author ThinkGem
*/
public void rebuildIndex(Category category) {
public String rebuildIndex(Category category) {
if (articleIndexService == null) {
throw new ServiceException(text("未安装全文检索模块"));
return text("您好,系统未安装全文检索模块");
}
articleIndexService.rebuild(new Article(category));
return articleIndexService.rebuild(new Article(category));
}
}

View File

@@ -4,19 +4,17 @@
*/
package com.jeesite.modules.cms.service;
import com.jeesite.common.service.ServiceException;
import com.jeesite.modules.cms.entity.Article;
import com.jeesite.modules.cms.entity.Category;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.jeesite.common.entity.Page;
import com.jeesite.common.service.CrudService;
import com.jeesite.modules.cms.dao.SiteDao;
import com.jeesite.modules.cms.entity.Article;
import com.jeesite.modules.cms.entity.Category;
import com.jeesite.modules.cms.entity.Site;
import com.jeesite.modules.cms.utils.CmsUtils;
import com.jeesite.modules.file.utils.FileUploadUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* 站点表Service
@@ -113,11 +111,11 @@ public class SiteService extends CrudService<SiteDao, Site> {
* 重建索引
* @author ThinkGem
*/
public void rebuildIndex(Site site) {
public String rebuildIndex(Site site) {
if (articleIndexService == null) {
throw new ServiceException(text("未安装全文检索模块"));
return text("您好,系统未安装全文检索模块");
}
articleIndexService.rebuild(new Article(new Category(site)));
return articleIndexService.rebuild(new Article(new Category(site)));
}
}

View File

@@ -255,10 +255,7 @@ public class CategoryController extends BaseController {
@ResponseBody
@RequestMapping(value = "rebuildIndex")
public String rebuildIndex(Category category) {
long start = System.currentTimeMillis();
categoryService.rebuildIndex(category);
return renderResult(Global.TRUE, "重建索引成功! 用时"
+ TimeUtils.formatTime(System.currentTimeMillis() - start) + "");
return renderResult(Global.TRUE, categoryService.rebuildIndex(category));
}
/**

View File

@@ -7,7 +7,6 @@ package com.jeesite.modules.cms.web;
import com.jeesite.common.config.Global;
import com.jeesite.common.entity.Page;
import com.jeesite.common.lang.StringUtils;
import com.jeesite.common.lang.TimeUtils;
import com.jeesite.common.web.BaseController;
import com.jeesite.common.web.CookieUtils;
import com.jeesite.modules.cms.entity.Site;
@@ -143,10 +142,7 @@ public class SiteController extends BaseController {
@ResponseBody
@RequestMapping(value = "rebuildIndex")
public String rebuildIndex(Site site) {
long start = System.currentTimeMillis();
siteService.rebuildIndex(site);
return renderResult(Global.TRUE, "重建索引成功! 用时"
+ TimeUtils.formatTime(System.currentTimeMillis() - start) + "");
return renderResult(Global.TRUE, siteService.rebuildIndex(site));
}
/**

View File

@@ -95,7 +95,15 @@ $(function(){
</#html:forEach>
</#html:if>
<#html:if test="${page! == null || page.list.~size == 0}">
<dt><#html:if test="${isBlank(q)}">请键入要查找的关键字。</#html:if><#html:if test="${isNotBlank(q)}">抱歉,没有找到与“${q}”相关内容。</#html:if><br/><br/>建议:</dt>
<dt>
<% if (isNotBlank(page.otherData.message!)){ %>
${page.otherData.message!}
<% } else if (isBlank(q)){ %>
请键入要查找的关键字。
<% } else if (isNotBlank(q)){ %>
抱歉,没有找到与 “${q}” 相关内容。
<% } %>
<br/><br/>建议:</dt>
<dd><ul><li>检查输入是否正确;</li><li>简化输入词;</li><li>尝试其他相关词,如同义、近义词等。</li></ul></dd>
</#html:if>
</dl>