实现通过接收参数不同值按照不同字段排序
dao层接口
List<Movie> findMovicesBySort(@Param("param") Integer param);
<select id="findMovicesBySort" resultType="com.tuling.entity.Movie" parameterType="int">
select *
from movie where movie_state=1
<if test="param==1">
order by movie_commentCount DESC ;
</if>
<if test="param==2">
order by movie_releaseDate DESC ;
</if>
<if test="param==3">
order by movie_score DESC ;
</if>
</select>