dao层的代码:
public interface SupplierMapper extends BaseMapper<SupplierDbo>{ /*List<SupplierDbo> getAllSupplier(@Param("type") String type, @Param("cooperStatus") Integer cooperStatus, @Param("name") String name, @Param("supplierNo") String supplierNo);*/ List<SupplierDbo> getAllSupplier(@Param("supplierDbo") SupplierDbo supplierDbo,@Param("goodsClassDbo") GoodsClassDbo goodsClassDbo); }
传入的参数为两个实体类SupplierDbo、GoodsClassDbo
mapper中的代码:
<select id="getAllSupplier" resultType="java.util.Map"> SELECT s.name,s.supplier_no,s.address,s.contacts,s.phone_number, s.contact_begin_date,s.contact_period,s.period_type,s.cooper_status, s.licence,s.permission,s.settle_cycle ,s.bank_account,s.bank_name, gc.class_name FROM busi_supplier s LEFT JOIN busi_supplier_rel_goods sg ON s.supplier_no = sg.supplier_no LEFT JOIN busi_goods_class gc ON gc.id = sg.goods_class_id WHERE 1=1 <if test="goodsClassDbo.className != null and goodsClassDbo.className != ''"> AND gc.class_name = #{goodsClassDbo.className} </if> <if test="supplierDbo.cooperStatus != null"> AND s.cooper_status = #{supplierDbo.cooperStatus} </if> <if test="supplierDbo.name != null and supplierDbo.name != ''"> AND s.name = #{name} </if> <if test="supplierDbo.supplierNo != null and supplierDbo.supplierNo != ''"> AND s.supplier_no = #{supplierDbo.supplierNo} </if> </select>
dao层中使用@Param,然后mapper中使用@Param中的参数对相应的参数取值。
原文地址:https://www.cnblogs.com/huangzhe1515023110/p/9276100.html