Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jeecg-boot 2.0.1 版本代码生成器生成的字段无法模糊搜索 #215

Closed
yaominyuan opened this issue Jun 18, 2019 · 4 comments
Closed

Comments

@yaominyuan
Copy link

2.0.1

通过代码生成器生成的代码,前台搜索都是精确查找,按照MybatisPlus中@TableField注解 在实体类字段上加了,但是就是没用。

image

重现步骤&代码

@zhangdaiscott
Copy link
Member

jeecg自带查询过滤器,需要默认查询,文字: “张*”
http://jeecg-boot.mydoc.io/?t=345707

@zhangdaiscott
Copy link
Member

zhangdaiscott commented Jul 19, 2019

如果需要默认全部模糊查询,可以这么改
jeecg-boot-base-common/org/jeecg/common/system/query/QueryGenerator.java:152
加上下面这段代码

// add -begin 添加判断为字符串时设为全模糊查询
if("class java.lang.String".equals(type)) {
// 可以设置左右模糊或全模糊,因人而异
rule = QueryRuleEnum.LIKE;
}
// add -end 添加判断为字符串时设为全模糊查询

image

此改法的弊端:
会导致所有的查询都走模糊查询,有一种情况会出问题,比如通过下拉性别查询,男女值分别为0,1
这个时候采用模糊匹配,如果字典值有以0开头或者结尾的字典值,就会导致查询出多个(非正常匹配)

@xiaojx-959
Copy link

如果需要全部完全模糊查询,可以这么改
jeecg-boot-base-common / org / jeecg / common / system / query / QueryGenerator.java:152
加上以下代码

// add -begin添加判断为字符串时创建全模糊查询
if(“ class java.lang.String” .equals(type)){
//可以设置左右模糊或全模糊,因人而异
rule = QueryRuleEnum 。喜欢;
}
//添加-end添加判断为字符串时添加全模糊查询

图片

此改法的弊端:
会导致所有的查询都走模糊查询,有一种情况会出问题,此类通过拖放性别查询,男女值分别为0,1
这个时候采用混淆匹配,如果字典值有以0开头或者最终的字典值,就会导致查询出多个(非正常匹配)

online在线开发的可以开模糊查询吗 , 上面这个方法在online测试页面就没有效果了

@zhouyunxu
Copy link

image
一楼的这个问题解决了吗? 我也想了解一下, 有些单个字段模糊查询不了怎么, 但不开启全局匹配的模糊查询,该怎么处理

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants