全局搜索数量支持非中文

This commit is contained in:
wangliwen 2022-10-26 10:34:11 +08:00
parent 5f2b7d7778
commit e836bcb271
5 changed files with 12 additions and 9 deletions

View File

@ -636,8 +636,8 @@ public class ResourceController {
@GetMapping("/getCountByFuzzyQuery") @GetMapping("/getCountByFuzzyQuery")
@ApiOperation("获取各类资源模糊查询总数") @ApiOperation("获取各类资源模糊查询总数")
@LogOperation("获取各类资源模糊查询总数") @LogOperation("获取各类资源模糊查询总数")
public Result getCountByFuzzyQuery(@RequestParam String keyWorld) { public Result getCountByFuzzyQuery(@RequestParam String keyWorld, @RequestParam String nonChinese) {
return new Result<>().ok(resourceService.getCountByFuzzyQuery(keyWorld)); return new Result<>().ok(resourceService.getCountByFuzzyQuery(keyWorld, nonChinese));
} }

View File

@ -178,7 +178,7 @@ public interface ResourceDao extends BaseDao<ResourceEntity> {
String selectPicByResId(@Param("id") String id); String selectPicByResId(@Param("id") String id);
List<Map> selectTypeCountByName(@Param("keyWorld") String keyWorld); List<Map> selectTypeCountByName(@Param("keyWorld") String keyWorld, @Param("nonChinese") Boolean nonChinese);
List<Map> countByCIMType(@Param("deptId") Long deptId); List<Map> countByCIMType(@Param("deptId") Long deptId);

View File

@ -140,7 +140,7 @@ public interface ResourceService extends CrudService<ResourceEntity, ResourceDTO
Object selectAppList(Map params); Object selectAppList(Map params);
Object getCountByFuzzyQuery(String keyWorld); Object getCountByFuzzyQuery(String keyWorld, String nonChinese);
Object selectApplyDeptDetailTypeCountList(Map params); Object selectApplyDeptDetailTypeCountList(Map params);

View File

@ -477,8 +477,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
* 从本库内查询 * 从本库内查询
*/ */
@SneakyThrows @SneakyThrows
private Page<ResourceDTO> common(Page<ResourceDTO> resultPage, List<Map> selectDTOPageSpecilTotal, ResourceDTO resourceDTO, private Page<ResourceDTO> common(Page<ResourceDTO> resultPage, List<Map> selectDTOPageSpecilTotal, ResourceDTO resourceDTO, String orderField, String orderType, Integer pageNum, Integer pageSize, Boolean nonChinese) {
String orderField, String orderType, Integer pageNum, Integer pageSize, Boolean nonChinese) {
if (resourceDTO.getInfoList().isEmpty()) { if (resourceDTO.getInfoList().isEmpty()) {
List<ResourceDTO> resourceDTOS; List<ResourceDTO> resourceDTOS;
if (orderField.equals("total")) { // 对总体评价特殊处理 if (orderField.equals("total")) { // 对总体评价特殊处理
@ -1978,9 +1977,10 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
} }
@Override @Override
public Object getCountByFuzzyQuery(String keyWorld) { public Object getCountByFuzzyQuery(String keyWorld, String nonChinese) {
ArrayList<Map> resultList = new ArrayList<>(); ArrayList<Map> resultList = new ArrayList<>();
CompletableFuture<Void> DBresourceCount = CompletableFuture.runAsync(() -> resultList.addAll(resourceDao.selectTypeCountByName(keyWorld))); Boolean nonChinese_ = Boolean.getBoolean(nonChinese);// 不传默认为中文走全文索引
CompletableFuture<Void> DBresourceCount = CompletableFuture.runAsync(() -> resultList.addAll(resourceDao.selectTypeCountByName(keyWorld, nonChinese_)));
final Integer[] meetCountNew = new Integer[1]; final Integer[] meetCountNew = new Integer[1];
switch (Constant.ProjectPlace.getByFlag(projectPlace)) { switch (Constant.ProjectPlace.getByFlag(projectPlace)) {
case TSINGTAO: { case TSINGTAO: {

View File

@ -1632,9 +1632,12 @@
FROM tb_data_resource FROM tb_data_resource
WHERE 1 = 1 WHERE 1 = 1
AND del_flag = 0 AND del_flag = 0
<if test="keyWorld != null and keyWorld != ''"> <if test="keyWorld != null and keyWorld != '' and nonChinese == false">
AND MATCH (name) AGAINST ( #{keyWorld} IN BOOLEAN MODE) AND MATCH (name) AGAINST ( #{keyWorld} IN BOOLEAN MODE)
</if> </if>
<if test="keyWorld != null and keyWorld != '' and nonChinese == true">
AND name LIKE CONCAT( '%', #{keyWorld}, '%' )
</if>
AND type != '赋能案例' AND type != '赋能案例'
GROUP BY type GROUP BY type
ORDER BY type ORDER BY type