有时候项目中没有配置xml文件,需要使用 @Select 注解做条件过滤查询,实例方法如下:
1 2 3 4 5 6 7 8 9 10 11
|
@Select("<script>" + "SELECT mobile,name,id FROM tab_user_info WHERE 1=1" + "<if test='mobile != null and mobile != \"\" '>" + " AND mobile = #{mobile}" + "</if>" + " AND age = '18' " + "</script>") Map<String, Object> selByMobile(String mobile);
|