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);
Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐