当前位置:网站首页>小小的模糊查询,竟来来回回修改了3次代码?找个电子厂上班吧
小小的模糊查询,竟来来回回修改了3次代码?找个电子厂上班吧
2022-04-21 17:40:00 【七八月的天空】
首先,架构是springboot+mybatis
模糊查询姓名、手机号,是不是很简单
第一次:
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,"姓名和手机号不能为空!");
}
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>
高高兴兴的提交了。。。
传参:
{
"name":"1",
"telNumber":"1"
}
第二次:
前端说,姓名和手机号要放一个字段传
改吧
<if test="keyWord != null and keyWord != '' ">
and (name like concat('%', #{keyWord,jdbcType=VARCHAR}, '%')
or s.tele_number like concat('%', #{keyWord,jdbcType=VARCHAR}, '%')
)
</if>
传参:
{
"keyWord":"1"
}
感觉很完美了。。提交!!!
第三次:
太年轻了,前端说:“传一个数字 1进来能查出几万条数据,前端页面崩了,加个限制吧”
<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>
因为是那种弹出框的模糊搜索,不需要分页,也不需要展示所有数据,所以加个limit就好了
传:
{
"keyWord":"1",
"limitNum":"100"
}
终于搞定了,前端说:“可以了”
版权声明
本文为[七八月的天空]所创,转载请带上原文链接,感谢
https://blog.csdn.net/x18094/article/details/121539090
边栏推荐
- MySQL基础合集
- 当你遇到技术难题之后的状态
- Using Jetson nano as an environmental weather station
- "Method breakpoints may drastically slow down debugging" will be prompted during idea debugging
- onnx效率问题:和Module & DataParallel比较
- How to show the ability of structure in the interview?
- Why can we use probability distribution density function to express probability?
- Yield function in Arduino esp8266
- Understand prototype patterns in minutes
- Vulnerability detection and defense: redis unauthorized access vulnerability recurrence
猜你喜欢
![[interview ordinary people vs Expert Series] can you talk about CAS mechanism?](/img/ec/2c96667f79f72872e0dd0169516446.png)
[interview ordinary people vs Expert Series] can you talk about CAS mechanism?

In cabin visual AI application front loading "increased by nearly 200% year-on-year". Which suppliers lead the Chinese market

DPI发布AI药物研发最新进展报告

在阿里云上搭建个人博客(WordPress)
本田北美产品规划发布!Insight混动停产,CR-V、雅阁即将发布

Precautions for MySQL aliasing database tables

数字化时代,企业运维面临现状及挑战分析解读

Detailed explanation of spark SQL underlying execution process

【栈】155. 最小栈

169. 多数元素
随机推荐
MySQL数据库常识之储存引擎
WPF 引用 UWP 控件 不打包为 MSIX 分发的方法
What is ODBC – open database connectivity
老电脑应该怎么重装系统比较好
MySQL进阶之表的增删改查
新技术的应用开启了有关产业互联网的第二条路径
直播带货源码,渐变式状态栏的不同写法
The difference between MSIL static class and non static class in IL definition
[sogaf] sogaf architecture type / mode
short_open_tag 短开放标签 必须打开
What is the "responsibility" of fault determination?
基于SSM的美容院管理系统(附源码+项目展示)
[an article helps you lay a good foundation for routing]
C# ODBC将一个文件夹的文件装载到MySQL数据库BLOB列,并将BLOB列下载到另一个文件夹
redis的watch机制
[dynamic programming] 152 Product maximum subarray
We sincerely invite you to sign up for the first openharmony developer growth plan sharing day
短视频平台搭建,仿制一个登陆界面的demo
How to turn on the undisturbed time with win10 memo how to set the message of rest day to be undisturbed
将模型训练外包真的安全吗?新研究:外包商可能植入后门,控制银行放款