入参实体对象
@Data
public class ListByCustomerIdsAndProductIdsReq implements Serializable {
private Long customerId;
/**
* 产品唯一id
*/
private Long productId;
}
Mapper层
List<ListByCustomerIdsAndProductIdsRsp> listByCustomerIdsAndProductIds(@Param("companyCode") Long companyCode,@Param("reqList") List<ListByCustomerIdsAndProductIdsReq> reqList);
xml层
<select id="listByCustomerIdsAndProductIds" parameterType="com.manager.dto.customerbank.req.ListByCustomerIdsAndProductIdsReq" resultType="com.manager.dto.customerbank.rsp.ListByCustomerIdsAndProductIdsRsp">
select
cbp.customerId,
cbp.productId,
cb.bankName,
cb.accountNumber
from customer_bank_product cbp
inner join customer_bank cb on cb.companyCode = cbp.companyCode and cb.customerBankId = cbp.customerBankId and cb.isDelete = 0
where cbp.companyCode = #{companyCode}
AND cbp.isDelete = 0
AND (cbp.customerId, cbp.productId) IN
<foreach item="item" collection="reqList" open="(" separator="," close=")">
(#{item.customerId} , #{item.productId})
</foreach>
</select>
mybatis 查询入参是一个集合对象,如何写sql
于 2025-09-18 18:00:53 首次发布

被折叠的 条评论
为什么被折叠?



