Mybatis中没有if-else的写法,取而代之的是choose-when-otherwise。choose在最外面,when相当于if,otherwise则相当于else。
<choose>
<when test="orderby.field != null and orderby.field != ''">
ORDER BY ta.${orderby.field} ${orderby.order}
</when>
<otherwise>
ORDER BY ta.create_date DESC
</otherwise>
</choose>