<sql id="queryWhereId">
from sys_logs
<where>
<if test="username!=null and username != ''">
username like concat('%' , #{username} , '%')
</if>
</where>
</sql>
<!-- 基于用户名,动态拼接sql实现数据库查询 -->
<select id="findPageObjects" resultType="com.edut.springboot.tarena.pojo.SysLog">
select *
<include refid="queryWhereId" />
order by createdTime desc
limit #{startIndex} , #{pageSize}
</select>