mybatis 判断参数有没有传入
<!--审核展示列表-->
<select id="auditResList" resultType="java.util.HashMap">
<include refid="auditRes"/>
</select>
<!--审核展示 一条-->
<select id="auditResInfo" resultType="java.util.HashMap">
<include refid="auditRes"/>
</select>
<sql id="auditRes">
SELECT
r.id AS resId,
r.res_desc,
r.res_type,
r.res_state,
r.expires_date,
r.res_pic_path,
ra.id as applyId,
ra.reason,
ra.apply_note,
ra.company_id,
ra.state,
r.res_name,
c.companyName,
c.shopName
FROM resource r
inner JOIN resource_apply ra
ON r.id = ra.res_id
left JOIN company c
on ra.company_id = c.companyId
<where>
r.res_state = 1
<if test="resType != null">
and r.res_type = #{resType}
</if>
<if test="_parameter.containsKey('applyId') and applyId != null">
and ra.id = #{applyId}
</if>
<if test=" _parameter.containsKey('state') and state != null">
and ra.state = #{state}
</if>
<if test=" _parameter.containsKey('resName') and resName != null and resName != ''">
and r.res_name like CONCAT('%', #{resName}, '%')
</if>
<if test=" _parameter.containsKey('companyName') and companyName != null and companyName != ''">
and c.companyName like CONCAT('%', #{companyName}, '%')
</if>
<if test=" _parameter.containsKey('shopName') and shopName != null and shopName != ''">
and c.shopName like CONCAT('%', #{shopName}, '%')
</if>
</where>
</sql> /**
* 审核展示列表
*
* @param resType
* @return
*/
List<HashMap> auditResList(@Param("resType") Integer resType,
@Param("companyName") String companyName,
@Param("shopName") String shopName,
@Param("state") Integer state,
@Param("resName") String resName); /**
* 审核展示 一条
*
* @param resType
* @param applyId
* @return
*/
HashMap auditResInfo(@Param("resType") Integer resType, @Param("applyId") Integer applyId);
mybatis 判断参数有没有传入的更多相关文章
- MyBatis的参数,不能传入null
今天在调试的过程中发现一个bug,把传入的参数写到查询分析器中执行没有问题,但是在程序中执行就报错:org.springframework.jdbc.UncategorizedSQLException ...
- mybatis mapper文件sql语句传入hashmap参数
1.怎样在mybatis mapper文件sql语句传入hashmap参数? 答:直接这样写map就可以 <select id="selectTeacher" paramet ...
- mybatis 传递参数的方法总结
有三种mybatis传递参数的方式: 第一种 mybatis传入参数是有序号的,可以直接用序号取得参数 User selectUser(String name,String area); 可以在xml ...
- mybatis中参数为list集合时使用 mybatis in查询
mybatis中参数为list集合时使用 mybatis in查询 一.问题描述mybatis sql查询时,若遇到多个条件匹配一个字段,sql 如: select * from user where ...
- 【mybatis源码学习】mybatis的参数处理
一.mybatis的参数处理以及参数取值 1.单个参数 mybatis不做任何处理 取值方式: #{参数名/任意名} <!-- Employee getEmpById(Integer id) ...
- MyBatis 判断条件为等于的问题
在用MyBatis操作数据库的时候相信很多人都用到,当在判断null, 大于,大于等于,小于,小于等于,不等于时估计很多都用到,比较容易实现了,这里就省略了,但唯独判断条件为等于时估计蛮多人遇到坑了, ...
- 【转载】Mybatis多参数查询映射
转载地址:http://www.07net01.com/zhishi/402787.html 最近在做一个Mybatis的项目,由于是接触不久,虽然看了一下资料,但在实际开发中还是暴 露了很多问题,其 ...
- mybatis判断集合为空或者元素个数为零
mybatis判断集合为空或者元素个数为零: <if test="mlhs != null and mlhs.size() != 0"> and t.mlh_name ...
- MyBatis传递参数
MyBatis传递参数 一.使用 map 接口传递参数 在 MyBatis 中允许 map 接口通过键值对传递多个参数,把接口方法定义为 : public List<Role> findR ...
随机推荐
- 关于在namanode上编写脚本控制DataNode的...
脚本如下:(我的虚拟机名字分别为:wang201 wang 202 wang 203 wang 204) params=$@ i= ; i <= ; i++)) ; do echo ====== ...
- batch-normalization为什么效果好
batch-normalization为什么效果好 深度学习中 Batch Normalization为什么效果好? - 龙鹏-言有三的回答 - 知乎 https://www.zhihu.com/qu ...
- tomcat8+idea远程调试
window下 setenv.bat增加 set JPDA_OPTS=-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n lin ...
- Python登录人人网并抓取新鲜事
from sgmllib import SGMLParser import sys,urllib2,urllib,cookielib class spider(SGMLParser): def ...
- 连续小波变换(CWT)
整理下时频分析变换的方法,遇见好的文章就记录下来了,本篇博客参考知乎https://www.zhihu.com/topic/19621077/top-answers上的一个回答,自己手敲一遍,增强记忆 ...
- android基础知识杂记
Activity中获取视图组件对象:public View findViewById(@IdRes int id) 该方法以组件的资源ID为参数,返回一个视图对象View,需要强转成具体的视图类对象. ...
- Hotspot GC实现原理
GC扫描 可达性分析的GC Roots主要是全局性引用或在Stack Frame中 ,现在的应用仅仅方法区往往就有几百兆,这样要这个检查这里面的引用,就必然会消耗很多时间,效率很低. 分析工作在一个保 ...
- 新博客 http://kunyashaw.com/
感谢博客园. 请关注我的新博客: http://kunyashaw.com/
- ios开发学习笔记003-流程控制和类型转换
流程控制 顺序结构.选择结构.循环结构 1.顺序结构 程序默认是顺序执行的. 2.选择结构 if选择语句 第一种情况 if(条件)//条件成立执行下面语句 { //语句 } 第二种情况 if(条件)/ ...
- Android EditText禁止换行键(回车键enter)
在EditText所在的xml文件中,设置android:singleLine="true", 则可以禁止掉虚拟键盘: maxlength为该EditText的最大输入长度: &l ...