mybatis-plus apply 使用和left join

单参数
lqw.apply("date_format(start_time, '%Y-%m-%d') = {0}", startTimeFormat);.apply("DATE_FORMAT(course_study_end_time,'%Y-%m-%d') > DATE_FORMAT(NOW(),'%Y-%m-%d')");

两个区间

 .apply(StringUtils.isNotEmpty(beginDate),"date_format (payment_time,'%Y-%m-%d') >= date_format('" + beginDate + "','%Y-%m-%d')")
                        .apply(StringUtils.isNotEmpty(endDate),"date_format (payment_time,'%Y-%m-%d') <= date_format('" + endDate + "','%Y-%m-%d')") 

ps: lamda 表达式前面都可以加条件

、、、、、、、left join、、、、、
controller:

Map<String,Object> map = new HashMap<>();
map.put("name",name);
map.put("startTime",startTime);
map.put("endTime",endTime);
map.put("list",Arrays.asList(user.getCommunityId()));
page = buildWuyePriceMapper.selectListPage(new Page<>(pageNum, pageSize),map);

mapper:

Page<BuildPropertyFundVo> selectListPage(Page<BuildPropertyFundVo> pagination, @Param(value = "para") Map<String,Object> para);

xml:

<select id="selectListPage" resultType="com.zscat.mallplus.build.entity.BuildPropertyFundVo">
        select w.name wuyeName,c.name areaName,sum(b.price) price,c.id comId
        from build_property_fund as b
        left join building_room r on b.room_id = r.id
        left join building_community c on r.community_id = c.id
        left join build_wuye_company w on c.company_id = w.id
        where 1=1
        <if test="para.name!=null and para.name!=''">
            and c.name = #{para.name}
        </if >
        <if test="para.list!=null and para.list.size()!=0">
            and c.id in
            <foreach collection="para.list" item="id" index="index"  open="(" close=")" separator=",">
                #{id}
            </foreach>
        </if >
        <if test="para.startTime!=null and para.startTime!=''">
            and DATE_FORMAT(b.create_date,'%Y-%m-%d') >=#{para.startTime}
        </if >
        <if test="para.endTime!=null and para.endTime!=''">
            and <![CDATA[ DATE_FORMAT(b.create_date,'%Y-%m-%d') <= #{para.endTime} ]]>
        </if >
        group by c.id
        order by b.create_date desc
    </select>

你可能感兴趣的:(MyBatis/Plus)