使用Wrapper条件类实现分页

时间:2019-08-31 17:31:24   收藏:0   阅读:1392

server层:   

        Wrapper<Ship> wrapper = new EntityWrapper<>();//条件类

        wrapper.where("user_id={0}",uid);//增加条件

        Page<Ship> shipPage = new Page<>(pageNum, pageSize);//分页类

        List<Ship> ships = shipMapper.selectPages(shipPage, wrapper);//去dao

        return new PageResult<>(shipPage.getTotal(), ships);

daoMapper层:        

List<Ship> selectPages(Page<Ship> page, @Param("ew") Wrapper<Ship> wrapper);

mapper.xml层:     

       <select id="selectPages" resultMap="BaseResultMap">

          select s.*,f.fsa_flag from tb_ship s left join tb_flag_state_authority f on s.fsa_id=f."id"

          <where>

            ${ew.sqlSegment}

          </where>
        </select>

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!