zoukankan      html  css  js  c++  java
  • 关于mybatis对实体类参数绑定参数的问题

    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
  • 相关阅读:
    Django(72)Django认证系统库--djoser
    Django(71)图片处理器django-imagekit
    python进阶(21)typing模块--类型提示支持
    Jmeter 参数化-文件和参数同时上传的场景
    Java线程监控之 jvisualvm 和 jstack
    操作系统监控
    Redis安装部署
    Mac下charles安装及配置
    Prometheus 监控平台部署
    Nginx配置(九)
  • 原文地址:https://www.cnblogs.com/jpfss/p/11346839.html
Copyright © 2011-2022 走看看