mybatis多条件对象查询

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标识;对象的字段都需要点出来!

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值