欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

mapper中String类型传入数据查询和对象传入查询区别

程序员文章站 2022-07-15 14:28:14
...
public List<testPO>  pageList(@Param("param") testQuery query);

    <select id="pageList" resultType="com.XXX.XX.XX.po.XX.testPO">
    SELECT *
    FROM
        test  a
    WHERE
        1=1
    <if test="param.id != null and param.id != ''">
        AND a.id=#{param.d}
    </if>
    <if test="param.name != null and param.name != ''">
        AND a.name like concat('%',#{param.name},'%')
    </if>
    <if test="param.number != null and param.number != ''">
        AND a.number  like concat('%',#{param.number},'%')
    </if>
    <include refid="drSQL"/>
</select>

public testPO selectById(@Param("id") String id);
<select id="selectById" parameterType="String" resultType="com.XXX.XX.XX.po.XX.testPO">
    SELECT *
    FROM
    test  a
    WHERE
    1=1
    AND a.id=#{id}
    <include refid="drSQL"/>
</select>

<sql id="tenantIdSQL">
    <if test="param.tenantId != null and param.tenantId!=''">
        AND a.tenant_id = #{param.tenantId}
    </if>
</sql>

<sql id="drSQL">
    AND a.dr = 0
</sql>
相关标签: java