publishId=20210722013&sort=all&type=all&categoryID=Notice
前端传输资料方式如上所示
后台mybatis处理如下所示
#{categoryID} 会自动加''
${publishId} 数据是什么就是什么,不会加''
<if test="输入的栏位名 运算符 比较的内容">
and 数据库栏位
</if>
<select id="ABD" resultType="Message" parameterType="String">
select * from Notice
<where>
categoryid = #{categoryID} and isvalid = 'Y' and publishId like '%${publishId}%'
<if test="type == 'top'">
and istop = 'Y'
</if>
<if test="type == 'supreme'">
and issupreme='Y'
</if>
<if test="sort=='timedesc'">
order by updatetime desc
</if>
<if test="sort== 'all' or sort=='timeasc'">
order by updatetime asc
</if>
<if test="sort=='viewdesc'">
order by viewcount desc
</if>
<if test="sort=='viewasc'">
order by viewcount asc
</if>
</where>
</select>