在MyBatis的Mapper中是不支持if-else语句,可以通过choose(即Java的switch语句)语句来进行替换
写法如下:
<choose>
<when test="consultationType != null">
AND a.consultation_type =#{consultationType}
</when>
<otherwise>
AND a.consultation_type IN(0,2)
</otherwise>
</choose>