使用的是OGNL表达式,表达式格式为:${@prefix@methodName(传递参数名称)}

1、赋值时判断

SELECT * FROM USER WHERE name='${@org.apache.commons.lang3@StringUtils(name)}' 

 

2、IF条件判断

<if test="@org.apache.commons.lang.StringUtils@isNotBlank(name)">name=#{name}</if>

 

3、自定义生成ID

<insert >
        insert into myproperty (id,asset_id,asset_name,dept_name,brand,specifications,units,produce_time,indate,purchase_time,price,
        total_money,address,classification,is_fixed) values
        <foreach collection="list" item="property" separator=",">
            (
            ${@cn.hutool.core.util.IdUtil@getSnowflake(1, 3).nextIdStr()},
            ${@cn.hutool.core.util.IdUtil@getSnowflake(1, 3).nextId()},
            #{property.assetName},
            #{property.deptName},
            #{property.brand},
            #{property.specifications},
            #{property.units},
            #{property.produceTime},
            #{property.indate},
            #{property.purchaseTime},
            #{property.price},
            #{property.price},
            #{property.address},
            #{property.classification},
            <choose>
                <when test="property.price > 1000">
                    '0'
                </when>
                <otherwise>
                    ''
                </otherwise>
            </choose>
            )
        </foreach>
</insert>

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-24
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-06
  • 2021-10-04
  • 2021-10-06
  • 2021-09-27
  • 2021-11-13
相关资源
相似解决方案