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>