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