2021-12-27 星期一 1035 by:enAn
where: 当where没有任何条件的时候,可以都执行,不用1=1
if中对数字型参数-处理:
<where> <!-- 当where没有任何条件的时候,可以都执行,不用1=1 -->
1.如果是数字型,只需要[status != null],不能后面加,否则把数字0的值丢弃
<if test="( status != null and status !='' )">
2.或者也可以:
<if test="(status != null and status != '' ) || status == 0">
完整的
--------------------------------------------------------------------------------------------------------------------
@ApiModelProperty("*供应商订单状态:0-待发货,1-发货中,2-发货失败,3-已完成")//订单状态
private Integer status;
<!-- 供应商订单状态:0-待发货,1-发货中,2-发货失败,3-已完成" 订单状态 -->
--------------------------------------------------------------------------------------------------------------------
<where> <!-- 当where没有任何条件的时候,可以都执行,不用1=1 -->
<if test="(qo.status != null and qo.status != '') || qo.status == 0">
and a.i_status = #{qo.status}
</if>
</where>
--------------------------------------------------------------------------------------------------------------------
修改正为: 如果是数字型,只需要[qo.status != null],不能后面加[qo.status != ''],否则把数字0的值丢弃
<where> <!-- 当where没有任何条件的时候,可以都执行,不用1=1 -->
<if test=" qo.status != null ">
and a.i_status = #{qo.status}
</if>
--------------------------------------------------------------------------------------------------------------------
版权声明:本文为yuxueyuanwj原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。