mybatisplus在xml中使用wrapper备忘

mapper:

IPage<PurchasePlan> listWithZj(Page page, @Param(Constants.WRAPPER) Wrapper<T> wrapper);

xml:

 <select id="listWithZj" resultType="org.jeecg.modules.gz.purchase.entity.PurchasePlan">
        select a.*,case when b.project_id is null then 0 else 1 end hasLz from gz_purchase_plan a
        left join projectlz b
        on a.id=b.plan_id
        ${ew.customSqlSegment}
    </select>

还有一个情况,在sql中已经写有条件了,传入的条件需要拼接到一起,就用 ${ew.sqlSegment}

select * from meet_reserve_room r
        left join meet_reserve_order o
        on r.order_id=o.id
        where o.`status` is null or o.`status`!=2
        <if test="ew != null">
            <if test="ew.nonEmptyOfWhere">
                AND
            </if>
            ${ew.sqlSegment}
        </if>

上边两个是关联查询的,在wrapper中需要写表名:

QueryWrapper<T> wrapper = new QueryWrapper<T>();
        wrapper.eq("r.room_id",vo.getRoomId());
        wrapper.in("r.meet_date",dates);

        List<ReserveRoom> list = reserveRoomService.listNormal(wrapper);
  • 6
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值