mybatis-plus如果属性为空,则不查询

如题,如果插入部门-用xml方式则是:


 		insert into sys_dept(
 			dept_id,
 			parent_id,
 			dept_name,
 			ancestors,
 			order_num,
 			leader,
 			phone,
 			email,
 			status,
 			create_by,
 			create_time
 		)values(
 			#{deptId},
 			#{parentId},
 			#{deptName},
 			#{ancestors},
 			#{orderNum},
 			#{leader},
 			#{phone},
 			#{email},
 			#{status},
 			#{createBy},
 			sysdate()
 		)
	

在mybatis-plus中可以简单使用一个:

Map mapObj = BeanUtil.beanToMap(deptObj);

QueryWrapper queryWrapper = new QueryWrapper();

queryWrapper.allEq(mapObj,false);

List resultList = deptService.list(queryWrapper);

见:mybatisPlus-allEq介绍

你可能感兴趣的:(mybaits-plus,java)