mybatis-Plus自定义IPage分页查询传参

//传统传参
QueryWrapper<Table> queryWrapper = new QueryWrapper<Table>(query);
queryWrapper.eq("A.CREATER_UNIT_ID", createrUnitId);
//字符串传参
String createrUnitId="1111";
IPage<TableVo> data=tableMapper.getTablePage(page,queryWrapper,createrUnitId);
IPage<TableVo> getTablePage(Page<TableVo> page,
@Param(Constants.WRAPPER) QueryWrapper<Table> queryWrapper,
@Param("createrUnitId") String createrUnitId);
<select id="getTablePage" resultType="com.vo.TableVo" resultMap="BaseResultTableMap">
  select A.*  from TABLE A
  left join TABLE_LIST B ON (A.id=B.TABLE_ID   
  <!--自定义字符串传参-->
  <if test="createrUnitId!= null and createrUnitId!= ">
      and B.CREATER_UNIT_ID = #{
          
   createrUnitId}
  </if>
 )
   
 <!--自定义对象传参-->
 <if test="ew.emptyOfWhere == false">
    ${
          
   ew.customSqlSegment}
 </if>
</select>

增加构造器QueryWrapper大部分使用说明

经验分享 程序员 微信小程序 职场和发展