如图:要实现车辆数不同区间查询条件
 
 
 
 
思路:a.前端传数组,数组里面放"1-5"String类型值
 
          b.后端mybatis用双foreach循环解析
 
 
后端代码如下:
 <!--图例车辆数区间-->
      <if test="countCargoList != null and countCargoList.size>0" >
          and (
          <foreach item="item" index="index" collection="countCargoList">
              (
            <foreach item="item2" index="index2" collection="item.split('-')">

                <if test="index2%2==0">
                    sfi.count_cargo &gt;= #{item2}
                </if>

                <if test="index2%2==1">
                    and sfi.count_cargo &lt;= #{item2}
                </if>

            </foreach>
              )
              <!--最后一次不用加or-->
              <if test="index != countCargoList.size-1" >
                  or
              </if>
          </foreach>
          )
      </if>

 

 
 

转载于:https://www.cnblogs.com/ejQiu-123/p/11448175.html

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐