使用hashmap封装mybatis的查询参数:
HashMap<String, Object> map=new HashMap();
map.put("name","jack");
List<User> list=userService.getUserList(map);
mybatis查询语句
<select id="getUserList" resultType="com.test.entity.base.SysUser">
SELECT
*
FROM
user where deleted=0
<if test="username!= null and username != ''">
and username LIKE concat(concat('%',#{user.username}),'%')
</if>
<if test="type != null">
and type=#{type}
</if>
</select>
在实际项目中,频繁的查询需要重复构建hashmap,可以写一个工具类,构建hashmap
public static Map<String,Object> build(Object... param){
Map<String,Object&