后台代码
<select id="selectWorkNeedList" parameterType="WorkNeed" resultMap="WorkNeedResult">
<include refid="selectWorkNeedVo"/>
<where>
<if test="name != null and name != ''"> and n.name like concat('%', #{name}, '%')</if>
<if test="company != null and company != ''"> and n.company like concat('%', #{company}, '%')</if>
<if test="declarant != null and declarant != ''"> and n.declarant like concat('%', #{declarant}, '%')</if>
<if test="telephone != null "> and n.telephone = #{telephone}</if>
AND YEAR(n.create_time) = YEAR(NOW())
${params.dataScope}
</where>
order by n.create_time desc
</select>
<select>.....</select>语句中的 <if ....> </if>是用来过滤信息的。
and name like concat('%', #{name}是来进行模糊查询的,
telephone = #{telephone}时进行普通查询(查询信息必须输入完成)。
order by ...desc,按照某个属性降序排列(由大到小)