mybatis多条件对象查询
================ 此为 Mapper ================
List<ListCardPagingResponse> cardStockPagingByStoreCode(@Param("cardPagingRequest") CardPagingRequest cardPagingRequest, @Param("storeCodeList") List<String> storeCodeList);
================ 此为 Mapper.xml ================
<select id="cardStockPagingByStoreCode" resultType="com.lingzhi.retail.middleend.member.card.response.ListCardPagingResponse">
select
t.id,
t.make_card_order_id,
t.card_type_name,
t.card_no,
t.status,
t.shop_name,
t.corporation_name,
t.created_at
from card t
where 1=1
<if test="cardPagingRequest.makeCardOrderId != null">and t.`make_card_order_id` = #{cardPagingRequest.makeCardOrderId}</if>
<if test="cardPagingRequest.cardNo != null">and t.`card_no` = #{cardPagingRequest.cardNo}</if>
<if test="cardPagingRequest.corporationCode != null">and t.`corporation_code` = #{cardPagingRequest.corporationCode}</if>
<if test="cardPagingRequest.storeCode != null">and t.`shop_id` = #{cardPagingRequest.storeCode}</if>
<if test="cardPagingRequest.cardTypeName != null">and t.`card_type_name` = #{cardPagingRequest.cardTypeName}</if>
<if test="cardPagingRequest.startTime != null and cardPagingRequest.startTime != ''">and t.created_at <![CDATA[>=]]> CONCAT(#{cardPagingRequest.startTime},' 00:00:00')</if>
<if test="cardPagingRequest.endTime != null and cardPagingRequest.endTime != ''">and t.created_at <![CDATA[<=]]> CONCAT(#{cardPagingRequest.endTime},' 23:59:59')</if>
<if test="cardPagingRequest.status != null">and t.`status` = #{cardPagingRequest.status}</if>
and shop_id in (
<foreach collection="storeCodeList" separator="," item="item">
#{item}
</foreach>)
order by t.created_at DESC
</select>
两个对象都需要用@para标识;对象的字段都需要点出来!