<choose>
<when test="rq.timeType != null and rq.timeType == 'createTime'">
<if test="rq.startTime != '' and rq.startTime != null">
and s.createTime >= #{rq.startTime}
</if>
<if test="rq.endTime != '' and rq.endTime != null">
and s.createTime <= #{rq.endTime}
</if>
</when>
<when test="rq.timeType != null and rq.timeType == 'salesTime'">
<if test="rq.startTime != '' and rq.startTime != null">
and s.salesTime >= #{rq.startTime}
</if>
<if test="rq.endTime != '' and rq.endTime != null">
and s.salesTime <= #{rq.endTime}
</if>
</when>
<when test="rq.timeType != null and rq.timeType == 'verifyTime'">
<if test="rq.startTime != '' and rq.startTime != null">
and s.verifyTime >= #{rq.startTime}
</if>
<if test="rq.endTime != '' and rq.endTime != null">
and s.verifyTime <= #{rq.endTime}
</if>
</when>
<otherwise>
<if test="rq.startTime != '' and rq.startTime != null">
and s.salesTime >= #{rq.startTime}
</if>
<if test="rq.endTime != '' and rq.endTime != null">
and s.salesTime <= #{rq.endTime}
</if>
</otherwise>
</choose>
複数の時間タイプ (作成時間、監査時間など)、SQL での実装方法 (<choose> </choose> を使用)
おすすめ
転載: blog.csdn.net/linyiwwy/article/details/132166177
おすすめ
ランキング