当前位置:网站首页>Small fuzzy query, unexpectedly modified the code three times back and forth? Find an electronics factory
Small fuzzy query, unexpectedly modified the code three times back and forth? Find an electronics factory
2022-04-21 17:46:00 【The sky in July and August】
First , The architecture is springboot+mybatis
Fuzzy query name 、 cell-phone number , Is it simple
for the first time :
java
String name =MapUtils.getString(param,"name");
String telNumber =MapUtils.getString(param,"telNumber");
if(StringUtil.isEmpty(name) && StringUtil.isEmpty(telNumber)){
throw new xxxException(Err.Check," Name and mobile number cannot be empty !");
}
mybatis xml
<if test="name != null and name != '' ">
and s.name like concat('%', #{name,jdbcType=VARCHAR}, '%')
</if>
<if test="telNumber != null and telNumber != '' ">
and s.tele_number like concat('%', #{telNumber,jdbcType=VARCHAR}, '%')
</if>
Happily submitted ...
The ginseng :
{
"name":"1",
"telNumber":"1"
}
The second time :
Front end theory , The name and mobile phone number should be put in a field and transmitted
Change it
<if test="keyWord != null and keyWord != '' ">
and (name like concat('%', #{keyWord,jdbcType=VARCHAR}, '%')
or s.tele_number like concat('%', #{keyWord,jdbcType=VARCHAR}, '%')
)
</if>
The ginseng :
{
"keyWord":"1"
}
It feels perfect .. Submit !!!
third time :
Too young. , Front end theory :“ Pass a number 1 You can find tens of thousands of data , The front page crashed , Add a limit ”
<if test="keyWord != null and keyWord != '' ">
and (name like concat('%', #{keyWord,jdbcType=VARCHAR}, '%')
or s.tele_number like concat('%', #{keyWord,jdbcType=VARCHAR}, '%')
)
</if>
<if test="limitNum != null and limitNum != '' ">
limit #{limitNum}
</if>
Because it's a fuzzy search with pop-up boxes , No need to paginate , You don't need to show all the data , So add a limit Just fine
Pass on :
{
"keyWord":"1",
"limitNum":"100"
}
We finally got it , Front end theory :“ All right ”
版权声明
本文为[The sky in July and August]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204211740318302.html
边栏推荐
猜你喜欢
随机推荐
Akismet插件教程WordPress阻止过滤垃圾邮件插件
Vulnerability detection and defense: redis unauthorized access vulnerability recurrence
Huawei URPF
Ros2 abandonment guide 5: creating topic for ros2
老电脑应该怎么重装系统比较好
Chest X-ray images - dataset
WPF references methods that uwp controls are not packaged for msix distribution
Spark SQL底层执行流程详解
华为URPF
MOS管和IGBT有什么区别?别傻傻分不清了
Mobile date plug-in (add your favorite)
[dynamic programming] 152 Product maximum subarray
169. 多数元素
Common problems and solutions of redis distributed lock
[stack] 155 Minimum stack
169. Most elements
MySQL advanced common functions
在阿里云上搭建个人博客(WordPress)
百度地图、腾讯地图、高德地图经纬度转换
Shell编程学习(三)条件判断、流程控制







