feat: 统一列表模糊搜索行为
- 统一管理端和用户中心搜索参数及多字段包含匹配 - 修复聊天搜索竞态并优化部门重名路径展示 - 补充部门展开、模型空白词和聊天查询回归测试
This commit is contained in:
@@ -32,6 +32,9 @@ public class Bot extends BotBase {
|
||||
@Column(ignore = true)
|
||||
private String createdByName;
|
||||
|
||||
@Column(ignore = true)
|
||||
private String keyword;
|
||||
|
||||
public boolean isAnonymousEnabled() {
|
||||
Map<String, Object> options = getOptions();
|
||||
if (options == null) {
|
||||
@@ -83,4 +86,22 @@ public class Bot extends BotBase {
|
||||
this.createdByName = createdByName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取市场列表搜索关键字。
|
||||
*
|
||||
* @return 标题或描述关键字
|
||||
*/
|
||||
public String getKeyword() {
|
||||
return keyword;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置市场列表搜索关键字。
|
||||
*
|
||||
* @param keyword 标题或描述关键字
|
||||
*/
|
||||
public void setKeyword(String keyword) {
|
||||
this.keyword = keyword;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,6 +29,9 @@ public class Workflow extends WorkflowBase implements VisibilityResource {
|
||||
@Column(ignore = true)
|
||||
private String createdByName;
|
||||
|
||||
@Column(ignore = true)
|
||||
private String keyword;
|
||||
|
||||
public Tool toFunction(boolean needEnglishName) {
|
||||
return new WorkflowTool(this, needEnglishName);
|
||||
}
|
||||
@@ -78,4 +81,22 @@ public class Workflow extends WorkflowBase implements VisibilityResource {
|
||||
public void setCreatedByName(String createdByName) {
|
||||
this.createdByName = createdByName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取市场列表搜索关键字。
|
||||
*
|
||||
* @return 标题或描述关键字
|
||||
*/
|
||||
public String getKeyword() {
|
||||
return keyword;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置市场列表搜索关键字。
|
||||
*
|
||||
* @param keyword 标题或描述关键字
|
||||
*/
|
||||
public void setKeyword(String keyword) {
|
||||
this.keyword = keyword;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,10 +27,10 @@ public interface PluginService extends IService<Plugin> {
|
||||
* @param pageNumber 页码
|
||||
* @param pageSize 每页数量
|
||||
* @param category 分类 ID
|
||||
* @param name 插件名称关键字
|
||||
* @param keyword 插件名称或描述关键字
|
||||
* @return 插件分页结果
|
||||
*/
|
||||
Result<Page<Plugin>> pageByCategory(Long pageNumber, Long pageSize, int category, String name);
|
||||
Result<Page<Plugin>> pageByCategory(Long pageNumber, Long pageSize, int category, String keyword);
|
||||
|
||||
boolean updatePlugin(Plugin plugin);
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import tech.easyflow.ai.config.SearcherFactory;
|
||||
import tech.easyflow.common.util.SearchKeywordUtil;
|
||||
import tech.easyflow.ai.documentimport.DocumentImportDtos;
|
||||
import tech.easyflow.ai.documentimport.DocumentImportKeys;
|
||||
import tech.easyflow.ai.documentimport.DocumentImportPreviewService;
|
||||
@@ -183,7 +184,7 @@ public class DocumentServiceImpl extends ServiceImpl<DocumentMapper, Document> i
|
||||
.where(DOCUMENT.COLLECTION_ID.eq(knowledgeId))
|
||||
.orderBy(DOCUMENT.ID, false);
|
||||
if (fileName != null && !fileName.trim().isEmpty()) {
|
||||
queryWrapper.and(DOCUMENT.TITLE.like(fileName));
|
||||
queryWrapper.and(DOCUMENT.TITLE.likeRaw(SearchKeywordUtil.literalContainsPattern(fileName)));
|
||||
}
|
||||
if (documentId != null) {
|
||||
queryWrapper.and(DOCUMENT.ID.eq(documentId));
|
||||
|
||||
@@ -23,6 +23,7 @@ import tech.easyflow.common.domain.Result;
|
||||
import tech.easyflow.common.web.exceptions.BusinessException;
|
||||
import tech.easyflow.common.entity.LoginAccount;
|
||||
import tech.easyflow.common.satoken.util.SaTokenUtil;
|
||||
import tech.easyflow.common.util.SearchKeywordUtil;
|
||||
import tech.easyflow.system.entity.vo.RoleCategoryAccessSnapshot;
|
||||
import tech.easyflow.system.service.CategoryPermissionService;
|
||||
|
||||
@@ -138,7 +139,7 @@ public class PluginServiceImpl extends ServiceImpl<PluginMapper, Plugin> impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Page<Plugin>> pageByCategory(Long pageNumber, Long pageSize, int category, String name) {
|
||||
public Result<Page<Plugin>> pageByCategory(Long pageNumber, Long pageSize, int category, String keyword) {
|
||||
RoleCategoryAccessSnapshot access = categoryPermissionService.getCurrentAccess("PLUGIN");
|
||||
QueryWrapper queryWrapper = QueryWrapper.create().select(PluginCategoryMapping::getPluginId)
|
||||
.eq(PluginCategoryMapping::getCategoryId, category);
|
||||
@@ -165,7 +166,7 @@ public class PluginServiceImpl extends ServiceImpl<PluginMapper, Plugin> impleme
|
||||
}
|
||||
|
||||
List<Plugin> totalPlugins = preparePluginsForCurrentUser(
|
||||
queryPluginsByIds(visiblePluginIds, name), true, false);
|
||||
queryPluginsByIds(visiblePluginIds, keyword), true, false);
|
||||
int fromIndex = Math.max(0, Math.toIntExact((pageNumber - 1) * pageSize));
|
||||
if (fromIndex >= totalPlugins.size()) {
|
||||
return Result.ok(new Page<>(Collections.emptyList(), pageNumber, pageSize, totalPlugins.size()));
|
||||
@@ -259,19 +260,20 @@ public class PluginServiceImpl extends ServiceImpl<PluginMapper, Plugin> impleme
|
||||
}
|
||||
|
||||
/**
|
||||
* 按给定顺序查询插件,并按名称关键字过滤。
|
||||
* 按给定顺序查询插件,并按名称或描述关键字过滤。
|
||||
*
|
||||
* @param pluginIds 插件 ID 列表
|
||||
* @param name 插件名称关键字
|
||||
* @param keyword 插件名称或描述关键字
|
||||
* @return 保持输入 ID 顺序的插件列表
|
||||
*/
|
||||
private List<Plugin> queryPluginsByIds(List<BigInteger> pluginIds, String name) {
|
||||
private List<Plugin> queryPluginsByIds(List<BigInteger> pluginIds, String keyword) {
|
||||
if (CollectionUtil.isEmpty(pluginIds)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
QueryWrapper queryPluginWrapper = QueryWrapper.create().select().in(Plugin::getId, pluginIds);
|
||||
if (name != null && !name.isBlank()) {
|
||||
queryPluginWrapper.like(Plugin::getName, name.trim());
|
||||
if (keyword != null && !keyword.isBlank()) {
|
||||
String pattern = SearchKeywordUtil.literalContainsPattern(keyword);
|
||||
queryPluginWrapper.and(PLUGIN.NAME.likeRaw(pattern).or(PLUGIN.DESCRIPTION.likeRaw(pattern)));
|
||||
}
|
||||
List<Plugin> plugins = pluginMapper.selectListWithRelationsByQuery(queryPluginWrapper);
|
||||
Map<BigInteger, Plugin> pluginMap = plugins.stream().collect(Collectors.toMap(
|
||||
|
||||
Reference in New Issue
Block a user