Mybatis的分支选择和In循环
Mybatis的分支选择:
<choose>
<when test="patientNo != null and patientNo != ''">
and ipi.patient_no = #{patientNo}
</when>
<otherwise>
<if test="patientName != null and patientName != ''">
and ipi.patient_name like CONCAT('%',#{patientName},'%')
</if>
<trim prefix="where" prefixOverrides="and">
<if test="printTimeBegin != null and printTimeBegin != ''">
and mrm.print_time >= #{printTimeBegin}
</if>
<if test="printTimeEnd != null and printTimeEnd != ''">
and mrm.print_time <= #{printTimeEnd}
</if>
</trim>
</otherwise>
</choose>
循环In:
<if test='depts!=null and depts.size()>0'>
and ioh.department_id IN
<foreach item="item" index="index" collection="depts" open="(" separator="," close=")">
#{item}
</foreach>
</if>