mybatis 传map参数
2023-09-27 14:20:50 时间
第一步在你的mapper写上:
List<WeixinUserLocationList> findweixinUserLocations(@Param("params") Map<String, Object> map);
注意就是注解@param 这个,是mybatis的
然后在xml中这样写:
<if test="params.accountId!=null"> and a.accountid=#{params.accountId} </if> <if test="params.nickname!=null and params.nickname !=''"> and a.nickname like '%${params.nickname}%' </if> <if test="params.beginDate!=null and params.beginDate!=''"> and date_format(a.createtime,'%Y-%m-%d')>=${params.beginDate} </if> <if test="params.endDate!=null and params.endDate!=''"> <![CDATA[ and date_format(a.createtime,'%Y-%m-%d')<=${params.endDate} ]]> </if>
${params.nickname}这种写法参数默认是传字符串,
#{params.accountId}可以取Long,Integer之类的。
好久没有用了,今天记一下...
相关文章
- hadoop中map和reduce的数量设置
- 集合框架Collection和Map总结,Collections工具类,集合答疑
- spring 3配置文件中如何注入map list set等类型
- MyBatis传入参数为list、数组、map写法
- Python面试题之Python中的lambda map filter reduce zip
- MyBatis-parameterType 入参封装 Map 流程
- 0082-Go-关联类型 map
- 枚举类型的数据存入到map中
- Google Map API 应用实例说明
- mybatis遍历map
- DNS map file in windows
- golang-map
- mybatis嵌套map或者map嵌套的parameterType
- mybatis 插入一条记录 参数为map的写法【用遍历Map的key和value的方式,可以实现只插入有效值】
- idea遍历map快捷键