<!-- 条件指定検索 -->
<select id="search" resultType="com.example.demo.entity.UserInfo">
SELECT
*
FROM
userinfo
WHERE
delete_date IS NULL
<if test="id != null and id != ''">
AND id = #{id}
</if>
<if test="name != null and name != ''">
AND name LIKE CONCAT('%', #{name}, '%')
</if>
<if test="sortDirection == 'ASC' or sortDirection == ''">
ORDER BY ${sortId} ASC
</if>
<if test="sortDirection == 'DESC'">
ORDER BY ${sortId} DESC
</if>
</select>